use of android.support.v7.widget.RecyclerView.LayoutManager in project android by nextcloud.
the class ExtendedListFragment method saveIndexAndTopPosition.
/*
* Save index and top position
*/
protected void saveIndexAndTopPosition(int index) {
mIndexes.add(index);
RecyclerView.LayoutManager layoutManager = mRecyclerView.getLayoutManager();
int firstPosition;
if (layoutManager instanceof GridLayoutManager) {
firstPosition = ((GridLayoutManager) layoutManager).findFirstCompletelyVisibleItemPosition();
} else {
firstPosition = ((LinearLayoutManager) layoutManager).findFirstCompletelyVisibleItemPosition();
}
mFirstPositions.add(firstPosition);
View view = mRecyclerView.getChildAt(0);
int top = (view == null) ? 0 : view.getTop();
mTops.add(top);
// Save the height of a cell
mHeightCell = (view == null || mHeightCell != 0) ? mHeightCell : view.getHeight();
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project android by nextcloud.
the class OCFileListFragment method switchLayoutManager.
public void switchLayoutManager(boolean grid) {
int position = 0;
if (getRecyclerView().getLayoutManager() != null) {
position = ((LinearLayoutManager) getRecyclerView().getLayoutManager()).findFirstCompletelyVisibleItemPosition();
}
RecyclerView.LayoutManager layoutManager;
if (grid) {
layoutManager = new GridLayoutManager(getContext(), getColumnSize());
((GridLayoutManager) layoutManager).setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
if (position == getAdapter().getItemCount() - 1) {
return ((GridLayoutManager) layoutManager).getSpanCount();
} else {
return 1;
}
}
});
} else {
layoutManager = new LinearLayoutManager(getContext());
}
getRecyclerView().setLayoutManager(layoutManager);
getRecyclerView().scrollToPosition(position);
getAdapter().setGridView(grid);
getRecyclerView().setAdapter(getAdapter());
getAdapter().notifyDataSetChanged();
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project JustAndroid by chinaltz.
the class DividerGridItemDecoration method getSpanCount.
private int getSpanCount(RecyclerView parent) {
// 列数
int spanCount = -1;
LayoutManager layoutManager = parent.getLayoutManager();
if (layoutManager instanceof GridLayoutManager) {
spanCount = ((GridLayoutManager) layoutManager).getSpanCount();
} else if (layoutManager instanceof StaggeredGridLayoutManager) {
spanCount = ((StaggeredGridLayoutManager) layoutManager).getSpanCount();
}
return spanCount;
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project JustAndroid by chinaltz.
the class WeChatCircleActivity method initView.
private void initView() {
initUploadDialog();
recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
recyclerView.addItemDecoration(new DivItemDecoration(2, true));
recyclerView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (edittextbody.getVisibility() == View.VISIBLE) {
return true;
}
return false;
}
});
recyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
}
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
Glide.with(mContext).resumeRequests();
} else {
Glide.with(mContext).pauseRequests();
}
}
});
circleAdapter = new CircleAdapter(this);
recyclerView.setAdapter(circleAdapter);
edittextbody = (LinearLayout) findViewById(R.id.editTextBodyLl);
editText = (EditText) findViewById(R.id.circleEt);
sendIv = (ImageView) findViewById(R.id.sendIv);
sendIv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
setViewTreeObserver();
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project BBS-Android by bdpqchen.
the class MyReplyFragment method initFragment.
@Override
protected void initFragment() {
myReplyAdapter = new MyReplyAdapter(getActivity(), data);
layoutManager = new LinearLayoutManager(getActivity());
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
rv.setHasFixedSize(true);
rv.setLayoutManager(layoutManager);
rv.setAdapter(myReplyAdapter);
rv.addItemDecoration(new RecyclerViewItemDecoration(5));
srl.setOnRefreshListener(this);
srl.setColorSchemeColors(getResources().getIntArray(R.array.swipeRefreshColors));
eros = new EndlessRecyclerOnScrollListener(layoutManager) {
@Override
public void onLoadMore() {
mPresenter.getMyReplyList();
}
};
rv.addOnScrollListener(eros);
mPresenter.initMyReplyList();
}
Aggregations