• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java TiView类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中net.grandcentrix.thirtyinch.TiView的典型用法代码示例。如果您正苦于以下问题:Java TiView类的具体用法?Java TiView怎么用?Java TiView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

TiView类属于net.grandcentrix.thirtyinch包,在下文中一共展示了TiView类的22个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: provideView

点赞 3

import net.grandcentrix.thirtyinch.TiView; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@NonNull
@Override
public V provideView() {
    final Class<?> foundViewInterface = AnnotationUtil
            .getInterfaceOfClassExtendingGivenInterface(getActivity().getClass(), TiView.class);

    if (foundViewInterface == null) {
        throw new IllegalArgumentException(
                "This Activity doesn't implement a TiView interface. "
                        + "This is the default behaviour. Override provideView() to explicitly change this.");
    } else {
        if (foundViewInterface.getSimpleName().equals("TiView")) {
            throw new IllegalArgumentException(
                    "extending TiView doesn't make sense, it's an empty interface."
                            + " This is the default behaviour. Override provideView() to explicitly change this.");
        } else {
            // assume that the activity itself is the view and implements the TiView interface
            return (V) getActivity();
        }
    }
}
 

开发者ID:weiwenqiang,
项目名称:GitHub,
代码行数:23,
代码来源:TiActivityPlugin.java

示例2: provideView

点赞 3

import net.grandcentrix.thirtyinch.TiView; //导入依赖的package包/类
/**
 * the default implementation assumes that the fragment is the view and implements the {@link
 * TiView} interface. Override this method for a different behaviour.
 *
 * @return the object implementing the TiView interface
 */
@NonNull
public V provideView() {

    final Class<?> foundViewInterface = AnnotationUtil
            .getInterfaceOfClassExtendingGivenInterface(getFragment().getClass(), TiView.class);

    if (foundViewInterface == null) {
        throw new IllegalArgumentException(
                "This Fragment doesn't implement a TiView interface. "
                        + "This is the default behaviour. Override provideView() to explicitly change this.");
    } else {
        if (foundViewInterface.getSimpleName().equals("TiView")) {
            throw new IllegalArgumentException(
                    "extending TiView doesn't make sense, it's an empty interface."
                            + " This is the default behaviour. Override provideView() to explicitly change this.");
        } else {
            // assume that the fragment itself is the view and implements the TiView interface
            //noinspection unchecked
            return (V) getFragment();
        }
    }
}
 

开发者ID:weiwenqiang,
项目名称:GitHub,
代码行数:29,
代码来源:TiFragmentPlugin.java

示例3: wrap

点赞 3

import net.grandcentrix.thirtyinch.TiView; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <V extends TiView> V wrap(final V view) {

    Class<?> foundInterfaceClass = getInterfaceOfClassExtendingGivenInterface(
            view.getClass(), TiView.class);
    if (foundInterfaceClass == null) {
        throw new IllegalStateException("the interface extending View could not be found");
    }

    if (!hasObjectMethodWithAnnotation(view, CallOnMainThread.class)) {
        // not method has the annotation, returning original view
        // not creating a proxy
        return view;
    }

    return (V) Proxy.newProxyInstance(
            foundInterfaceClass.getClassLoader(), new Class<?>[]{foundInterfaceClass},
            new CallOnMainThreadInvocationHandler<>(view));
}
 

开发者ID:weiwenqiang,
项目名称:GitHub,
代码行数:20,
代码来源:CallOnMainThreadInterceptor.java

示例4: wrap

点赞 3

import net.grandcentrix.thirtyinch.TiView; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@NonNull
public <V extends TiView> V wrap(@NonNull final V view) {

    Class<?> foundInterfaceClass =
            getInterfaceOfClassExtendingGivenInterface(view.getClass(), TiView.class);
    if (foundInterfaceClass == null) {
        throw new IllegalStateException("the interface extending View could not be found");
    }

    if (!hasObjectMethodWithAnnotation(view, DistinctUntilChanged.class)) {
        // not method has the annotation, returning original view
        // not creating a proxy
        return view;
    }

    return (V) Proxy.newProxyInstance(
            foundInterfaceClass.getClassLoader(), new Class<?>[]{foundInterfaceClass},
            new DistinctUntilChangedInvocationHandler<>(view));
}
 

开发者ID:weiwenqiang,
项目名称:GitHub,
代码行数:21,
代码来源:DistinctUntilChangedInterceptor.java

示例5: testAttachView_ShouldReplaceUIThreadExecutor

