当前位置: 首页>>代码示例>>Java>>正文


Java MvpPresenter类代码示例

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


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

示例1: checkWithInjectViewState

import com.arellomobile.mvp.MvpPresenter; //导入依赖的package包/类
@Test
public void checkWithInjectViewState() {
	InjectViewStatePresenter injectViewStatePresenter = new InjectViewStatePresenter();
	injectViewStatePresenter.attachView(mTestView);
	try {
		Field mViewState = MvpPresenter.class.getDeclaredField("mViewState");

		mViewState.setAccessible(true);
		assertTrue("ViewState is null for InjectViewStatePresenter", mViewState.get(injectViewStatePresenter) != null);
	} catch (IllegalAccessException | NoSuchFieldException e) {
		assertFalse(e.getLocalizedMessage(), true);
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:LocalPresenterTest.java

示例2: checkWithoutViewState

import com.arellomobile.mvp.MvpPresenter; //导入依赖的package包/类
@Test
public void checkWithoutViewState() {
	NoViewStatePresenter noViewStatePresenter = new NoViewStatePresenter();
	noViewStatePresenter.attachView(mTestView);
	try {
		Field mViewState = MvpPresenter.class.getDeclaredField("mViewState");

		mViewState.setAccessible(true);
		assertTrue("ViewState is not null for NoViewStatePresenter", mViewState.get(noViewStatePresenter) == null);
	} catch (IllegalAccessException | NoSuchFieldException e) {
		assertFalse(e.getLocalizedMessage(), true);
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:LocalPresenterTest.java

示例3: getViewClassFromGeneric

import com.arellomobile.mvp.MvpPresenter; //导入依赖的package包/类
private String getViewClassFromGeneric(TypeElement typeElement, DeclaredType declaredType) {
	TypeMirror superclass = declaredType;
	Map<TypeParameterElement, TypeMirror> mTypedMap = Collections.emptyMap();

	if (!typeElement.getTypeParameters().isEmpty()) {
		mTypedMap = getChildInstanceOfClassFromGeneric(typeElement, MvpView.class);
	}


	Map<String, String> parentTypes = Collections.emptyMap();
	List<? extends TypeMirror> totalTypeArguments = new ArrayList<>(((DeclaredType) superclass).getTypeArguments());
	while (superclass.getKind() != TypeKind.NONE) {
		TypeElement superclassElement = (TypeElement) ((DeclaredType) superclass).asElement();
		List<? extends TypeMirror> typeArguments = ((DeclaredType) superclass).getTypeArguments();
		totalTypeArguments.retainAll(typeArguments);
		final List<? extends TypeParameterElement> typeParameters = superclassElement.getTypeParameters();

		Map<String, String> types = new HashMap<>();
		for (int i = 0; i < typeArguments.size(); i++) {
			types.put(typeParameters.get(i).toString(), fillGenerics(parentTypes, typeArguments.get(i)));
		}

		if (superclassElement.toString().equals(MvpPresenter.class.getCanonicalName())) {
			if (!typeArguments.isEmpty()) {
				TypeMirror typeMirror = typeArguments.get(0);
				if (typeMirror instanceof TypeVariable) {
					Element key = ((TypeVariable) typeMirror).asElement();

					for (Map.Entry<TypeParameterElement, TypeMirror> entry : mTypedMap.entrySet()) {
						if (entry.getKey().toString().equals(key.toString())) {
							return Util.getFullClassName(entry.getValue());
						}
					}
				}
			}

			if (typeArguments.isEmpty() && typeParameters.isEmpty()) {
				return ((DeclaredType) superclass).asElement().getSimpleName().toString();
			}
			// MvpPresenter is typed only on View class
			return fillGenerics(parentTypes, typeArguments);
		}

		parentTypes = types;

		superclass = superclassElement.getSuperclass();
	}

	return "";
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:51,代码来源:PresenterInjectorRules.java


注:本文中的com.arellomobile.mvp.MvpPresenter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。