Search in sources :

Example 11 with Router

use of com.bluelinelabs.conductor.Router in project Conductor by bluelinelabs.

the class ControllerPagerAdapter method instantiateItem.

@Override
public Object instantiateItem(ViewGroup container, int position) {
    final String name = makeControllerName(container.getId(), getItemId(position));
    Router router = host.getChildRouter(container, name);
    if (savesState && !router.hasRootController()) {
        Bundle routerSavedState = savedPages.get(position);
        if (routerSavedState != null) {
            router.restoreInstanceState(routerSavedState);
        }
    }
    final Controller controller;
    if (!router.hasRootController()) {
        controller = getItem(position);
        router.setRoot(RouterTransaction.with(controller).tag(name));
    } else {
        router.rebindIfNeeded();
        controller = router.getControllerWithTag(name);
    }
    if (controller != null) {
        visiblePageIds.put(position, controller.getInstanceId());
    }
    return router.getControllerWithTag(name);
}
Also used : Bundle(android.os.Bundle) Router(com.bluelinelabs.conductor.Router) Controller(com.bluelinelabs.conductor.Controller)

Example 12 with Router

use of com.bluelinelabs.conductor.Router in project Conductor by bluelinelabs.

the class RouterPagerAdapter method instantiateItem.

@Override
public Object instantiateItem(ViewGroup container, int position) {
    final String name = makeRouterName(container.getId(), getItemId(position));
    Router router = host.getChildRouter(container, name);
    if (!router.hasRootController()) {
        Bundle routerSavedState = savedPages.get(position);
        if (routerSavedState != null) {
            router.restoreInstanceState(routerSavedState);
            savedPages.remove(position);
            savedPageHistory.remove((Integer) position);
        }
    }
    router.rebindIfNeeded();
    configureRouter(router, position);
    if (router != currentPrimaryRouter) {
        for (RouterTransaction transaction : router.getBackstack()) {
            transaction.controller().setOptionsMenuHidden(true);
        }
    }
    visibleRouters.put(position, router);
    return router;
}
Also used : RouterTransaction(com.bluelinelabs.conductor.RouterTransaction) Bundle(android.os.Bundle) Router(com.bluelinelabs.conductor.Router)

Aggregations

Router (com.bluelinelabs.conductor.Router)12 Bundle (android.os.Bundle)5 Controller (com.bluelinelabs.conductor.Controller)4 ActivityHostedRouter (com.bluelinelabs.conductor.ActivityHostedRouter)3 Menu (android.view.Menu)2 MenuItem (android.view.MenuItem)2 RouterTransaction (com.bluelinelabs.conductor.RouterTransaction)2 Activity (android.app.Activity)1 IdRes (android.support.annotation.IdRes)1 ViewGroup (android.view.ViewGroup)1 FrameLayout (android.widget.FrameLayout)1 ControllerChangeHandler (com.bluelinelabs.conductor.ControllerChangeHandler)1 ControllerChangeType (com.bluelinelabs.conductor.ControllerChangeType)1 FadeChangeHandler (com.bluelinelabs.conductor.changehandler.FadeChangeHandler)1 BaseController (com.bluelinelabs.conductor.demo.controllers.base.BaseController)1 FakePager (com.bluelinelabs.conductor.support.util.FakePager)1 TestController (com.bluelinelabs.conductor.support.util.TestController)1 BaseController (com.nextcloud.talk.controllers.base.BaseController)1