点赞 3

import net.grandcentrix.thirtyinch.TiView; //导入依赖的package包/类
@Test
public void testAttachView_ShouldReplaceUIThreadExecutor() throws Exception {

    // Given the presenter is currently in the state VIEW_DETACHED.
    when(mMockPresenter.getState()).thenReturn(State.VIEW_DETACHED);

    final TiTestPresenter<TiView> tiTestPresenter = new TiTestPresenter<>(mMockPresenter);

    // When a new View is attached to the TiTestPresenter.
    tiTestPresenter.attachView(mMockView);

    // Then the TiTestPresenter should set any ui thread executor on the Presenter.
    verify(mMockPresenter).setUiThreadExecutor(any(Executor.class));

    // And then the TiTestPresenter should attach the new View to the Presenter.
    verify(mMockPresenter).attachView(mMockView);
}
 

开发者ID:grandcentrix,
项目名称:ThirtyInch,
代码行数:18,
代码来源:TiTestPresenterTest.java

示例6: unwrap

点赞 2

import net.grandcentrix.thirtyinch.TiView; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Nullable
public static DistinctUntilChangedInvocationHandler<TiView> unwrap(@NonNull final TiView view) {
    try {
        return (DistinctUntilChangedInvocationHandler) Proxy.getInvocationHandler(view);
    } catch (ClassCastException e) {
        return null;
    }
}
 

开发者ID:weiwenqiang,
项目名称:GitHub,
代码行数:10,
代码来源:DistinctUntilChangedInterceptor.java

示例7: clearCache

点赞 2

import net.grandcentrix.thirtyinch.TiView; //导入依赖的package包/类
public <V extends TiView> void clearCache(final InterceptableViewBinder<V> interceptable) {
    final TiView wrappedView = interceptable.getInterceptedViewOf(this);
    if (wrappedView != null) {
        final DistinctUntilChangedInvocationHandler<TiView> view
                = DistinctUntilChangedInterceptor.unwrap(wrappedView);
        if (view != null) {
            view.clearCache();
            TiLog.v(TAG, "cleared the distinctUntilChanged cache of " + view);
        }
    }
}
 

开发者ID:weiwenqiang,
项目名称:GitHub,
代码行数:12,
代码来源:DistinctUntilChangedInterceptor.java

示例8: build

点赞 2

import net.grandcentrix.thirtyinch.TiView; //导入依赖的package包/类
public TestTiFragment build() {
    TiPresenterProvider<TiPresenter<TiView>> presenterProvider = mPresenterProvider;
    if (presenterProvider == null) {
        presenterProvider = new TiPresenterProvider<TiPresenter<TiView>>() {
            @NonNull
            @Override
            public TiPresenter<TiView> providePresenter() {
                return mPresenter;
            }
        };
    }

    return new TestTiFragment(presenterProvider, mSavior, mHostingActivity);
}
 

开发者ID:weiwenqiang,
项目名称:GitHub,
代码行数:15,
代码来源:TestTiFragment.java

示例9: TestTiFragment

点赞 2

import net.grandcentrix.thirtyinch.TiView; //导入依赖的package包/类
private TestTiFragment(final TiPresenterProvider<TiPresenter<TiView>> presenterProvider,
        final TiPresenterSavior savior,
        final HostingActivity hostingActivity) {

    mDelegate = new TiFragmentDelegate<>(this, this, presenterProvider,
            new TiLoggingTagProvider() {
                @Override
                public String getLoggingTag() {
                    return "Test";
                }
            }, savior);

    mHostingActivity = hostingActivity;
}
 

开发者ID:weiwenqiang,
项目名称:GitHub,
代码行数:15,
代码来源:TestTiFragment.java

示例10: build

点赞 2

import net.grandcentrix.thirtyinch.TiView; //导入依赖的package包/类
public TestTiActivity build() {
    TiPresenterProvider<TiPresenter<TiView>> presenterProvider = mPresenterProvider;
    if (presenterProvider == null) {
        presenterProvider = new TiPresenterProvider<TiPresenter<TiView>>() {
            @NonNull
            @Override
            public TiPresenter<TiView> providePresenter() {
                return mPresenter;
            }
        };
    }
    return new TestTiActivity(presenterProvider, mSavior);
}
 

开发者ID:weiwenqiang,
项目名称:GitHub,
代码行数:14,
代码来源:TestTiActivity.java

示例11: TestTiActivity

点赞 2

