org.ioc.commons.impl.android.ui.FragmentView Maven / Gradle / Ivy
package org.ioc.commons.impl.android.ui;
import org.ioc.commons.flowcontrol.actioncontroller.IsExternalAction;
import org.ioc.commons.flowcontrol.eventbus.IsEvent;
import org.ioc.commons.flowcontrol.operationmanager.IsOperation;
import org.ioc.commons.ui.IsView;
import org.ioc.commons.ui.IsViewPresenter;
import android.app.Activity;
public class FragmentView, O extends Enum extends IsOperation>, A extends Enum extends IsExternalAction>, P extends IsViewPresenter>
extends FragmentDisplay implements IsView {
/**
* Determines if {@link #activate()} and {@link #deactivate()} methods will
* be automatically invoked when {@link #onLoad()} and {@link #onUnload()}
* methods are called. By default value is true.
*/
private boolean autoActivation = true;
private boolean manuallyActive;
/**
* Default constructor. By default auto activation is true.
*
* @see FragmentView#autoActivation
*/
public FragmentView() {
}
/**
* Constructor which set value of {@link #autoActivation}
*
* @param autoActivation
*
* @see FragmentView#autoActivation
*/
public FragmentView(boolean autoActivation) {
this.autoActivation = autoActivation;
}
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// this.setRetainInstance(true);
// }
/**
* This method should be manually called to indicate view is active when
* {@link #autoActivation} is false.
*/
@Override
public void activate() {
this.manuallyActive = true;
if (this.presenter != null) {
this.presenter.onActive();
}
}
/**
* This method should be manually called to indicate view is not active when
* {@link #autoActivation} is false.
*/
@Override
public void deactivate() {
this.manuallyActive = false;
if (this.presenter != null) {
this.presenter.onDeactive();
}
}
@Override
public boolean isActive() {
// View view = this.getView();
// int b = getChildFragmentManager().getBackStackEntryCount();
// if (getChildFragmentManager() != null) {
// getChildFragmentManager().executePendingTransactions();
// }
boolean added = this.isAdded();
// boolean attached = view != null ? view.isAttachedToWindow() : false;
return this.autoActivation ? added : this.manuallyActive;
}
@Override
public void onResume() {
super.onResume();
if (this.autoActivation && !this.manuallyActive) {
activate();
}
}
@Override
public void onPause() {
super.onPause();
if (this.autoActivation && this.manuallyActive) {
deactivate();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy