本文整理汇总了Java中net.grandcentrix.thirtyinch.TiPresenter类的典型用法代码示例。如果您正苦于以下问题:Java TiPresenter类的具体用法?Java TiPresenter怎么用?Java TiPresenter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TiPresenter类属于net.grandcentrix.thirtyinch包,在下文中一共展示了TiPresenter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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);
}
示例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();
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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"));
}
}
示例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");
}
}
示例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);
}
示例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");
}
}
示例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);
}
示例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);
}
示例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");
}
}