Search in sources :

Example 1 with ChatListScreen

use of com.example.mortar.screen.ChatListScreen in project simple-stack by Zhuinden.

the class MortarDemoActivity method handleStateChange.

@Override
public void handleStateChange(StateChange stateChange, Callback completionCallback) {
    BaseKey newScreen = stateChange.topNewState();
    String title = newScreen.title();
    ActionBarOwner.MenuAction menu = new ActionBarOwner.MenuAction("Friends", new Action() {

        @Override
        public void run() throws Exception {
            Navigator.getBackstack(MortarDemoActivity.this).goTo(FriendListScreen.create());
        }
    });
    actionBarOwner.setConfig(new ActionBarOwner.Config(false, !(newScreen instanceof ChatListScreen), title, menu));
    completionCallback.stateChangeComplete();
}
Also used : Action(io.reactivex.functions.Action) ChatListScreen(com.example.mortar.screen.ChatListScreen) BaseKey(com.example.mortar.util.BaseKey) ActionBarOwner(com.example.mortar.android.ActionBarOwner)

Example 2 with ChatListScreen

use of com.example.mortar.screen.ChatListScreen in project mortar by square.

the class MortarDemoActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    GsonParceler parceler = new GsonParceler(new Gson());
    @SuppressWarnings("deprecation") FlowDelegate.NonConfigurationInstance nonConfig = (FlowDelegate.NonConfigurationInstance) getLastNonConfigurationInstance();
    MortarScope parentScope = MortarScope.getScope(getApplication());
    String scopeName = getLocalClassName() + "-task-" + getTaskId();
    activityScope = parentScope.findChild(scopeName);
    if (activityScope == null) {
        activityScope = parentScope.buildChild().withService(BundleServiceRunner.SERVICE_NAME, new BundleServiceRunner()).build(scopeName);
    }
    ObjectGraphService.inject(this, this);
    getBundleServiceRunner(activityScope).onCreate(savedInstanceState);
    actionBarOwner.takeView(this);
    setContentView(R.layout.root_layout);
    container = (PathContainerView) findViewById(R.id.container);
    containerAsHandlesBack = (HandlesBack) container;
    flowDelegate = FlowDelegate.onCreate(nonConfig, getIntent(), savedInstanceState, parceler, History.single(new ChatListScreen()), this);
}
Also used : BundleServiceRunner(mortar.bundler.BundleServiceRunner) BundleServiceRunner.getBundleServiceRunner(mortar.bundler.BundleServiceRunner.getBundleServiceRunner) FlowDelegate(flow.FlowDelegate) GsonParceler(com.example.mortar.screen.GsonParceler) MortarScope(mortar.MortarScope) ChatListScreen(com.example.mortar.screen.ChatListScreen) Gson(com.google.gson.Gson)

Example 3 with ChatListScreen

use of com.example.mortar.screen.ChatListScreen in project mortar by square.

the class MortarDemoActivity method dispatch.

@Override
public void dispatch(Flow.Traversal traversal, Flow.TraversalCallback callback) {
    Path newScreen = traversal.destination.top();
    String title = newScreen.getClass().getSimpleName();
    ActionBarOwner.MenuAction menu = new ActionBarOwner.MenuAction("Friends", new Action0() {

        @Override
        public void call() {
            Flow.get(MortarDemoActivity.this).set(new FriendListScreen());
        }
    });
    actionBarOwner.setConfig(new ActionBarOwner.Config(false, !(newScreen instanceof ChatListScreen), title, menu));
    container.dispatch(traversal, callback);
}
Also used : Path(flow.path.Path) Action0(rx.functions.Action0) FriendListScreen(com.example.mortar.screen.FriendListScreen) ChatListScreen(com.example.mortar.screen.ChatListScreen) ActionBarOwner(com.example.mortar.android.ActionBarOwner)

Aggregations

ChatListScreen (com.example.mortar.screen.ChatListScreen)3 ActionBarOwner (com.example.mortar.android.ActionBarOwner)2 FriendListScreen (com.example.mortar.screen.FriendListScreen)1 GsonParceler (com.example.mortar.screen.GsonParceler)1 BaseKey (com.example.mortar.util.BaseKey)1 Gson (com.google.gson.Gson)1 FlowDelegate (flow.FlowDelegate)1 Path (flow.path.Path)1 Action (io.reactivex.functions.Action)1 MortarScope (mortar.MortarScope)1 BundleServiceRunner (mortar.bundler.BundleServiceRunner)1 BundleServiceRunner.getBundleServiceRunner (mortar.bundler.BundleServiceRunner.getBundleServiceRunner)1 Action0 (rx.functions.Action0)1