Back to project page cube-sdk.
The source code is released under:
Apache License
If you think the Android project cube-sdk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package in.srain.cube.app; /* w ww. j a v a 2 s . co m*/ import android.os.Bundle; import android.util.Log; import in.srain.cube.app.lifecycle.IComponentContainer; import in.srain.cube.app.lifecycle.LifeCycleComponent; import in.srain.cube.app.lifecycle.LifeCycleComponentManager; import in.srain.cube.util.Debug; /** * 1. manager the components when move from a lifetime to another * * @author http://www.liaohuqiu.net */ public abstract class XActivity extends CubeFragmentActivity implements IComponentContainer { private LifeCycleComponentManager mComponentContainer = new LifeCycleComponentManager(); private static final boolean DEBUG = Debug.DEBUG_LIFE_CYCLE; @Override protected void onRestart() { super.onStart(); mComponentContainer.onBecomesVisibleFromTotallyInvisible(); if (DEBUG) { showStatus("onRestart"); } } @Override protected void onPause() { super.onPause(); mComponentContainer.onBecomesPartiallyInvisible(); if (DEBUG) { showStatus("onPause"); } } @Override protected void onResume() { super.onResume(); mComponentContainer.onBecomesVisibleFromPartiallyInvisible(); if (DEBUG) { showStatus("onResume"); } } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (DEBUG) { showStatus("onCreate"); } } @Override protected void onStop() { super.onStop(); mComponentContainer.onBecomesTotallyInvisible(); if (DEBUG) { showStatus("onStop"); } } @Override protected void onDestroy() { super.onDestroy(); mComponentContainer.onDestroy(); if (DEBUG) { showStatus("onDestroy"); } } @Override public void addComponent(LifeCycleComponent component) { mComponentContainer.addComponent(component); } private void showStatus(String status) { final String[] className = ((Object) this).getClass().getName().split("\\."); Log.d("cube-lifecycle", String.format("%s %s", className[className.length - 1], status)); } }