use of com.funstill.kelefun.adapter.ImageAdapter in project keleFanfou by kelefun.
the class ImageListFragment method initView.
private void initView(View view) {
SwipeRefreshLayout mRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.line_swipe_refresh);
// 禁用下拉刷新
mRefreshLayout.setEnabled(false);
mRecyclerView = (RecyclerView) view.findViewById(R.id.line_recycler);
StaggeredGridLayoutManager mLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
mRecyclerView.setLayoutManager(mLayoutManager);
mAdapter = new ImageAdapter(getActivity(), data);
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
lastPositions = mLayoutManager.findLastVisibleItemPositions(lastPositions);
super.onScrolled(recyclerView, dx, dy);
}
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (lastPositions == null || lastPositions.length == 0) {
return;
}
lastVisibleItemPosition = getMax(lastPositions);
if (newState == RecyclerView.SCROLL_STATE_IDLE && (lastVisibleItemPosition + 1 >= mLayoutManager.getItemCount()) && !isLoadingMore) {
if (data.size() > 0) {
Map<String, String> loadMoreParam = new ArrayMap<>();
loadMoreParam.put("max_id", data.get(data.size() - 1).getId());
loadMoreParam.put("count", "25");
loadMoreMentions(loadMoreParam);
}
}
}
});
}
use of com.funstill.kelefun.adapter.ImageAdapter in project keleFanfou by kelefun.
the class ImageListFragment method initView.
private void initView(View view) {
mRecyclerView = (RecyclerView) view.findViewById(R.id.line_recycler);
StaggeredGridLayoutManager mLayoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL);
mLayoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS);
mRecyclerView.setLayoutManager(mLayoutManager);
mAdapter = new ImageAdapter(getActivity(), data);
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
lastPositions = mLayoutManager.findLastVisibleItemPositions(lastPositions);
super.onScrolled(recyclerView, dx, dy);
}
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (lastPositions == null || lastPositions.length == 0) {
return;
}
lastVisibleItemPosition = getMax(lastPositions);
if (newState == RecyclerView.SCROLL_STATE_IDLE && (lastVisibleItemPosition + 1 >= mLayoutManager.getItemCount()) && !isLoadingMore) {
if (data.size() > 0) {
Map<String, String> loadMoreParam = new ArrayMap<>();
loadMoreParam.put("max_id", data.get(data.size() - 1).getId());
loadMoreParam.put("count", "15");
loadMoreMentions(loadMoreParam);
}
}
}
});
}
Aggregations