本文整理汇总了Java中com.bluelinelabs.conductor.Controller类的典型用法代码示例。如果您正苦于以下问题:Java Controller类的具体用法?Java Controller怎么用?Java Controller使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Controller类属于com.bluelinelabs.conductor包,在下文中一共展示了Controller类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onChangeCompleted
import com.bluelinelabs.conductor.Controller; //导入依赖的package包/类
@Override
public void onChangeCompleted(@Nullable Controller to, @Nullable Controller from, boolean isPush, @NonNull ViewGroup container, @NonNull ControllerChangeHandler handler) {
List<RouterTransaction> newState = router.getBackstack();
Log.d("MainActivity",
Arrays.toString(previousState.toArray()) + " :: " + Arrays.toString(newState.toArray()));
for(RouterTransaction previousKey : previousState) {
if(!newState.contains(previousKey)) {
serviceTree.removeNodeAndChildren(serviceTree.getNode(previousKey));
Log.d("MainActivity", "Destroying [" + previousKey + "]");
}
}
for(RouterTransaction newKey : newState) {
if(!serviceTree.hasNodeWithKey(newKey)) {
((BaseController) newKey.controller()).bindServices(serviceTree.createChildNode(serviceTree.getNode(
TAG), newKey));
Log.d("MainActivity", "Bind service to [" + newKey + "]");
}
}
previousState = router.getBackstack();
}
示例2: findHasControllerInjector
import com.bluelinelabs.conductor.Controller; //导入依赖的package包/类
private static HasControllerInjector findHasControllerInjector(Controller controller) {
Controller parentController = controller;
do {
if ((parentController = parentController.getParentController()) == null) {
Activity activity = controller.getActivity();
if (activity instanceof HasControllerInjector) {
return (HasControllerInjector) activity;
}
if (activity.getApplication() instanceof HasControllerInjector) {
return (HasControllerInjector) activity.getApplication();
}
throw new IllegalArgumentException(
String.format("No injector was found for %s", new Object[] { controller.getClass().getCanonicalName() }));
}
} while (!(parentController instanceof HasControllerInjector));
return (HasControllerInjector) parentController;
}
示例3: preAttach
import com.bluelinelabs.conductor.Controller; //导入依赖的package包/类
@Override public void preAttach(@NonNull Controller controller, @NonNull View view) {
MvpViewStateConductorDelegateCallback<V, P, VS> vsCallback =
((MvpViewStateConductorDelegateCallback<V, P, VS>) callback);
if (vsCallback.getViewState() == null) {
// Creating view for the first time, so onRestoreViewState() never has been called
// Create ViewState
VS viewState = vsCallback.createViewState();
if (viewState == null) {
throw new NullPointerException("ViewState from createViewState() is null in " + vsCallback);
}
vsCallback.setViewState(viewState);
vsCallback.onNewViewStateInstance();
}
super.preAttach(controller, view);
}
示例4: nullPointerOnCreateViewState
import com.bluelinelabs.conductor.Controller; //导入依赖的package包/类
@Test public void nullPointerOnCreateViewState() {
MvpPresenter<MvpView> presenter = Mockito.mock(MvpPresenter.class);
Controller controller = PowerMockito.mock(Controller.class);
View view = Mockito.mock(View.class);
MvpView mvpView = Mockito.mock(MvpView.class);
MvpViewStateConductorDelegateCallback<MvpView, MvpPresenter<MvpView>, ViewState<MvpView>>
callback = Mockito.mock(MvpViewStateConductorDelegateCallback.class);
Mockito.when(callback.getPresenter()).thenReturn(presenter);
Mockito.when(callback.getMvpView()).thenReturn(mvpView);
Mockito.when(callback.getViewState()).thenReturn(null);
Mockito.when(callback.createViewState()).thenReturn(null);
MvpViewStateConductorLifecycleListener<MvpView, MvpPresenter<MvpView>, ViewState<MvpView>>
lifecycleListener = new MvpViewStateConductorLifecycleListener<>(callback);
try {
lifecycleListener.preAttach(controller, view);
Assert.fail("NullPointerException expected");
} catch (NullPointerException e) {
Assert.assertEquals(e.getMessage(),
"ViewState from createViewState() is null in " + callback);
}
}
示例5: createAndSetNewViewState
import com.bluelinelabs.conductor.Controller; //导入依赖的package包/类
@Test public void createAndSetNewViewState() {
MvpPresenter<MvpView> presenter = Mockito.mock(MvpPresenter.class);
Controller controller = PowerMockito.mock(Controller.class);
View view = Mockito.mock(View.class);
MvpView mvpView = Mockito.mock(MvpView.class);
ViewState<MvpView> viewState = Mockito.mock(ViewState.class);
MvpViewStateConductorDelegateCallback<MvpView, MvpPresenter<MvpView>, ViewState<MvpView>>
callback = Mockito.mock(MvpViewStateConductorDelegateCallback.class);
Mockito.when(callback.getPresenter()).thenReturn(presenter);
Mockito.when(callback.getMvpView()).thenReturn(mvpView);
Mockito.when(callback.getViewState()).thenReturn(null);
Mockito.when(callback.createViewState()).thenReturn(viewState);
MvpViewStateConductorLifecycleListener<MvpView, MvpPresenter<MvpView>, ViewState<MvpView>>
lifecycleListener = new MvpViewStateConductorLifecycleListener<>(callback);
lifecycleListener.postCreateView(controller, view);
lifecycleListener.preAttach(controller, view);
Mockito.verify(callback, Mockito.times(1)).getViewState();
Mockito.verify(callback, Mockito.times(1)).createViewState();
Mockito.verify(callback, Mockito.times(1)).setViewState(viewState);
Mockito.verify(callback, Mockito.times(1)).onNewViewStateInstance();
}
示例6: dontRestoreViewStateBecauseViewStateInMemory
import com.bluelinelabs.conductor.Controller; //导入依赖的package包/类
@Test public void dontRestoreViewStateBecauseViewStateInMemory() {
MvpPresenter<MvpView> presenter = Mockito.mock(MvpPresenter.class);
Controller controller = PowerMockito.mock(Controller.class);
View view = Mockito.mock(View.class);
MvpView mvpView = Mockito.mock(MvpView.class);
ViewState<MvpView> viewState = Mockito.mock(ViewState.class);
MvpViewStateConductorDelegateCallback<MvpView, MvpPresenter<MvpView>, ViewState<MvpView>>
callback = Mockito.mock(MvpViewStateConductorDelegateCallback.class);
MvpViewStateConductorLifecycleListener<MvpView, MvpPresenter<MvpView>, ViewState<MvpView>>
lifecycleListener = new MvpViewStateConductorLifecycleListener<>(callback);
Mockito.when(callback.getPresenter()).thenReturn(presenter);
Mockito.when(callback.getMvpView()).thenReturn(mvpView);
Mockito.when(callback.getViewState()).thenReturn(viewState);
Bundle bundle = new Bundle();
lifecycleListener.changingConfigurations = true; // Simulate screen orientation change
lifecycleListener.postCreateView(controller, view);
lifecycleListener.onRestoreViewState(controller, bundle);
Mockito.verify(callback, Mockito.never()).createViewState();
Mockito.verify(viewState, Mockito.times(1)).apply(Mockito.eq(mvpView), Mockito.eq(true));
}
示例7: nullPointerExceptionOnSaveViewState
import com.bluelinelabs.conductor.Controller; //导入依赖的package包/类
@Test public void nullPointerExceptionOnSaveViewState() {
Controller controller = PowerMockito.mock(Controller.class);
MvpViewStateConductorDelegateCallback<MvpView, MvpPresenter<MvpView>, ViewState<MvpView>>
callback = Mockito.mock(MvpViewStateConductorDelegateCallback.class);
MvpViewStateConductorLifecycleListener<MvpView, MvpPresenter<MvpView>, ViewState<MvpView>>
lifecycleListener = new MvpViewStateConductorLifecycleListener<>(callback);
Mockito.when(callback.getViewState()).thenReturn(null);
Bundle bundle = new Bundle();
try {
lifecycleListener.onSaveViewState(controller, bundle);
Assert.fail("NullPointerException expected");
} catch (NullPointerException e) {
Assert.assertEquals(e.getMessage(), "ViewState from getViewState() is null in " + callback);
}
}
示例8: postCreateView
import com.bluelinelabs.conductor.Controller; //导入依赖的package包/类
@Override public void postCreateView(@NonNull Controller controller, @NonNull View view) {
MvpConductorDelegateCallback<V, P> callback = getCallback();
P presenter = callback.getPresenter();
if (presenter == null) {
presenter = callback.createPresenter();
if (presenter == null) {
throw new NullPointerException(
"Presenter returned from createPresenter() is null in " + callback);
}
callback.setPresenter(presenter);
}
V mvpView = callback.getMvpView();
if (mvpView == null) {
throw new NullPointerException("MVP View returned from getMvpView() is null in " + callback);
}
presenter.attachView(mvpView);
}
示例9: createAndSetNewPresenterAndAttachView
import com.bluelinelabs.conductor.Controller; //导入依赖的package包/类
@Test public void createAndSetNewPresenterAndAttachView() {
MvpPresenter<MvpView> presenter = Mockito.mock(MvpPresenter.class);
Controller controller = Mockito.mock(Controller.class);
View view = Mockito.mock(View.class);
MvpView mvpView = Mockito.mock(MvpView.class);
MvpConductorDelegateCallback<MvpView, MvpPresenter<MvpView>> callback =
Mockito.mock(MvpConductorDelegateCallback.class);
Mockito.when(callback.getPresenter()).thenReturn(null);
Mockito.when(callback.createPresenter()).thenReturn(presenter);
Mockito.when(callback.getMvpView()).thenReturn(mvpView);
MvpConductorLifecycleListener<MvpView, MvpPresenter<MvpView>> lifecycleListener =
new MvpConductorLifecycleListener<>(callback);
lifecycleListener.postCreateView(controller, view);
Mockito.verify(callback, Mockito.times(1)).getPresenter();
Mockito.verify(callback, Mockito.times(1)).createPresenter();
Mockito.verify(callback, Mockito.times(1)).setPresenter(presenter);
Mockito.verify(presenter, Mockito.times(1)).attachView(mvpView);
}
示例10: nullPointerExceptionOnCreatePresenter
import com.bluelinelabs.conductor.Controller; //导入依赖的package包/类
@Test public void nullPointerExceptionOnCreatePresenter() {
Controller controller = Mockito.mock(Controller.class);
View view = Mockito.mock(View.class);
MvpConductorDelegateCallback<MvpView, MvpPresenter<MvpView>> callback =
Mockito.mock(MvpConductorDelegateCallback.class);
Mockito.when(callback.getPresenter()).thenReturn(null);
Mockito.when(callback.createPresenter()).thenReturn(null);
MvpConductorLifecycleListener<MvpView, MvpPresenter<MvpView>> lifecycleListener =
new MvpConductorLifecycleListener<>(callback);
try {
lifecycleListener.postCreateView(controller, view);
Assert.fail("NullpointerException expected");
} catch (NullPointerException e) {
Assert.assertEquals(e.getMessage(),
"Presenter returned from createPresenter() is null in " + callback);
}
}
示例11: nullPointerExceptionOnGetMvpView
import com.bluelinelabs.conductor.Controller; //导入依赖的package包/类
@Test public void nullPointerExceptionOnGetMvpView() {
MvpPresenter<MvpView> presenter = Mockito.mock(MvpPresenter.class);
Controller controller = Mockito.mock(Controller.class);
View view = Mockito.mock(View.class);
MvpConductorDelegateCallback<MvpView, MvpPresenter<MvpView>> callback =
Mockito.mock(MvpConductorDelegateCallback.class);
Mockito.when(callback.getPresenter()).thenReturn(presenter);
Mockito.when(callback.getMvpView()).thenReturn(null);
MvpConductorLifecycleListener<MvpView, MvpPresenter<MvpView>> lifecycleListener =
new MvpConductorLifecycleListener<>(callback);
try {
lifecycleListener.postCreateView(controller, view);
Assert.fail("NullpointerException expected");
} catch (NullPointerException e) {
Assert.assertEquals(e.getMessage(),
"MVP View returned from getMvpView() is null in " + callback);
}
}
示例12: dontCreatePresenterIfOneExists
import com.bluelinelabs.conductor.Controller; //导入依赖的package包/类
@Test public void dontCreatePresenterIfOneExists() {
MvpPresenter<MvpView> presenter = Mockito.mock(MvpPresenter.class);
Controller controller = Mockito.mock(Controller.class);
View view = Mockito.mock(View.class);
MvpView mvpView = Mockito.mock(MvpView.class);
MvpConductorDelegateCallback<MvpView, MvpPresenter<MvpView>> callback =
Mockito.mock(MvpConductorDelegateCallback.class);
MvpConductorLifecycleListener<MvpView, MvpPresenter<MvpView>> lifecycleListener =
new MvpConductorLifecycleListener<>(callback);
Mockito.when(callback.getPresenter()).thenReturn(presenter);
Mockito.when(callback.getMvpView()).thenReturn(mvpView);
lifecycleListener.postCreateView(controller, view);
Mockito.verify(callback, Mockito.times(1)).getPresenter();
Mockito.verify(callback, Mockito.never()).createPresenter();
Mockito.verify(callback, Mockito.never()).setPresenter(presenter);
}
示例13: nullPointerExceptionGetPresenter
import com.bluelinelabs.conductor.Controller; //导入依赖的package包/类
@Test public void nullPointerExceptionGetPresenter() {
MvpPresenter<MvpView> presenter = Mockito.mock(MvpPresenter.class);
Controller controller = Mockito.mock(Controller.class);
View view = Mockito.mock(View.class);
MvpConductorDelegateCallback<MvpView, MvpPresenter<MvpView>> callback =
Mockito.mock(MvpConductorDelegateCallback.class);
MvpConductorLifecycleListener<MvpView, MvpPresenter<MvpView>> lifecycleListener =
new MvpConductorLifecycleListener<>(callback);
Mockito.when(callback.getPresenter()).thenReturn(null);
try {
lifecycleListener.preDestroyView(controller, view);
Assert.fail();
} catch (NullPointerException e) {
Assert.assertEquals(e.getMessage(),
"Presenter returned from getPresenter() is null in " + callback);
}
}
示例14: attachRoot
import com.bluelinelabs.conductor.Controller; //导入依赖的package包/类
public void attachRoot(Router router)
{
HomeController homeController = new HomeController();
homeController.setRetainViewMode(Controller.RetainViewMode.RETAIN_DETACH);
if (!router.hasRootController())
{
router.setRoot(RouterTransaction.with(homeController)
.tag("HomeController"));
}
}
示例15: inject
import com.bluelinelabs.conductor.Controller; //导入依赖的package包/类
public static void inject(Controller controller) {
Preconditions.checkNotNull(controller, "controller");
HasControllerInjector hasDispatchingControllerInjector = findHasControllerInjector(controller);
Log.d("dagger.android", String.format("An injector for %s was found in %s", controller.getClass().getCanonicalName(),
hasDispatchingControllerInjector.getClass().getCanonicalName()));
DispatchingAndroidInjector<Controller> controllerInjector = hasDispatchingControllerInjector.controllerInjector();
Preconditions.checkNotNull(controllerInjector, "%s.controllerInjector() returned null",
hasDispatchingControllerInjector.getClass().getCanonicalName());
controllerInjector.inject(controller);
}