use of com.bluelinelabs.conductor.Controller in project talk-android by nextcloud.
the class BaseController method setTitle.
protected void setTitle() {
Controller parentController = getParentController();
while (parentController != null) {
if (parentController instanceof BaseController && ((BaseController) parentController).getTitle() != null) {
return;
}
parentController = parentController.getParentController();
}
String title = getTitle();
ActionBar actionBar = getActionBar();
if (title != null && actionBar != null) {
actionBar.setTitle(title);
}
}
use of com.bluelinelabs.conductor.Controller in project talk-android by nextcloud.
the class BottomNavigationController method navigateTo.
/**
* Navigate to the supplied {@link Controller}, while setting the menuItemId as selected on the
* {@link BottomNavigationView}.
*
* @param itemId {@link MenuItem} ID
* @param controller {@link Controller} matching the itemId
*/
protected void navigateTo(int itemId, @NonNull Controller controller) {
if (currentlySelectedItemId != itemId) {
destroyChildRouter(lastActiveChildRouter, currentlySelectedItemId);
/* Ensure correct Checked state based on new selection */
Menu menu = bottomNavigationView.getMenu();
for (int i = 0; i < menu.size(); i++) {
MenuItem menuItem = menu.getItem(i);
if (menuItem.isChecked() && menuItem.getItemId() != itemId) {
menuItem.setChecked(false);
} else if (menuItem.getItemId() == itemId) {
menuItem.setChecked(true);
}
}
currentlySelectedItemId = itemId;
Router childRouter = getChildRouter(currentlySelectedItemId);
if (configureRouter(childRouter, currentlySelectedItemId)) {
/* Determine if a Controller of same class already exists in the backstack */
Controller backstackController;
int size = childRouter.getBackstackSize();
for (int i = 0; i < size; i++) {
backstackController = childRouter.getBackstack().get(i).controller();
if (BottomNavigationUtils.equals(backstackController.getClass(), controller.getClass())) {
/* Match found at root - so just set new root */
if (i == size - 1) {
childRouter.setRoot(RouterTransaction.with(controller));
} else {
/* Match found at i - pop until we're at the matching Controller */
for (int j = size; j < i; j--) {
childRouter.popCurrentController();
}
/* Replace the existing matching Controller with the new */
childRouter.replaceTopController(RouterTransaction.with(controller));
}
}
}
}
} else {
resetCurrentBackstack();
}
}
use of com.bluelinelabs.conductor.Controller in project Conductor by bluelinelabs.
the class ControllerLifecycleSubjectHelper method create.
public static BehaviorSubject<ControllerEvent> create(Controller controller) {
ControllerEvent initialState;
if (controller.isBeingDestroyed() || controller.isDestroyed()) {
throw new OutsideLifecycleException("Cannot bind to Controller lifecycle when outside of it.");
} else if (controller.isAttached()) {
initialState = ControllerEvent.ATTACH;
} else if (controller.getView() != null) {
initialState = ControllerEvent.CREATE_VIEW;
} else if (controller.getActivity() != null) {
initialState = ControllerEvent.CONTEXT_AVAILABLE;
} else {
initialState = ControllerEvent.CREATE;
}
final BehaviorSubject<ControllerEvent> subject = BehaviorSubject.create(initialState);
controller.addLifecycleListener(new LifecycleListener() {
@Override
public void preContextAvailable(@NonNull Controller controller) {
subject.onNext(ControllerEvent.CONTEXT_AVAILABLE);
}
@Override
public void preCreateView(@NonNull Controller controller) {
subject.onNext(ControllerEvent.CREATE_VIEW);
}
@Override
public void preAttach(@NonNull Controller controller, @NonNull View view) {
subject.onNext(ControllerEvent.ATTACH);
}
@Override
public void preDetach(@NonNull Controller controller, @NonNull View view) {
subject.onNext(ControllerEvent.DETACH);
}
@Override
public void preDestroyView(@NonNull Controller controller, @NonNull View view) {
subject.onNext(ControllerEvent.DESTROY_VIEW);
}
@Override
public void preContextUnavailable(@NonNull Controller controller, @NonNull Context context) {
subject.onNext(ControllerEvent.CONTEXT_UNAVAILABLE);
}
@Override
public void preDestroy(@NonNull Controller controller) {
subject.onNext(ControllerEvent.DESTROY);
}
});
return subject;
}
use of com.bluelinelabs.conductor.Controller in project Conductor by bluelinelabs.
the class ControllerPagerAdapter method destroyItem.
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
Router router = ((Controller) object).getRouter();
if (savesState) {
Bundle savedState = new Bundle();
router.saveInstanceState(savedState);
savedPages.put(position, savedState);
}
visiblePageIds.remove(position);
host.removeChildRouter(router);
}
use of com.bluelinelabs.conductor.Controller in project Conductor by bluelinelabs.
the class TargetTitleEntryController method optionPicked.
@OnClick(R.id.btn_use_title)
void optionPicked() {
Controller targetController = getTargetController();
if (targetController != null) {
((TargetTitleEntryControllerListener) targetController).onTitlePicked(editText.getText().toString());
getRouter().popController(this);
}
}
Aggregations