Search in sources :

Example 1 with CategoryArticleAdapter

use of com.example.jingbin.cloudreader.adapter.CategoryArticleAdapter 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 CategoryArticleAdapter

use of com.example.jingbin.cloudreader.adapter.CategoryArticleAdapter 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 CategoryArticleAdapter

use of com.example.jingbin.cloudreader.adapter.CategoryArticleAdapter in project CloudReader by youlookwhat.

the class SearchActivity method initViewModel.

private void initViewModel() {
    mAdapter = new CategoryArticleAdapter(this);
    if (binding.recyclerView.getItemDecorationCount() > 0) {
        binding.recyclerView.removeItemDecorationAt(0);
    }
    binding.recyclerView.addItemDecoration(new SpacesItemDecoration(this, SpacesItemDecoration.VERTICAL));
    binding.recyclerView.setAdapter(mAdapter);
    binding.recyclerView.setItemAnimator(null);
    binding.recyclerView.setOnLoadMoreListener(new ByRecyclerView.OnLoadMoreListener() {

        @Override
        public void onLoadMore() {
            int page = viewModel.getPage();
            viewModel.setPage(++page);
            loadWanData();
        }
    });
    if (!TextUtils.isEmpty(keyWord)) {
        viewModel.setPage(0);
        loadWanData();
    }
}
Also used : ByRecyclerView(me.jingbin.library.ByRecyclerView) CategoryArticleAdapter(com.example.jingbin.cloudreader.adapter.CategoryArticleAdapter) SpacesItemDecoration(me.jingbin.library.decoration.SpacesItemDecoration)

Aggregations

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