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();
}
});
}
}
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);
}
}
});
}
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();
}
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);
}
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();
}
Aggregations