Java源码示例:com.arellomobile.mvp.MvpDelegate
示例1
/**
* @return The {@link MvpDelegate} being used by this Fragment.
*/
public MvpDelegate getMvpDelegate() {
if (mMvpDelegate == null) {
mMvpDelegate = new MvpDelegate<>(this);
}
return mMvpDelegate;
}
示例2
/**
* @return The {@link MvpDelegate} being used by this Fragment.
*/
public MvpDelegate getMvpDelegate() {
if (mMvpDelegate == null) {
mMvpDelegate = new MvpDelegate<>(this);
}
return mMvpDelegate;
}
示例3
/**
* @return The {@link MvpDelegate} being used by this Fragment.
*/
public MvpDelegate getMvpDelegate() {
if (mMvpDelegate == null) {
mMvpDelegate = new MvpDelegate<>(this);
}
return mMvpDelegate;
}
示例4
/**
* @return The {@link MvpDelegate} being used by this Activity.
*/
public MvpDelegate getMvpDelegate() {
if (mMvpDelegate == null) {
mMvpDelegate = new MvpDelegate<>(this);
}
return mMvpDelegate;
}
示例5
public void initWidget(MvpDelegate parentDelegate, Repository repository) {
mParentDelegate = parentDelegate;
mRepository = repository;
getMvpDelegate().onCreate();
getMvpDelegate().onAttach();
}
示例6
public MvpDelegate getMvpDelegate() {
if (mMvpDelegate == null) {
mMvpDelegate = new MvpDelegate<>(this);
mMvpDelegate.setParentDelegate(mParentDelegate, String.valueOf(mRepository.getId()));
}
return mMvpDelegate;
}
示例7
public MvpDelegate getMvpDelegate() {
if (mMvpDelegate == null) {
mMvpDelegate = new MvpDelegate<>(this);
mMvpDelegate.setParentDelegate(mParentDelegate, mChildId);
}
return mMvpDelegate;
}
示例8
public RepositoriesAdapter(MvpDelegate<?> parentDelegate, OnScrollToBottomListener scrollToBottomListener) {
super(parentDelegate, String.valueOf(0));
mScrollToBottomListener = scrollToBottomListener;
mRepositories = new ArrayList<>();
mLiked = new ArrayList<>();
mLikesInProgress = new ArrayList<>();
}
示例9
MvpDelegate getMvpDelegate() {
if (mRepository == null) {
return null;
}
if (mMvpDelegate == null) {
mMvpDelegate = new MvpDelegate<>(this);
mMvpDelegate.setParentDelegate(RepositoriesAdapter.this.getMvpDelegate(), String.valueOf(mRepository.getId()));
}
return mMvpDelegate;
}
示例10
@Test
public void testLocalIsProvided() {
LocalProvidedView view = new LocalProvidedView();
view.delegate = new MvpDelegate<>(view);
view.delegate.onCreate(new Bundle());
Assert.assertNotNull(view.oneLocalPresenter);
Assert.assertSame(view.oneLocalPresenter, view.oneLocalProvidedPresenter);
}
示例11
@Test
public void testTwoLocalUseDifferentProvided() {
TwoLocalProvidedView view = new TwoLocalProvidedView();
view.delegate = new MvpDelegate<>(view);
view.delegate.onCreate(new Bundle());
Assert.assertNotSame(view.oneLocalPresenter, view.secondLocalPresenter);
}
示例12
@Test
public void testWeakPresenterWithHardcodedTag() {
WeakProvidedView view = new WeakProvidedView();
view.delegate = new MvpDelegate<>(view);
view.delegate.onCreate(new Bundle());
Assert.assertNotNull(view.weakPresenter);
Assert.assertSame(view.weakPresenter, view.weakProvidedPresenter);
}
示例13
@Test
public void testTwoWeakPresenterWithSamePresenterIdTest() {
TwoWeakWithSamePresenterIdView view = new TwoWeakWithSamePresenterIdView();
view.delegate = new MvpDelegate<>(view);
view.delegate.onCreate(new Bundle());
Assert.assertNotNull(view.oneWeakPresenter);
Assert.assertNotNull(view.secondWeakPresenter);
Assert.assertSame(view.oneWeakPresenter, view.secondWeakPresenter);
}
示例14
@Test
public void testWithoutInject() {
ViewWithoutInject view = new ViewWithoutInject();
view.delegate = new MvpDelegate<>(view);
view.delegate.onCreate(new Bundle());
}
示例15
@Test
public void test() {
TestViewImplementation viewImplementation = new TestViewImplementation();
viewImplementation.delegate = new MvpDelegate<>(viewImplementation);
viewImplementation.delegate.onCreate(new Bundle());
viewImplementation.delegate.onDestroy();
WeakReference viewImplementationReference = new WeakReference(viewImplementation);
WeakReference presenterReference = new WeakReference(viewImplementation.presenter);
/**
* Remove local reference to this object. Test will been failed if reference to the implemented view or
* to presenter was being saved in Moxy
*/
//noinspection UnusedAssignment
viewImplementation = null;
long delay = 0;
while (delay < TimeUnit.SECONDS.toMillis(2)) {
System.gc();
if (viewImplementationReference.get() == null && presenterReference.get() == null) {
return;
}
try {
TimeUnit.MILLISECONDS.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
delay += 100;
}
assertTrue(false);
}
示例16
public MvpDelegate getMvpDelegate() {
if (mMvpDelegate == null) {
mMvpDelegate = new MvpDelegate<>(this);
mMvpDelegate.setParentDelegate(mParentDelegate, mChildId);
}
return mMvpDelegate;
}
示例17
public RepositoriesAdapter(MvpDelegate<?> parentDelegate, OnScrollToBottomListener scrollToBottomListener) {
super(parentDelegate, String.valueOf(0));
mScrollToBottomListener = scrollToBottomListener;
mRepositories = new ArrayList<>();
mLiked = new ArrayList<>();
mLikesInProgress = new ArrayList<>();
}
示例18
public MvpBaseAdapter(MvpDelegate<?> parentDelegate, String childId) {
mParentDelegate = parentDelegate;
mChildId = childId;
getMvpDelegate().onCreate();
}
示例19
public MvpBaseAdapter(MvpDelegate<?> parentDelegate, String childId) {
mParentDelegate = parentDelegate;
mChildId = childId;
getMvpDelegate().onCreate();
}
示例20
@Test
public void testInjectInInherited() {
SuperViewWithInject view = new SuperViewWithInject();
view.delegate = new MvpDelegate<>(view);
view.delegate.onCreate(new Bundle());
Assert.assertNotNull(view.presenter);
}
示例21
@Test
public void testInjectOnlyInSuper() {
ChildViewWithoutInject view = new ChildViewWithoutInject();
view.delegate = new MvpDelegate<>(view);
view.delegate.onCreate();
Assert.assertNotNull(view.presenter);
}