use of com.mugen.MugenCallbacks in project TeamCityApp by vase4kin.
the class TestsPresenterImpl method initViews.
/**
* {@inheritDoc}
*/
@Override
protected void initViews() {
super.initViews();
mView.setListener(this);
mView.setOnLoadMoreListener(new MugenCallbacks() {
@Override
public void onLoadMore() {
mIsLoadMoreLoading = true;
mView.addLoadMore();
mDataManager.loadMore(new OnLoadingListener<List<TestOccurrences.TestOccurrence>>() {
@Override
public void onSuccess(List<TestOccurrences.TestOccurrence> data) {
mView.removeLoadMore();
mView.addMoreBuilds(new TestsDataModelImpl(data));
mIsLoadMoreLoading = false;
}
@Override
public void onFail(String errorMessage) {
mView.removeLoadMore();
mView.showRetryLoadMoreSnackBar();
mIsLoadMoreLoading = false;
}
});
}
@Override
public boolean isLoading() {
return mIsLoadMoreLoading;
}
@Override
public boolean hasLoadedAllItems() {
return !mDataManager.canLoadMore();
}
});
mView.replaceSkeletonViewContent();
}
use of com.mugen.MugenCallbacks in project TeamCityApp by vase4kin.
the class ChangesPresenterImpl method initViews.
/**
* {@inheritDoc}
*/
@Override
protected void initViews() {
super.initViews();
mView.setLoadMoreListener(new MugenCallbacks() {
@Override
public void onLoadMore() {
mIsLoadMoreLoading = true;
mView.addLoadMore();
mDataManager.loadMore(new OnLoadingListener<List<Changes.Change>>() {
@Override
public void onSuccess(List<Changes.Change> data) {
mView.removeLoadMore();
mView.addMoreBuilds(new ChangesDataModelImpl(data));
mIsLoadMoreLoading = false;
}
@Override
public void onFail(String errorMessage) {
mView.removeLoadMore();
mView.showRetryLoadMoreSnackBar();
mIsLoadMoreLoading = false;
}
});
}
@Override
public boolean isLoading() {
return mIsLoadMoreLoading;
}
@Override
public boolean hasLoadedAllItems() {
return !mDataManager.canLoadMore();
}
});
mView.replaceSkeletonViewContent();
}
use of com.mugen.MugenCallbacks in project TeamCityApp by vase4kin.
the class ChangesPresenterImplTest method testInitViews.
@Test
public void testInitViews() throws Exception {
when(mDataManager.canLoadMore()).thenReturn(false);
mPresenter.initViews();
verify(mView).setLoadMoreListener(mOnLoadMoreListenerArgumentCaptor.capture());
MugenCallbacks onLoadMoreListener = mOnLoadMoreListenerArgumentCaptor.getValue();
assertThat(onLoadMoreListener.hasLoadedAllItems(), is(true));
verify(mDataManager).canLoadMore();
onLoadMoreListener.onLoadMore();
verify(mView).addLoadMore();
verify(mDataManager).loadMore(mOnChangesLoadingListener.capture());
assertThat(mPresenter.mIsLoadMoreLoading, is(true));
OnLoadingListener<List<Changes.Change>> onChangesLoadingListener = mOnChangesLoadingListener.getValue();
List<Changes.Change> changes = Collections.emptyList();
onChangesLoadingListener.onSuccess(changes);
verify(mView).removeLoadMore();
verify(mView).addMoreBuilds(any(ChangesDataModelImpl.class));
assertThat(mPresenter.mIsLoadMoreLoading, is(false));
onChangesLoadingListener.onFail("error");
verify(mView, times(2)).removeLoadMore();
verify(mView).showRetryLoadMoreSnackBar();
assertThat(mPresenter.mIsLoadMoreLoading, is(false));
}
use of com.mugen.MugenCallbacks in project TeamCityApp by vase4kin.
the class TestsPresenterImplTest method testInitViews.
@Test
public void testInitViews() throws Exception {
when(mDataManager.canLoadMore()).thenReturn(false);
mPresenter.initViews();
verify(mView).setOnLoadMoreListener(mOnLoadMoreListenerArgumentCaptor.capture());
MugenCallbacks onLoadMoreListener = mOnLoadMoreListenerArgumentCaptor.getValue();
assertThat(onLoadMoreListener.hasLoadedAllItems(), is(true));
verify(mDataManager).canLoadMore();
onLoadMoreListener.onLoadMore();
verify(mView).addLoadMore();
verify(mDataManager).loadMore(mOnLoadingListenerArgumentCaptor.capture());
assertThat(mPresenter.mIsLoadMoreLoading, is(true));
OnLoadingListener<List<TestOccurrences.TestOccurrence>> listOnLoadingListener = mOnLoadingListenerArgumentCaptor.getValue();
List<TestOccurrences.TestOccurrence> tests = Collections.emptyList();
listOnLoadingListener.onSuccess(tests);
verify(mView).removeLoadMore();
verify(mView).addMoreBuilds(any(TestsDataModelImpl.class));
assertThat(mPresenter.mIsLoadMoreLoading, is(false));
listOnLoadingListener.onFail("error");
verify(mView, times(2)).removeLoadMore();
verify(mView).showRetryLoadMoreSnackBar();
assertThat(mPresenter.mIsLoadMoreLoading, is(false));
}
Aggregations