Search in sources :

Example 1 with CollectAdapter

use of com.rideread.rideread.common.adapter.CollectAdapter in project ride-read-android by Ride-Read.

the class CollectActivity method initView.

@Override
public void initView() {
    new TitleBuilder(this).setTitleText("ζˆ‘ηš„ζ”Άθ—").IsBack(true).setLeftOnClickListener(v -> finish()).build();
    mCollectList = new ArrayList<>();
    mSwipeRefreshLayout.setOnRefreshListener(() -> {
        mPages = 0;
        loadCollects();
    });
    mRecycleView.setHasFixedSize(true);
    mAdapter = new CollectAdapter(this, mCollectList);
    mRecycleView.setAdapter(mAdapter);
    mLayoutManager = new LinearLayoutManager(this);
    mRecycleView.setLayoutManager(mLayoutManager);
    mRecycleView.setOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            int lastVisibleItem = mLayoutManager.findLastVisibleItemPosition();
            int totalItemCount = mLayoutManager.getItemCount();
            if (lastVisibleItem >= totalItemCount - 1 && dy > 0) {
                if (!isLoadingMore) {
                    loadCollects();
                }
            }
        }
    });
    loadCollects();
}
Also used : CollectAdapter(com.rideread.rideread.common.adapter.CollectAdapter) ListUtils(com.rideread.rideread.common.util.ListUtils) BaseCallback(com.rideread.rideread.function.net.retrofit.BaseCallback) TitleBuilder(com.rideread.rideread.common.util.TitleBuilder) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) R(com.rideread.rideread.R) BaseActivity(com.rideread.rideread.common.base.BaseActivity) NetworkUtils(com.rideread.rideread.common.util.NetworkUtils) ArrayList(java.util.ArrayList) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) CollectInfo(com.rideread.rideread.data.result.CollectInfo) List(java.util.List) ToastUtils(com.rideread.rideread.common.util.ToastUtils) BaseModel(com.rideread.rideread.function.net.retrofit.BaseModel) ApiUtils(com.rideread.rideread.function.net.retrofit.ApiUtils) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) TitleBuilder(com.rideread.rideread.common.util.TitleBuilder) CollectAdapter(com.rideread.rideread.common.adapter.CollectAdapter) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Aggregations

SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 BindView (butterknife.BindView)1 R (com.rideread.rideread.R)1 CollectAdapter (com.rideread.rideread.common.adapter.CollectAdapter)1 BaseActivity (com.rideread.rideread.common.base.BaseActivity)1 ListUtils (com.rideread.rideread.common.util.ListUtils)1 NetworkUtils (com.rideread.rideread.common.util.NetworkUtils)1 TitleBuilder (com.rideread.rideread.common.util.TitleBuilder)1 ToastUtils (com.rideread.rideread.common.util.ToastUtils)1 CollectInfo (com.rideread.rideread.data.result.CollectInfo)1 ApiUtils (com.rideread.rideread.function.net.retrofit.ApiUtils)1 BaseCallback (com.rideread.rideread.function.net.retrofit.BaseCallback)1 BaseModel (com.rideread.rideread.function.net.retrofit.BaseModel)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1