import net.grandcentrix.thirtyinch.TiView; //导入依赖的package包/类
private TestTiActivity(final TiPresenterProvider<TiPresenter<TiView>> presenterProvider,
        final TiPresenterSavior savior) {
    mDelegate = new TiActivityDelegate<>(this, this, presenterProvider,
            new TiLoggingTagProvider() {
                @Override
                public String getLoggingTag() {
                    return "Test";
                }
            }, savior);
}
 

开发者ID:weiwenqiang,
项目名称:GitHub,
代码行数:11,
代码来源:TestTiActivity.java

示例12: setUp

点赞 2

import net.grandcentrix.thirtyinch.TiView; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    mPresenter = new TiPresenter<TiView>() {
    };
    mDisposableHandler = new RxTiPresenterDisposableHandler(mPresenter);
    mView = mock(TiView.class);
}
 

开发者ID:weiwenqiang,
项目名称:GitHub,
代码行数:8,
代码来源:RxTiPresenterDisposableHandlerTest.java

示例13: intercept

点赞 2

import net.grandcentrix.thirtyinch.TiView; //导入依赖的package包/类
@Override
public <V extends TiView> V intercept(final V view) {
    if (mLogger != TiLog.NOOP) {
        final V wrapped = wrap(view);
        TiLog.v(TAG, "wrapping View " + view + " in " + wrapped);
        return wrapped;
    }
    return view;
}
 

开发者ID:weiwenqiang,
项目名称:GitHub,
代码行数:10,
代码来源:LoggingInterceptor.java

示例14: wrap

点赞 2

import net.grandcentrix.thirtyinch.TiView; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <V extends TiView> V wrap(final V view) {

    Class<?> foundInterfaceClass = getInterfaceOfClassExtendingGivenInterface(
            view.getClass(), TiView.class);
    if (foundInterfaceClass == null) {
        throw new IllegalStateException("the interface extending TiView could not be found");
    }

    final V wrappedView = (V) Proxy.newProxyInstance(
            foundInterfaceClass.getClassLoader(), new Class<?>[]{foundInterfaceClass},
            new MethodLoggingInvocationHandler<>(view, mLogger));

    return wrappedView;
}
 

开发者ID:weiwenqiang,
项目名称:GitHub,
代码行数:16,
代码来源:LoggingInterceptor.java

示例15: testFindTiViewInterfaceInComplexStructure

点赞 2

import net.grandcentrix.thirtyinch.TiView; //导入依赖的package包/类
@Test
public void testFindTiViewInterfaceInComplexStructure() throws Exception {
    final LoggingInterceptor interceptor = new LoggingInterceptor();
    final TiView interceptView = interceptor.intercept(new MyActivity());
    assertThat(interceptView)
            .isInstanceOf(TiView.class)
            .isInstanceOf(MyView.class)
            .isNotInstanceOf(MyActivity.class)
            .isNotInstanceOf(BaseActivity.class);
}
 

开发者ID:weiwenqiang,
项目名称:GitHub,
代码行数:11,
代码来源:LoggingInterceptorTest.java

示例16: testLoggerNoop_dontWrap

点赞 2

import net.grandcentrix.thirtyinch.TiView; //导入依赖的package包/类
@Test
public void testLoggerNoop_dontWrap() throws Exception {
    final LoggingInterceptor interceptor = new LoggingInterceptor(TiLog.NOOP);
    final TiView view = mock(TiView.class);
    final TiView interceptView = interceptor.intercept(view);
    assertThat(interceptView).isEqualTo(view);
}
 

开发者ID:weiwenqiang,
项目名称:GitHub,
代码行数:8,
代码来源:LoggingInterceptorTest.java

示例17: testLoggerNull_dontWrap

点赞 2

import net.grandcentrix.thirtyinch.TiView; //导入依赖的package包/类
@Test
public void testLoggerNull_dontWrap() throws Exception {
    final LoggingInterceptor interceptor = new LoggingInterceptor(null);
    final TiView view = mock(TiView.class);
    final TiView interceptView = interceptor.intercept(view);
    assertThat(interceptView).isEqualTo(view);
}
 

开发者ID:weiwenqiang,
项目名称:GitHub,
代码行数:8,
代码来源:LoggingInterceptorTest.java

示例18: testLoggingDisabled_wrap

点赞 2

import net.grandcentrix.thirtyinch.TiView; //导入依赖的package包/类
@Test
public void testLoggingDisabled_wrap() throws Exception {
    final LoggingInterceptor interceptor = new LoggingInterceptor();
    final TiView view = mock(TiView.class);
    final TiView interceptView = interceptor.intercept(view);
    assertThat(interceptView).isNotEqualTo(view).isNotSameAs(view);
}
 

