本文整理汇总了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);
}
}
示例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);
}
}
示例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 "";
}