Search in sources :

Example 1 with NeteaseLoadMoreView

use of com.example.jingbin.cloudreader.view.byview.NeteaseLoadMoreView in project CloudReader by youlookwhat.

the class CategoryArticleFragment method initRefreshView.

private void initRefreshView() {
    mAdapter = new CategoryArticleAdapter(activity);
    bindingView.recyclerView.setLayoutManager(new LinearLayoutManager(activity));
    bindingView.recyclerView.setItemAnimator(null);
    bindingView.recyclerView.addItemDecoration(new SpacesItemDecoration(activity).setHeaderNoShowDivider(isRefresh ? 1 : 0));
    bindingView.recyclerView.setRefreshHeaderView(new NeteaseRefreshHeaderView(activity));
    bindingView.recyclerView.setLoadingMoreView(new NeteaseLoadMoreView(activity));
    bindingView.recyclerView.setAdapter(mAdapter);
    bindingView.recyclerView.setOnLoadMoreListener(new ByRecyclerView.OnLoadMoreListener() {

        @Override
        public void onLoadMore() {
            int page = viewModel.getPage();
            viewModel.setPage(++page);
            getHomeList();
        }
    });
    if (isRefresh) {
        bindingView.recyclerView.setOnRefreshListener(new ByRecyclerView.OnRefreshListener() {

            @Override
            public void onRefresh() {
                viewModel.setPage(0);
                getHomeList();
            }
        });
    }
}
Also used : ByRecyclerView(me.jingbin.library.ByRecyclerView) NeteaseRefreshHeaderView(com.example.jingbin.cloudreader.view.byview.NeteaseRefreshHeaderView) CategoryArticleAdapter(com.example.jingbin.cloudreader.adapter.CategoryArticleAdapter) SpacesItemDecoration(me.jingbin.library.decoration.SpacesItemDecoration) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) NeteaseLoadMoreView(com.example.jingbin.cloudreader.view.byview.NeteaseLoadMoreView)

Example 2 with NeteaseLoadMoreView

use of com.example.jingbin.cloudreader.view.byview.NeteaseLoadMoreView in project CloudReader by youlookwhat.

the class SearchActivity method initRefreshView.

private void initRefreshView() {
    binding.recyclerView.setLayoutManager(new LinearLayoutManager(this));
    binding.recyclerView.setLoadingMoreView(new NeteaseLoadMoreView(this));
    mAdapter = new CategoryArticleAdapter(this);
    binding.recyclerView.setAdapter(mAdapter);
}
Also used : CategoryArticleAdapter(com.example.jingbin.cloudreader.adapter.CategoryArticleAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) NeteaseLoadMoreView(com.example.jingbin.cloudreader.view.byview.NeteaseLoadMoreView)

Example 3 with NeteaseLoadMoreView

use of com.example.jingbin.cloudreader.view.byview.NeteaseLoadMoreView in project CloudReader by youlookwhat.

the class RefreshHelper method initStaggeredGrid.

public static void initStaggeredGrid(ByRecyclerView recyclerView, int spanCount, int spacing) {
    recyclerView.setLayoutManager(new StaggeredGridLayoutManager(spanCount, StaggeredGridLayoutManager.VERTICAL));
    // 如果每个item高度一致设置后效率更高
    recyclerView.setHasFixedSize(true);
    // recyclerView.setItemAnimator(null);
    recyclerView.addItemDecoration(new GridSpaceItemDecoration(spacing));
    recyclerView.setRefreshHeaderView(new NeteaseRefreshHeaderView(recyclerView.getContext()));
    recyclerView.setLoadingMoreView(new NeteaseLoadMoreView(recyclerView.getContext()));
}
Also used : NeteaseRefreshHeaderView(com.example.jingbin.cloudreader.view.byview.NeteaseRefreshHeaderView) StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager) NeteaseLoadMoreView(com.example.jingbin.cloudreader.view.byview.NeteaseLoadMoreView) GridSpaceItemDecoration(me.jingbin.library.decoration.GridSpaceItemDecoration)

Example 4 with NeteaseLoadMoreView

use of com.example.jingbin.cloudreader.view.byview.NeteaseLoadMoreView in project CloudReader by youlookwhat.

the class RefreshHelper method initLinear.

public static ByRecyclerView initLinear(ByRecyclerView recyclerView, boolean isDivider, int headerNoShowSize) {
    recyclerView.setLayoutManager(new LinearLayoutManager(recyclerView.getContext()));
    // recyclerView.setItemAnimator(null);
    if (isDivider) {
        recyclerView.addItemDecoration(new SpacesItemDecoration(recyclerView.getContext(), SpacesItemDecoration.VERTICAL, headerNoShowSize).setDrawable(R.drawable.shape_line));
    }
    recyclerView.setRefreshHeaderView(new NeteaseRefreshHeaderView(recyclerView.getContext()));
    recyclerView.setLoadingMoreView(new NeteaseLoadMoreView(recyclerView.getContext()));
    return recyclerView;
}
Also used : NeteaseRefreshHeaderView(com.example.jingbin.cloudreader.view.byview.NeteaseRefreshHeaderView) SpacesItemDecoration(me.jingbin.library.decoration.SpacesItemDecoration) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) NeteaseLoadMoreView(com.example.jingbin.cloudreader.view.byview.NeteaseLoadMoreView)

Aggregations

NeteaseLoadMoreView (com.example.jingbin.cloudreader.view.byview.NeteaseLoadMoreView)4 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)3 NeteaseRefreshHeaderView (com.example.jingbin.cloudreader.view.byview.NeteaseRefreshHeaderView)3 CategoryArticleAdapter (com.example.jingbin.cloudreader.adapter.CategoryArticleAdapter)2 SpacesItemDecoration (me.jingbin.library.decoration.SpacesItemDecoration)2 StaggeredGridLayoutManager (androidx.recyclerview.widget.StaggeredGridLayoutManager)1 ByRecyclerView (me.jingbin.library.ByRecyclerView)1 GridSpaceItemDecoration (me.jingbin.library.decoration.GridSpaceItemDecoration)1