开发者ID:weiwenqiang,
项目名称:GitHub,
代码行数:8,
代码来源:LoggingInterceptorTest.java

示例19: testAttachView_WithAttachedView_ShouldDetachPreviousView

点赞 2

import net.grandcentrix.thirtyinch.TiView; //导入依赖的package包/类
@Test
public void testAttachView_WithAttachedView_ShouldDetachPreviousView() {

    // Given the presenter is currently in the state VIEW_ATTACHED.
    when(mMockPresenter.getState()).thenReturn(State.VIEW_ATTACHED);

    final TiTestPresenter<TiView> tiTestPresenter = new TiTestPresenter<>(mMockPresenter);

    // When a new View is attached to the TiTestPresenter.
    tiTestPresenter.attachView(mMockTiView);

    // Then the TiTestPresenter should call detachView() on the Presenter.
    verify(mMockPresenter).detachView();
}
 

开发者ID:grandcentrix,
项目名称:ThirtyInch,
代码行数:15,
代码来源:TiTestPresenterTest.java

示例20: intercept

点赞 2

import net.grandcentrix.thirtyinch.TiView; //导入依赖的package包/类
@Override
public <V extends TiView> V intercept(final V view) {
    final V wrapped = wrap(view);
    TiLog.v(TAG, "wrapping View " + view + " in " + wrapped);
    return wrapped;
}
 

开发者ID:weiwenqiang,
项目名称:GitHub,
代码行数:7,
代码来源:CallOnMainThreadInterceptor.java

示例21: reuseSameFragmentCreateANewPresenterInstance

点赞 2

import net.grandcentrix.thirtyinch.TiView; //导入依赖的package包/类
@Test
public void reuseSameFragmentCreateANewPresenterInstance() throws Exception {

    final AtomicInteger providePresenterCalls = new AtomicInteger(0);

    // Given a fragment which always return a new presenter instance in providePresenter()
    final TestTiFragment fragment = new TestTiFragment.Builder()
            .setPresenterProvider(new TiPresenterProvider<TiPresenter<TiView>>() {
                @NonNull
                @Override
                public TiPresenter<TiView> providePresenter() {
                    providePresenterCalls.incrementAndGet();
                    return new TestPresenter(TiConfiguration.DEFAULT);
                }
            })
            .setSavior(mSavior)
            .build();

    // When the Fragment is added to the Activity.
    fragment.onCreate(null);
    fragment.setAdded(true);
    fragment.onCreateView(mock(LayoutInflater.class), null, null);
    fragment.onStart();

    final TiPresenter<TiView> presenter1 = fragment.getPresenter();
    // Then the presenter is saved in the savior
    assertThat(fragment.getPresenter().isDestroyed()).isFalse();
    assertThat(mSavior.getPresenterCount()).isEqualTo(1);

    // And when the Fragment is removed from the Activity
    fragment.setAdded(false);
    fragment.setRemoving(true);
    fragment.onStop();
    fragment.onDestroyView();
    fragment.onDestroy();

    // Then providePresenter was called once
    assertThat(providePresenterCalls.intValue()).isEqualTo(1);

    // Then assert that the Presenter is destroyed and not saved in the savior
    assertThat(fragment.getPresenter().isDestroyed()).isTrue();
    assertThat(mSavior.getPresenterCount()).isEqualTo(0);

    // When the Fragment is added again to the Activity, again
    fragment.onCreate(null);
    fragment.setAdded(true);
    fragment.onCreateView(mock(LayoutInflater.class), null, null);
    fragment.onStart();

    // Then providePresenter was called again
    assertThat(providePresenterCalls.intValue()).isEqualTo(2);

    // Then the presenter is different
    final TiPresenter<TiView> presenter2 = fragment.getPresenter();
    assertThat(presenter2).isNotSameAs(presenter1);

}
 

开发者ID:weiwenqiang,
项目名称:GitHub,
代码行数:58,
代码来源:TiFragmentDelegateTest.java

示例22: setPresenter

点赞 2

import net.grandcentrix.thirtyinch.TiView; //导入依赖的package包/类
public Builder setPresenter(TiPresenter<TiView> presenter) {
    mPresenter = presenter;
    return this;
}
 

开发者ID:weiwenqiang,
项目名称:GitHub,
代码行数:5,
代码来源:TestTiFragment.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)