Search in sources :

Example 1 with OnLoadingListener

use of com.github.vase4kin.teamcityapp.account.create.data.OnLoadingListener 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();
}
Also used : TestsDataModelImpl(com.github.vase4kin.teamcityapp.tests.data.TestsDataModelImpl) MugenCallbacks(com.mugen.MugenCallbacks) TestOccurrences(com.github.vase4kin.teamcityapp.tests.api.TestOccurrences) List(java.util.List) OnLoadingListener(com.github.vase4kin.teamcityapp.account.create.data.OnLoadingListener)

Example 2 with OnLoadingListener

use of com.github.vase4kin.teamcityapp.account.create.data.OnLoadingListener 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();
}
Also used : Changes(com.github.vase4kin.teamcityapp.changes.api.Changes) MugenCallbacks(com.mugen.MugenCallbacks) List(java.util.List) OnLoadingListener(com.github.vase4kin.teamcityapp.account.create.data.OnLoadingListener) ChangesDataModelImpl(com.github.vase4kin.teamcityapp.changes.data.ChangesDataModelImpl)

Aggregations

OnLoadingListener (com.github.vase4kin.teamcityapp.account.create.data.OnLoadingListener)2 MugenCallbacks (com.mugen.MugenCallbacks)2 List (java.util.List)2 Changes (com.github.vase4kin.teamcityapp.changes.api.Changes)1 ChangesDataModelImpl (com.github.vase4kin.teamcityapp.changes.data.ChangesDataModelImpl)1 TestOccurrences (com.github.vase4kin.teamcityapp.tests.api.TestOccurrences)1 TestsDataModelImpl (com.github.vase4kin.teamcityapp.tests.data.TestsDataModelImpl)1