本文整理汇总了Java中net.grandcentrix.thirtyinch.TiPresenter类的典型用法代码示例。如果您正苦于以下问题:Java TiPresenter类的具体用法?Java TiPresenter怎么用?Java TiPresenter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TiPresenter类属于net.grandcentrix.thirtyinch包,在下文中一共展示了TiPresenter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: bindView
import net.grandcentrix.thirtyinch.TiPresenter; //导入依赖的package包/类
/**
* binds the view (this Activity) to the {@code presenter}. Allows interceptors to change,
* delegate or wrap the view before it gets attached to the presenter.
*/
public void bindView(final TiPresenter<V> presenter, final TiViewProvider<V> viewProvider) {
if (mLastView == null) {
invalidateView();
V interceptedView = viewProvider.provideView();
for (final BindViewInterceptor interceptor : mBindViewInterceptors) {
interceptedView = interceptor.intercept(interceptedView);
mInterceptorViewOutput.put(interceptor, interceptedView);
}
mLastView = interceptedView;
TiLog.v(mLogTag.getLoggingTag(), "binding NEW view to Presenter " + mLastView);
presenter.attachView(mLastView);
} else {
TiLog.v(mLogTag.getLoggingTag(), "binding the cached view to Presenter " + mLastView);
presenter.attachView(mLastView);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:PresenterViewBinder.java
示例2: activityAddedWithoutPresenters
import net.grandcentrix.thirtyinch.TiPresenter; //导入依赖的package包/类
@Test
public void activityAddedWithoutPresenters() throws Exception {
final TestPresenterSavior savior = new TestPresenterSavior();
final HostingActivity hostingActivity = new HostingActivity();
// create lifecycle callbacks with different scope
final TiPresenter presenter = new TiPresenter() {
};
final String id = savior.save(presenter, hostingActivity.getMockActivityInstance());
assertThat(id).isNotNull();
assertThat(savior.getPresenterCount()).isEqualTo(1);
assertThat(savior.mScopes).hasSize(1);
// some random Activity was created
final HostingActivity hostingActivity2 = new HostingActivity();
savior.mActivityInstanceObserver.onActivityCreated(
hostingActivity2.getMockActivityInstance(), mSavedState);
// no second scope was created
assertThat(savior.mScopes).hasSize(1);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:PresenterSaviorTest.java
示例3: detectFinishingActivity
import net.grandcentrix.thirtyinch.TiPresenter; //导入依赖的package包/类
@Test
public void detectFinishingActivity() throws Exception {
final TestPresenterSavior savior = new TestPresenterSavior();
final HostingActivity hostingActivity = new HostingActivity();
final TiPresenter presenter = new TiPresenter() {
};
final String id = savior.save(presenter, hostingActivity.getMockActivityInstance());
assertThat(savior.getPresenterCount()).isEqualTo(1);
assertThat(id).isNotEmpty().isNotNull();
hostingActivity.setFinishing(true);
savior.mActivityInstanceObserver
.onActivityDestroyed(hostingActivity.getMockActivityInstance());
assertThat(savior.getPresenterCount()).isEqualTo(0);
assertThat(savior.mScopes).isEmpty();
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:PresenterSaviorTest.java
示例4: freePresenterSaveAgain
import net.grandcentrix.thirtyinch.TiPresenter; //导入依赖的package包/类
@Test
public void freePresenterSaveAgain() throws Exception {
final TestPresenterSavior savior = new TestPresenterSavior();
final HostingActivity hostingActivity = new HostingActivity();
final TiPresenter presenter = new TiPresenter() {
};
final String id = savior.save(presenter, hostingActivity.getMockActivityInstance());
assertThat(savior.getPresenterCount()).isEqualTo(1);
savior.free(id, hostingActivity.getMockActivityInstance());
assertThat(savior.getPresenterCount()).isEqualTo(0);
final String id2 = savior.save(presenter, hostingActivity.getMockActivityInstance());
assertThat(id2).isNotEqualTo(id);
assertThat(savior.getPresenterCount()).isEqualTo(1);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:PresenterSaviorTest.java
示例5: freePresenterTwice
import net.grandcentrix.thirtyinch.TiPresenter; //导入依赖的package包/类
@Test
public void freePresenterTwice() throws Exception {
final TestPresenterSavior savior = new TestPresenterSavior();
final HostingActivity hostingActivity = new HostingActivity();
final TiPresenter presenter = new TiPresenter() {
};
final String id = savior.save(presenter, hostingActivity.getMockActivityInstance());
assertThat(savior.getPresenterCount()).isEqualTo(1);
savior.free(id, hostingActivity.getMockActivityInstance());
assertThat(savior.getPresenterCount()).isEqualTo(0);
assertThat(savior.mScopes).isEmpty();
// free again should do nothing
savior.free(id, hostingActivity.getMockActivityInstance());
assertThat(savior.getPresenterCount()).isEqualTo(0);
assertThat(savior.mScopes).isEmpty();
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:PresenterSaviorTest.java
示例6: ignoreWhenActivityChangesConfiguration
import net.grandcentrix.thirtyinch.TiPresenter; //导入依赖的package包/类
@Test
public void ignoreWhenActivityChangesConfiguration() throws Exception {
final TestPresenterSavior savior = new TestPresenterSavior();
final HostingActivity hostingActivity = new HostingActivity();
final TiPresenter presenter = new TiPresenter() {
};
final String id = savior.save(presenter, hostingActivity.getMockActivityInstance());
assertThat(savior.getPresenterCount()).isEqualTo(1);
assertThat(id).isNotEmpty().isNotNull();
savior.mActivityInstanceObserver
.onActivityDestroyed(hostingActivity.getMockActivityInstance());
assertThat(savior.getPresenterCount()).isEqualTo(1);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:PresenterSaviorTest.java
示例7: ignoreWhenActivityRecreates
import net.grandcentrix.thirtyinch.TiPresenter; //导入依赖的package包/类
@Test
public void ignoreWhenActivityRecreates() throws Exception {
final TestPresenterSavior savior = new TestPresenterSavior();
final HostingActivity hostingActivity = new HostingActivity();
final TiPresenter presenter = new TiPresenter() {
};
final String id = savior.save(presenter, hostingActivity.getMockActivityInstance());
assertThat(savior.getPresenterCount()).isEqualTo(1);
assertThat(id).isNotEmpty().isNotNull();
savior.mActivityInstanceObserver
.onActivityDestroyed(hostingActivity.getMockActivityInstance());
assertThat(savior.getPresenterCount()).isEqualTo(1);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:PresenterSaviorTest.java
示例8: restoreFailWithDifferentActivity
import net.grandcentrix.thirtyinch.TiPresenter; //导入依赖的package包/类
@Test
public void restoreFailWithDifferentActivity() throws Exception {
final TestPresenterSavior savior = new TestPresenterSavior();
final HostingActivity hostingActivity = new HostingActivity();
final TiPresenter presenter = new TiPresenter() {
};
final String id = savior.save(presenter, hostingActivity.getMockActivityInstance());
assertThat(savior.getPresenterCount()).isEqualTo(1);
final HostingActivity hostingActivity2 = new HostingActivity();
final TiPresenter recovered = savior
.recover(id, hostingActivity2.getMockActivityInstance());
assertThat(recovered).isNull();
assertThat(savior.getPresenterCount()).isEqualTo(1);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:PresenterSaviorTest.java
示例9: testManageViewSubscription_InOnDetachView_ShouldThrow
import net.grandcentrix.thirtyinch.TiPresenter; //导入依赖的package包/类
@Test
public void testManageViewSubscription_InOnDetachView_ShouldThrow() throws Exception {
final TiPresenter presenter = new TiPresenter() {
private RxTiPresenterDisposableHandler mSubscriptionHandler =
new RxTiPresenterDisposableHandler(this);
@Override
protected void onDetachView() {
super.onDetachView();
mSubscriptionHandler.manageViewDisposable(Observable.just("test").subscribe());
}
};
presenter.create();
presenter.attachView(mView);
try {
presenter.detachView();
fail("did not throw");
} catch (Throwable e) {
assertThat(e.getMessage(), containsString("no view"));
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:RxTiPresenterDisposableHandlerTest.java
示例10: detachView
import net.grandcentrix.thirtyinch.TiPresenter; //导入依赖的package包/类
/**
* moves the presenter into state {@link net.grandcentrix.thirtyinch.TiPresenter.State#VIEW_DETACHED}
* from every state
*/
public void detachView() {
final TiPresenter.State state = mPresenter.getState();
switch (state) {
case INITIALIZED:
mPresenter.create();
break;
case VIEW_DETACHED:
// already there
break;
case VIEW_ATTACHED:
mPresenter.detachView();
mPresenter.setUiThreadExecutor(null);
break;
case DESTROYED:
throw new IllegalStateException(
"Presenter is already destroyed, further lifecycle changes aren't allowed");
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:TiPresenterInstructor.java
示例11: save
import net.grandcentrix.thirtyinch.TiPresenter; //导入依赖的package包/类
public void save(@NonNull final String id, @NonNull final TiPresenter presenter) {
if (id == null) {
throw new IllegalStateException("id must be non-null");
}
if (presenter == null) {
throw new IllegalStateException("presenter must be non-null");
}
// overriding a presenter is not allowed, use remove before saving a presenter
if (mStore.get(id) != null) {
throw new IllegalStateException("There is already a presenter saved with id "
+ id + " " + presenter);
}
// saving a presenter twice with a different id is not supported
for (final Map.Entry<String, TiPresenter> entry : mStore.entrySet()) {
if (entry.getValue().equals(presenter)) {
throw new IllegalStateException("Presenter is already saved with different id '"
+ entry.getKey() + "' " + presenter);
}
}
TiLog.d(TAG, "save " + id + " " + presenter);
mStore.put(id, presenter);
}
开发者ID:grandcentrix,项目名称:ThirtyInch,代码行数:26,代码来源:PresenterScope.java
示例12: detachView
import net.grandcentrix.thirtyinch.TiPresenter; //导入依赖的package包/类
/**
* moves the presenter into state {@link TiPresenter.State#VIEW_DETACHED}
* from every state
*
* @see TiPresenter#onDetachView()
*/
public void detachView() {
final TiPresenter.State state = mPresenter.getState();
switch (state) {
case INITIALIZED:
mPresenter.create();
break;
case VIEW_DETACHED:
// already there
break;
case VIEW_ATTACHED:
mPresenter.detachView();
mPresenter.setUiThreadExecutor(null);
break;
case DESTROYED:
throw new IllegalStateException(
"Presenter is already destroyed, further lifecycle changes aren't allowed");
}
}
开发者ID:grandcentrix,项目名称:ThirtyInch,代码行数:25,代码来源:TiTestPresenter.java
示例13: addOneMapping
import net.grandcentrix.thirtyinch.TiPresenter; //导入依赖的package包/类
@Test
public void addOneMapping() throws Exception {
final PresenterScope scope = new PresenterScope();
final TiPresenter presenter = new TiPresenter() {
};
scope.save("a", presenter);
assertThat(scope.getAll())
.hasSize(1)
.contains(presenter);
assertThat(scope.size()).isEqualTo(1);
assertThat(scope.getAllMappings()).hasSize(1);
assertThat(scope.getAllMappings().get(0).getKey()).isEqualTo("a");
assertThat(scope.getAllMappings().get(0).getValue()).isEqualTo(presenter);
}
开发者ID:grandcentrix,项目名称:ThirtyInch,代码行数:18,代码来源:PresenterScopeTest.java
示例14: addTwoMappings
import net.grandcentrix.thirtyinch.TiPresenter; //导入依赖的package包/类
@Test
public void addTwoMappings() throws Exception {
final PresenterScope scope = new PresenterScope();
final TiPresenter presenter1 = new TiPresenter() {
};
scope.save("a", presenter1);
// add second presenter with different id
final TiPresenter presenter2 = new TiPresenter() {
};
scope.save("b", presenter2);
assertThat(scope.size()).isEqualTo(2);
assertThat(scope.getAll())
.hasSize(2)
.contains(presenter1, presenter2);
}
开发者ID:grandcentrix,项目名称:ThirtyInch,代码行数:20,代码来源:PresenterScopeTest.java
示例15: overrideMappingThrows
import net.grandcentrix.thirtyinch.TiPresenter; //导入依赖的package包/类
@Test
public void overrideMappingThrows() throws Exception {
final PresenterScope scope = new PresenterScope();
final TiPresenter presenter1 = new TiPresenter() {
};
scope.save("myId", presenter1);
// override with same id throws
final TiPresenter presenter2 = new TiPresenter() {
};
try {
scope.save("myId", presenter2);
fail("did not throw");
} catch (IllegalStateException e) {
assertThat(e).hasMessageContaining("myId");
}
}
开发者ID:grandcentrix,项目名称:ThirtyInch,代码行数:19,代码来源:PresenterScopeTest.java
示例16: removeOneMapping
import net.grandcentrix.thirtyinch.TiPresenter; //导入依赖的package包/类
@Test
public void removeOneMapping() throws Exception {
final PresenterScope scope = new PresenterScope();
final TiPresenter presenter = new TiPresenter() {
};
scope.save("a", presenter);
assertThat(scope.getAll())
.hasSize(1)
.contains(presenter);
final TiPresenter removedPresenter = scope.remove("a");
assertThat(scope.getAll()).isEmpty();
assertThat(removedPresenter).isEqualTo(presenter);
}
开发者ID:grandcentrix,项目名称:ThirtyInch,代码行数:18,代码来源:PresenterScopeTest.java
示例17: saveSamePresenterTwiceThrows
import net.grandcentrix.thirtyinch.TiPresenter; //导入依赖的package包/类
@Test
public void saveSamePresenterTwiceThrows() throws Exception {
final PresenterScope scope = new PresenterScope();
final TiPresenter presenter = new TiPresenter() {
};
scope.save("myId", presenter);
// try to save the same presenter with a different id
try {
scope.save("b", presenter);
fail("did not throw");
} catch (IllegalStateException e) {
assertThat(e).hasMessageContaining("myId");
}
}
开发者ID:grandcentrix,项目名称:ThirtyInch,代码行数:17,代码来源:PresenterScopeTest.java
示例18: setUp
import net.grandcentrix.thirtyinch.TiPresenter; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
mMockTiPresenter = new TiPresenter<MockTiView>() {
@Override
protected void onAttachView(@NonNull MockTiView view) {
super.onAttachView(view);
sendToView(new ViewAction<MockTiView>() {
@Override
public void call(MockTiView tiView) {
tiView.helloWorld();
}
});
}
};
mMockTiPresenter.create();
mMockTiView = mock(MockTiView.class);
}
开发者ID:grandcentrix,项目名称:ThirtyInch,代码行数:19,代码来源:TiTestPresenterTest.java
示例19: RxTiPresenterDisposableHandler
import net.grandcentrix.thirtyinch.TiPresenter; //导入依赖的package包/类
public RxTiPresenterDisposableHandler(final TiPresenter presenter) {
presenter.addLifecycleObserver(new TiLifecycleObserver() {
@Override
public void onChange(final TiPresenter.State state,
final boolean hasLifecycleMethodBeenCalled) {
if (state == TiPresenter.State.VIEW_DETACHED && !hasLifecycleMethodBeenCalled) {
// dispose all UI disposable created in onAttachView(TiView) and added
// via manageViewDisposable(Disposable...)
if (mUiDisposables != null) {
mUiDisposables.dispose();
mUiDisposables = null;
}
}
if (state == TiPresenter.State.VIEW_ATTACHED && !hasLifecycleMethodBeenCalled) {
mUiDisposables = new CompositeDisposable();
}
if (state == TiPresenter.State.DESTROYED && !hasLifecycleMethodBeenCalled) {
mPresenterDisposables.dispose();
mPresenterDisposables = null;
}
}
});
}
开发者ID:grandcentrix,项目名称:ThirtyInch,代码行数:27,代码来源:RxTiPresenterDisposableHandler.java
示例20: testManageViewSubscription_InOnDetachView_ShouldThrow
import net.grandcentrix.thirtyinch.TiPresenter; //导入依赖的package包/类
@Test
public void testManageViewSubscription_InOnDetachView_ShouldThrow() throws Exception {
final TiPresenter presenter = new TiPresenter() {
private RxTiPresenterDisposableHandler mSubscriptionHandler =
new RxTiPresenterDisposableHandler(this);
@Override
protected void onDetachView() {
super.onDetachView();
mSubscriptionHandler.manageViewDisposable(Observable.just("test").subscribe());
}
};
presenter.create();
presenter.attachView(mView);
try {
presenter.detachView();
fail("did not throw");
} catch (Throwable e) {
assertThat(e).hasMessageContaining("no view");
}
}
开发者ID:grandcentrix,项目名称:ThirtyInch,代码行数:24,代码来源:RxTiPresenterDisposableHandlerTest.java
注:本文中的net.grandcentrix.thirtyinch.TiPresenter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论