本文整理汇总了Java中com.hannesdorfmann.mosby3.mvp.MvpPresenter类的典型用法代码示例。如果您正苦于以下问题:Java MvpPresenter类的具体用法?Java MvpPresenter怎么用?Java MvpPresenter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MvpPresenter类属于com.hannesdorfmann.mosby3.mvp包,在下文中一共展示了MvpPresenter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: initComponents
import com.hannesdorfmann.mosby3.mvp.MvpPresenter; //导入依赖的package包/类
@Before public void initComponents() {
view = new MvpView() {
};
viewState = Mockito.mock(ViewState.class);
presenter = Mockito.mock(MvpPresenter.class);
callback = Mockito.spy(PartialMvpViewStateDelegateCallbackImpl.class);
activity = Mockito.mock(Activity.class);
application = Mockito.mock(Application.class);
Mockito.doCallRealMethod().when(callback).setPresenter(presenter);
Mockito.doCallRealMethod().when(callback).getPresenter();
Mockito.doCallRealMethod().when(callback).setViewState(viewState);
Mockito.doCallRealMethod().when(callback).getViewState();
Mockito.when(callback.getMvpView()).thenReturn(view);
Mockito.when(activity.getApplication()).thenReturn(application);
Mockito.when(callback.createPresenter()).thenReturn(presenter);
Mockito.when(callback.createViewState()).thenReturn(viewState);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:ActivityMvpViewStateDelegateImplTestNew.java
示例2: appStartAfterProcessDeathAndViewStateRecreationFromBundle
import com.hannesdorfmann.mosby3.mvp.MvpPresenter; //导入依赖的package包/类
@Test public void appStartAfterProcessDeathAndViewStateRecreationFromBundle() {
ActivityMvpViewStateDelegateImpl<MvpView, MvpPresenter<MvpView>, ViewState<MvpView>> delegate =
new ActivityMvpViewStateDelegateImpl<>(activity, callback, true);
Mockito.doAnswer(new Answer() {
@Override public Object answer(InvocationOnMock invocation) throws Throwable {
viewState = Mockito.spy(new SimpleRestorableViewState());
return viewState;
}
}).when(callback).createViewState();
Bundle bundle = BundleMocker.create();
bundle.putString(ActivityMvpViewStateDelegateImpl.KEY_MOSBY_VIEW_ID, "123456789");
startActivity(delegate, bundle, 1, 1, 1, 1, 1, 1, false, 1, 0, 1);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:ActivityMvpViewStateDelegateImplTestNew.java
示例3: appStartWithViewStateFromMemoryAndBundleButPreferViewStateFromMemory
import com.hannesdorfmann.mosby3.mvp.MvpPresenter; //导入依赖的package包/类
@Test public void appStartWithViewStateFromMemoryAndBundleButPreferViewStateFromMemory() {
ActivityMvpViewStateDelegateImpl<MvpView, MvpPresenter<MvpView>, ViewState<MvpView>> delegate =
new ActivityMvpViewStateDelegateImpl<>(activity, callback, true);
Mockito.doAnswer(new Answer() {
@Override public Object answer(InvocationOnMock invocation) throws Throwable {
viewState = Mockito.spy(new SimpleRestorableViewState());
return viewState;
}
}).when(callback).createViewState();
startActivity(delegate, null, 1, 1, 1, 1, 1, 0, null, 0, 1, 0);
Bundle bundle = BundleMocker.create();
finishActivity(delegate, bundle, true, 1, true, false);
startActivity(delegate, bundle, 1, 2, 2, 1, 2, 1, true, 1, 1, 1);
finishActivity(delegate, bundle, false, 1, false, true);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:ActivityMvpViewStateDelegateImplTestNew.java
示例4: finishActivity
import com.hannesdorfmann.mosby3.mvp.MvpPresenter; //导入依赖的package包/类
private void finishActivity(ActivityMvpDelegateImpl<MvpView, MvpPresenter<MvpView>> delegate,
Bundle bundle, boolean expectKeepPresenter, int detachViewCount,
boolean changingConfigurations, boolean isFinishing) {
Mockito.when(callback.getPresenter()).thenReturn(presenter);
Mockito.when(callback.getViewState()).thenReturn(viewState);
Mockito.when(activity.isChangingConfigurations()).thenReturn(changingConfigurations);
Mockito.when(activity.isFinishing()).thenReturn(isFinishing);
delegate.onPause();
delegate.onSaveInstanceState(bundle);
delegate.onStop();
delegate.onDestroy();
delegate.onRestart();
Mockito.verify(presenter, Mockito.times(detachViewCount)).detachView(expectKeepPresenter);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:ActivityMvpViewStateDelegateImplTestNew.java
示例5: putPresenter
import com.hannesdorfmann.mosby3.mvp.MvpPresenter; //导入依赖的package包/类
/**
* Put the presenter in the internal cache
*
* @param viewId The mosby internal View id of the {@link MvpView} which the presenter is
* associated to.
* @param presenter The Presenter
*/
public void putPresenter(@NonNull String viewId,
@NonNull MvpPresenter<? extends MvpView> presenter) {
if (viewId == null) {
throw new NullPointerException("ViewId is null");
}
if (presenter == null) {
throw new NullPointerException("Presenter is null");
}
PresenterHolder presenterHolder = presenterMap.get(viewId);
if (presenterHolder == null) {
presenterHolder = new PresenterHolder();
presenterHolder.presenter = presenter;
presenterMap.put(viewId, presenterHolder);
} else {
presenterHolder.presenter = presenter;
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:ActivityScopedCache.java
示例6: putGetRemovePresenter
import com.hannesdorfmann.mosby3.mvp.MvpPresenter; //导入依赖的package包/类
@Test
public void putGetRemovePresenter(){
Activity activity = Mockito.mock(Activity.class);
Application application = Mockito.mock(Application.class);
Mockito.when(activity.getApplication()).thenReturn(application);
MvpPresenter<MvpView> presenter = new MvpPresenter<MvpView>() {
@Override public void attachView(MvpView view) {
}
@Override public void detachView(boolean retainInstance) {
}
};
String viewId ="123";
Assert.assertNull(PresenterManager.getPresenter(activity, viewId));
PresenterManager.putPresenter(activity, viewId, presenter);
Assert.assertTrue(presenter == PresenterManager.getPresenter(activity, viewId));
PresenterManager.remove(activity, viewId);
Assert.assertNull(PresenterManager.getPresenter(activity, viewId));
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:PresenterManagerTest.java
示例7: initComponents
import com.hannesdorfmann.mosby3.mvp.MvpPresenter; //导入依赖的package包/类
@Before public void initComponents() {
view = new MvpView() {
};
presenter = Mockito.mock(MvpPresenter.class);
callback = Mockito.mock(PartialMvpDelegateCallbackImpl.class);
activity = Mockito.mock(Activity.class);
application = Mockito.mock(Application.class);
Mockito.doCallRealMethod().when(callback).setPresenter(presenter);
Mockito.doCallRealMethod().when(callback).getPresenter();
Mockito.when(callback.getMvpView()).thenReturn(view);
Mockito.when(activity.getApplication()).thenReturn(application);
Mockito.when(callback.createPresenter()).thenReturn(presenter);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:ActivityMvpDelegateImplTest.java
示例8: initComponents
import com.hannesdorfmann.mosby3.mvp.MvpPresenter; //导入依赖的package包/类
@Before public void initComponents() {
view = new MvpView() {
};
presenter = Mockito.mock(MvpPresenter.class);
callback = Mockito.mock(PartialViewGroupMvpDelegateCallbackImpl.class);
Mockito.doCallRealMethod().when(callback).setPresenter(presenter);
Mockito.doCallRealMethod().when(callback).getPresenter();
activity = Mockito.mock(FragmentActivity.class);
application = Mockito.mock(Application.class);
androidView = Mockito.mock(View.class);
Mockito.when(callback.getMvpView()).thenReturn(view);
Mockito.when(callback.getContext()).thenReturn(activity);
Mockito.when(activity.getApplication()).thenReturn(application);
Mockito.when(androidView.isInEditMode()).thenReturn(false);
delegate = new ViewGroupMvpDelegateImpl<>(androidView, callback, true);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:ViewGroupMvpDelegateImplTest.java
示例9: initComponents
import com.hannesdorfmann.mosby3.mvp.MvpPresenter; //导入依赖的package包/类
@Before public void initComponents() {
view = new MvpView() {
};
presenter = Mockito.mock(MvpPresenter.class);
callback = Mockito.mock(PartialMvpDelegateCallbackImpl.class);
Mockito.doCallRealMethod().when(callback).setPresenter(presenter);
Mockito.doCallRealMethod().when(callback).getPresenter();
fragment = PowerMockito.mock(Fragment.class);
activity = Mockito.mock(FragmentActivity.class);
application = Mockito.mock(Application.class);
Mockito.when(callback.getMvpView()).thenReturn(view);
Mockito.when(fragment.getActivity()).thenReturn(activity);
Mockito.when(activity.getApplication()).thenReturn(application);
delegate = new FragmentMvpDelegateImpl<>(fragment, callback, true, true);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:FragmentMvpDelegateImplTest.java
示例10: nullPointerOnCreateViewState
import com.hannesdorfmann.mosby3.mvp.MvpPresenter; //导入依赖的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);
}
}
开发者ID:sockeqwe,项目名称:mosby-conductor,代码行数:27,代码来源:MvpViewStateConductorLifecycleTest.java
示例11: createAndSetNewViewState
import com.hannesdorfmann.mosby3.mvp.MvpPresenter; //导入依赖的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();
}
开发者ID:sockeqwe,项目名称:mosby-conductor,代码行数:27,代码来源:MvpViewStateConductorLifecycleTest.java
示例12: dontRestoreViewStateBecauseViewStateInMemory
import com.hannesdorfmann.mosby3.mvp.MvpPresenter; //导入依赖的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));
}
开发者ID:sockeqwe,项目名称:mosby-conductor,代码行数:27,代码来源:MvpViewStateConductorLifecycleTest.java
示例13: nullPointerExceptionOnSaveViewState
import com.hannesdorfmann.mosby3.mvp.MvpPresenter; //导入依赖的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);
}
}
开发者ID:sockeqwe,项目名称:mosby-conductor,代码行数:20,代码来源:MvpViewStateConductorLifecycleTest.java
示例14: createAndSetNewPresenterAndAttachView
import com.hannesdorfmann.mosby3.mvp.MvpPresenter; //导入依赖的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);
}
开发者ID:sockeqwe,项目名称:mosby-conductor,代码行数:25,代码来源:MvpConductorLifecycleListenerTest.java
示例15: nullPointerExceptionOnCreatePresenter
import com.hannesdorfmann.mosby3.mvp.MvpPresenter; //导入依赖的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);
}
}
开发者ID:sockeqwe,项目名称:mosby-conductor,代码行数:23,代码来源:MvpConductorLifecycleListenerTest.java
示例16: nullPointerExceptionOnGetMvpView
import com.hannesdorfmann.mosby3.mvp.MvpPresenter; //导入依赖的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);
}
}
开发者ID:sockeqwe,项目名称:mosby-conductor,代码行数:24,代码来源:MvpConductorLifecycleListenerTest.java
示例17: dontCreatePresenterIfOneExists
import com.hannesdorfmann.mosby3.mvp.MvpPresenter; //导入依赖的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);
}
开发者ID:sockeqwe,项目名称:mosby-conductor,代码行数:21,代码来源:MvpConductorLifecycleListenerTest.java
示例18: nullPointerExceptionGetPresenter
import com.hannesdorfmann.mosby3.mvp.MvpPresenter; //导入依赖的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);
}
}
开发者ID:sockeqwe,项目名称:mosby-conductor,代码行数:22,代码来源:MvpConductorLifecycleListenerTest.java
示例19: appStartWithViewStateFromMemoryAndBundleButPreferViewStateFromMemory
import com.hannesdorfmann.mosby3.mvp.MvpPresenter; //导入依赖的package包/类
@Test public void appStartWithViewStateFromMemoryAndBundleButPreferViewStateFromMemory() {
ActivityMvpViewStateDelegateImpl<MvpView, MvpPresenter<MvpView>, ViewState<MvpView>> delegate =
new ActivityMvpViewStateDelegateImpl<>(activity, callback, true);
Mockito.doAnswer(new Answer() {
@Override public Object answer(InvocationOnMock invocation) throws Throwable {
viewState = Mockito.spy(new SimpleRestorableViewState());
return viewState;
}
}).when(callback).createViewState();
startActivity(delegate, null, 1, 1, 1, 1, 1, 0, null, 0, 1, 0);
Bundle bundle = BundleMocker.create();
finishActivity(delegate, bundle, 1, 0,true, false);
startActivity(delegate, bundle, 1, 2, 2, 1, 2, 1, true, 1, 1, 1);
finishActivity(delegate, bundle, 2, 1,false, true);
}
开发者ID:sockeqwe,项目名称:mosby,代码行数:19,代码来源:ActivityMvpViewStateDelegateImplTestNew.java
示例20: finishActivity
import com.hannesdorfmann.mosby3.mvp.MvpPresenter; //导入依赖的package包/类
private void finishActivity(ActivityMvpDelegateImpl<MvpView, MvpPresenter<MvpView>> delegate,
Bundle bundle, int detachViewCount, int destroyViewCount, boolean changingConfigurations,
boolean isFinishing) {
Mockito.when(callback.getPresenter()).thenReturn(presenter);
Mockito.when(callback.getViewState()).thenReturn(viewState);
Mockito.when(activity.isChangingConfigurations()).thenReturn(changingConfigurations);
Mockito.when(activity.isFinishing()).thenReturn(isFinishing);
delegate.onPause();
delegate.onSaveInstanceState(bundle);
delegate.onStop();
delegate.onDestroy();
delegate.onRestart();
Mockito.verify(presenter, Mockito.times(detachViewCount)).detachView();
Mockito.verify(presenter, Mockito.times(destroyViewCount)).destroy();
}
开发者ID:sockeqwe,项目名称:mosby,代码行数:18,代码来源:ActivityMvpViewStateDelegateImplTestNew.java
注:本文中的com.hannesdorfmann.mosby3.mvp.MvpPresenter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论