use of me.jingbin.library.decoration.SpacesItemDecoration 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 me.jingbin.library.decoration.SpacesItemDecoration 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 me.jingbin.library.decoration.SpacesItemDecoration 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();
}
}
use of me.jingbin.library.decoration.SpacesItemDecoration 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;
}
use of me.jingbin.library.decoration.SpacesItemDecoration in project CloudReader by youlookwhat.
the class AndroidFragment method initRecyclerView.
private void initRecyclerView() {
adapter = new GankAndroidAdapter();
// 加了分割线,滚动条才会置顶
SpacesItemDecoration itemDecoration = new SpacesItemDecoration(activity, SpacesItemDecoration.VERTICAL, 1);
itemDecoration.setDrawable(R.drawable.shape_transparent);
RefreshHelper.initLinear(bindingView.xrvAndroid, false).addItemDecoration(itemDecoration);
bindingView.xrvAndroid.setAdapter(adapter);
bindingView.xrvAndroid.setOnRefreshListener(new ByRecyclerView.OnRefreshListener() {
@Override
public void onRefresh() {
viewModel.setPage(1);
loadAndroidData();
}
});
bindingView.xrvAndroid.setOnLoadMoreListener(new ByRecyclerView.OnLoadMoreListener() {
@Override
public void onLoadMore() {
int page = viewModel.getPage();
page++;
viewModel.setPage(page);
loadAndroidData();
}
});
}
Aggregations