Search in sources :

Example 1 with OneAdapter

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

the class OneFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    showContentView();
    aCache = ACache.get(getActivity());
    oneAdapter = new OneAdapter(activity);
    mHotMovieBean = (HotMovieBean) aCache.getAsObject(Constants.ONE_HOT_MOVIE);
    isPrepared = true;
    DebugUtil.error("---OneFragment   --onActivityCreated");
}
Also used : OneAdapter(com.example.jingbin.cloudreader.adapter.OneAdapter)

Example 2 with OneAdapter

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

the class OneFragment method initRecyclerView.

private void initRecyclerView() {
    oneBinding = DataBindingUtil.inflate(getLayoutInflater(), R.layout.header_item_one, null, false);
    oneBinding.setView(this);
    bindingView.listOne.setLayoutManager(new LinearLayoutManager(activity));
    bindingView.listOne.setItemAnimator(null);
    bindingView.listOne.addHeaderView(oneBinding.getRoot());
    oneAdapter = new OneAdapter(activity);
    bindingView.listOne.setAdapter(oneAdapter);
    bindingView.listOne.setOnLoadMoreListener(new ByRecyclerView.OnLoadMoreListener() {

        @Override
        public void onLoadMore() {
            if (oneBinding.tlMovie.getSelectedTabPosition() == 1) {
                viewModel.handleNextStart();
                loadComingSoonMovie();
            } else {
                bindingView.listOne.loadMoreEnd();
            }
        }
    });
    oneBinding.tlMovie.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {

        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            int tabPosition = oneBinding.tlMovie.getSelectedTabPosition();
            if (tabPosition == 0) {
                viewModel.setStart(0);
                bindingView.listOne.setRefreshing(false);
                loadHotMovie();
            } else {
                viewModel.setStart(0);
                bindingView.listOne.setRefreshing(false);
                loadComingSoonMovie();
            }
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {
        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {
        }
    });
}
Also used : ByRecyclerView(me.jingbin.library.ByRecyclerView) OneAdapter(com.example.jingbin.cloudreader.adapter.OneAdapter) TabLayout(com.google.android.material.tabs.TabLayout) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Aggregations

OneAdapter (com.example.jingbin.cloudreader.adapter.OneAdapter)2 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 TabLayout (com.google.android.material.tabs.TabLayout)1 ByRecyclerView (me.jingbin.library.ByRecyclerView)1