All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ioc.commons.impl.android.flowcontrol.activity.ShellActionBarActivity Maven / Gradle / Ivy

package org.ioc.commons.impl.android.flowcontrol.activity;

import java.util.HashMap;
import java.util.Map;

import org.ioc.commons.flowcontrol.actioncontroller.ActionController;
import org.ioc.commons.flowcontrol.actioncontroller.ActionControllerBinder;
import org.ioc.commons.flowcontrol.actioncontroller.IsExternalAction;
import org.ioc.commons.flowcontrol.eventbus.EventBus;
import org.ioc.commons.flowcontrol.eventbus.EventBusBinder;
import org.ioc.commons.flowcontrol.eventbus.IsEvent;
import org.ioc.commons.flowcontrol.operationmanager.IsOperation;
import org.ioc.commons.flowcontrol.operationmanager.OperationManager;
import org.ioc.commons.flowcontrol.operationmanager.OperationManagerBinder;
import org.ioc.commons.impl.android.flowcontrol.AndroidFlowController;
import org.ioc.commons.ui.HasStorage;
import org.ioc.commons.ui.IsDisplay;
import org.ioc.commons.ui.IsPresenter;
import org.ioc.commons.ui.IsWidget;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.HasContext;

public class ShellActionBarActivity, O extends Enum, A extends Enum, P extends IsPresenter>
		extends ActionBarActivity implements IsDisplay, HasStorage, HasContext {

	protected final AndroidFlowController flowController = new AndroidFlowController(this, false);
	protected final EventBus eventbus = flowController.eventBus();
	protected final OperationManager operationManager = flowController.operationManager();
	protected final ActionController actionController = flowController.actionController();
	private final Map storage = new HashMap();

	protected P presenter;

	private boolean initialized;
	private boolean isRunning;

	@Override
	public Context getContext() {
		return this;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}
	
	@Override
	protected void onStart() {
		super.onStart();

		this.isRunning = true;

		if (this.presenter != null && !this.initialized) {
			this.initialized = true;
			this.presenter.onInitDisplay();
		}

		this.flowController.onStart();
	}

	@Override
	public boolean isInitialized() {
		return initialized;
	}

	@Override
	public Object asWidget() {
		/*
		 * The activity as-is
		 */
		return this;
	}

	@Override
	public IsWidget getWidgetParent() {
		/*
		 * Activities do not have parents
		 */
		return null;
	}

	@Override
	protected void onResume() {
		super.onResume();
		this.isRunning = true;

		this.flowController.onResume();

	}

	@Override
	protected void onPause() {
		super.onPause();
		this.isRunning = false;

		this.flowController.onPause();
	}
	
	@Override
	protected void onStop() {
		super.onStop();
		
		this.flowController.onStop();
	}

	@Override
	public void onDestroy() {
		super.onDestroy();

		this.flowController.onDestroy();
	}

	@Override
	public EventBusBinder eventBus() {
		return this.eventbus;
	}

	@Override
	public OperationManagerBinder operationManager() {
		return this.operationManager;
	}

	@Override
	public ActionControllerBinder actionController() {
		return this.actionController;
	}

	@Override
	public void store(Object key, Object data) {
		storage.put(key, data);
	}

	@Override
	public Object retrieve(Object key) {
		return storage.get(key);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy