Search in sources :

Example 1 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager 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 LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project CloudReader by youlookwhat.

the class TreeFragment method initRefreshView.

private void initRefreshView() {
    RefreshHelper.setSwipeRefreshView(bindingView.srlWan);
    bindingView.srlWan.setOnRefreshListener(() -> bindingView.srlWan.postDelayed(this::getTree, 150));
    LinearLayoutManager layoutManager = new LinearLayoutManager(activity);
    bindingView.xrvWan.setLayoutManager(layoutManager);
    mTreeAdapter = new TreeAdapter(activity);
    bindingView.xrvWan.setAdapter(mTreeAdapter);
    HeaderItemTreeBinding oneBinding = DataBindingUtil.inflate(getLayoutInflater(), R.layout.header_item_tree, null, false);
    bindingView.xrvWan.addHeaderView(oneBinding.getRoot());
    oneBinding.tvPosition.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!mTreeAdapter.isSelect()) {
                GridLayoutManager layoutManager = new GridLayoutManager(activity, 2);
                bindingView.xrvWan.setLayoutManager(layoutManager);
                oneBinding.tvPosition.setText("选择类别");
                mTreeAdapter.setSelect(true);
                mTreeAdapter.notifyDataSetChanged();
                bindingView.xrvWan.addItemDecoration(new SpacesItemDecoration(activity).setNoShowDivider(1, 0).setDrawable(R.drawable.shape_line));
            } else {
                LinearLayoutManager layoutManager = new LinearLayoutManager(activity);
                bindingView.xrvWan.setLayoutManager(layoutManager);
                oneBinding.tvPosition.setText("发现页内容订制");
                mTreeAdapter.setSelect(false);
                mTreeAdapter.notifyDataSetChanged();
                if (bindingView.xrvWan.getItemDecorationCount() > 0) {
                    bindingView.xrvWan.removeItemDecorationAt(0);
                }
            }
        }
    });
    bindingView.xrvWan.setOnItemClickListener(new OnItemFilterClickListener() {

        @Override
        public void onSingleClick(View v, int position) {
            if (mTreeAdapter.isSelect()) {
                if (mTreeAdapter.getSelectedPosition() == position) {
                    ToastUtil.showToastLong("当前已经是\"" + mTreeAdapter.getData().get(position).getName() + "\"");
                    return;
                }
                LinearLayoutManager layoutManager = new LinearLayoutManager(activity);
                bindingView.xrvWan.setLayoutManager(layoutManager);
                oneBinding.tvPosition.setText("发现页内容订制");
                mTreeAdapter.setSelect(false);
                mTreeAdapter.notifyDataSetChanged();
                if (bindingView.xrvWan.getItemDecorationCount() > 0) {
                    bindingView.xrvWan.removeItemDecorationAt(0);
                }
                layoutManager.scrollToPositionWithOffset(position + bindingView.xrvWan.getCustomTopItemViewCount(), 0);
                RxBus.getDefault().post(RxCodeConstants.FIND_CUSTOM, position);
            }
        }
    });
}
Also used : HeaderItemTreeBinding(com.example.jingbin.cloudreader.databinding.HeaderItemTreeBinding) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) OnItemFilterClickListener(me.jingbin.library.view.OnItemFilterClickListener) TreeAdapter(com.example.jingbin.cloudreader.adapter.TreeAdapter) SpacesItemDecoration(me.jingbin.library.decoration.SpacesItemDecoration) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View)

Example 3 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project CloudReader by youlookwhat.

the class GankHomeFragment method initRecyclerView.

private void initRecyclerView() {
    mAdapter = new GankAndroidAdapter();
    mAdapter.setAllType(true);
    mHeaderBinding = DataBindingUtil.inflate(LayoutInflater.from(getContext()), R.layout.header_item_everyday, null, false);
    bindingView.recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    bindingView.recyclerView.setLoadMoreEnabled(true);
    bindingView.recyclerView.setHasFixedSize(false);
    bindingView.recyclerView.addHeaderView(mHeaderBinding.getRoot());
    // bindingView.recyclerView.setAdapter(mAdapter);
    // 显示日期,去掉第一位的"0"
    String day = getTodayTime().get(2);
    mHeaderBinding.includeEveryday.tvDailyText.setText(day.indexOf("0") == 0 ? day.replace("0", "") : day);
    mHeaderBinding.includeEveryday.ibXiandu.setOnClickListener(listener);
    mHeaderBinding.includeEveryday.ibWanAndroid.setOnClickListener(listener);
    mHeaderBinding.includeEveryday.ibMovieHot.setOnClickListener(listener);
    mHeaderBinding.includeEveryday.flEveryday.setOnClickListener(listener);
    DensityUtil.setWidthHeight(mHeaderBinding.banner, DensityUtil.getDisplayWidth(), 2.2f);
    onObserveViewModel();
    showItemSkeleton();
}
Also used : GankAndroidAdapter(com.example.jingbin.cloudreader.adapter.GankAndroidAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Example 4 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project CloudReader by youlookwhat.

the class OneMovieDetailActivity method setAdapter.

/**
 * 设置导演&演员adapter
 */
private void setAdapter(MovieDetailBean movieDetailBean) {
    bindingContentView.xrvCast.setVisibility(View.VISIBLE);
    LinearLayoutManager mLayoutManager = new LinearLayoutManager(OneMovieDetailActivity.this);
    mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    bindingContentView.xrvCast.setLayoutManager(mLayoutManager);
    // 需加,不然滑动不流畅
    bindingContentView.xrvCast.setNestedScrollingEnabled(false);
    bindingContentView.xrvCast.setHasFixedSize(false);
    MovieDetailAdapter mAdapter = new MovieDetailAdapter();
    mAdapter.addAll(movieDetailBean.getDirectors());
    mAdapter.addAll(movieDetailBean.getCasts());
    bindingContentView.xrvCast.setAdapter(mAdapter);
}
Also used : LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) MovieDetailAdapter(com.example.jingbin.cloudreader.adapter.MovieDetailAdapter)

Example 5 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project CloudReader by youlookwhat.

the class FilmDetailActivity method setImageAdapter.

/**
 * 剧照
 */
private void setImageAdapter(List<String> listBeans) {
    bindingContentView.xrvImages.setVisibility(View.VISIBLE);
    LinearLayoutManager mLayoutManager = new LinearLayoutManager(FilmDetailActivity.this);
    mLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
    bindingContentView.xrvImages.setLayoutManager(mLayoutManager);
    // 需加,不然滑动不流畅
    bindingContentView.xrvImages.setNestedScrollingEnabled(false);
    bindingContentView.xrvImages.setHasFixedSize(false);
    FilmDetailImageAdapter mAdapter = new FilmDetailImageAdapter(this, listBeans);
    mAdapter.addAll(listBeans);
    bindingContentView.xrvImages.setAdapter(mAdapter);
    bindingContentView.xrvImages.setFocusable(false);
    bindingContentView.xrvImages.setFocusableInTouchMode(false);
    initRxBus();
}
Also used : FilmDetailImageAdapter(com.example.jingbin.cloudreader.adapter.FilmDetailImageAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Aggregations

LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)470 RecyclerView (androidx.recyclerview.widget.RecyclerView)281 View (android.view.View)183 TextView (android.widget.TextView)65 ArrayList (java.util.ArrayList)37 Nullable (androidx.annotation.Nullable)33 Bundle (android.os.Bundle)32 Toolbar (androidx.appcompat.widget.Toolbar)32 Intent (android.content.Intent)30 ImageView (android.widget.ImageView)27 List (java.util.List)24 Test (org.junit.Test)24 Context (android.content.Context)23 NonNull (androidx.annotation.NonNull)23 ViewGroup (android.view.ViewGroup)22 AlertDialog (androidx.appcompat.app.AlertDialog)21 ContextualCard (com.android.settings.homepage.contextualcards.ContextualCard)20 LayoutInflater (android.view.LayoutInflater)18 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)16 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)16