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.
Java Source Code
package in.srain.cube.app.lifecycle;
//fromwww.java2s.comimport java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
publicclass LifeCycleComponentManager implements IComponentContainer {
private HashMap<String, LifeCycleComponent> mComponentList;
public LifeCycleComponentManager() {
}
/**
* Try to add component to container
*
* @param component
* @param matrixContainer
*/publicstaticvoid tryAddComponentToContainer(LifeCycleComponent component, Object matrixContainer) {
tryAddComponentToContainer(component, matrixContainer, true);
}
publicstaticboolean tryAddComponentToContainer(LifeCycleComponent component, Object matrixContainer, boolean throwEx) {
if (matrixContainer instanceof IComponentContainer) {
((IComponentContainer) matrixContainer).addComponent(component);
return true;
} else {
if (throwEx) {
thrownew IllegalArgumentException("componentContainerContext should implements IComponentContainer");
}
return false;
}
}
publicvoid addComponent(LifeCycleComponent component) {
if (component != null) {
if (mComponentList == null) {
mComponentList = new HashMap<String, LifeCycleComponent>();
}
mComponentList.put(component.toString(), component);
}
}
publicvoid onBecomesVisibleFromTotallyInvisible() {
if (mComponentList == null) {
return;
}
Iterator<Entry<String, LifeCycleComponent>> it = mComponentList.entrySet().iterator();
while (it.hasNext()) {
LifeCycleComponent component = it.next().getValue();
if (component != null) {
component.onBecomesVisibleFromTotallyInvisible();
}
}
}
publicvoid onBecomesTotallyInvisible() {
if (mComponentList == null) {
return;
}
Iterator<Entry<String, LifeCycleComponent>> it = mComponentList.entrySet().iterator();
while (it.hasNext()) {
LifeCycleComponent component = it.next().getValue();
if (component != null) {
component.onBecomesTotallyInvisible();
}
}
}
publicvoid onBecomesPartiallyInvisible() {
if (mComponentList == null) {
return;
}
Iterator<Entry<String, LifeCycleComponent>> it = mComponentList.entrySet().iterator();
while (it.hasNext()) {
LifeCycleComponent component = it.next().getValue();
if (component != null) {
component.onBecomesPartiallyInvisible();
}
}
}
publicvoid onBecomesVisibleFromPartiallyInvisible() {
if (mComponentList == null) {
return;
}
Iterator<Entry<String, LifeCycleComponent>> it = mComponentList.entrySet().iterator();
while (it.hasNext()) {
LifeCycleComponent component = it.next().getValue();
if (component != null) {
component.onBecomesVisible();
}
}
}
publicvoid onDestroy() {
if (mComponentList == null) {
return;
}
Iterator<Entry<String, LifeCycleComponent>> it = mComponentList.entrySet().iterator();
while (it.hasNext()) {
LifeCycleComponent component = it.next().getValue();
if (component != null) {
component.onDestroy();
}
}
}
}