use of android.support.v7.widget.StaggeredGridLayoutManager in project MaterialViewPager by florent37.
the class Utils method scrollTo.
public static void scrollTo(Object scroll, float yOffset) {
if (scroll instanceof RecyclerView) {
//RecyclerView.scrollTo : UnsupportedOperationException
//Moved to the RecyclerView.LayoutManager.scrollToPositionWithOffset
//Have to be instanceOf RecyclerView.LayoutManager to work (so work with RecyclerView.GridLayoutManager)
final RecyclerView.LayoutManager layoutManager = ((RecyclerView) scroll).getLayoutManager();
if (layoutManager instanceof LinearLayoutManager) {
LinearLayoutManager linearLayoutManager = (LinearLayoutManager) layoutManager;
linearLayoutManager.scrollToPositionWithOffset(0, (int) -yOffset);
} else if (layoutManager instanceof StaggeredGridLayoutManager) {
StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager) layoutManager;
staggeredGridLayoutManager.scrollToPositionWithOffset(0, (int) -yOffset);
}
} else if (scroll instanceof NestedScrollView) {
((NestedScrollView) scroll).scrollTo(0, (int) yOffset);
}
}
use of android.support.v7.widget.StaggeredGridLayoutManager in project material-sheet-fab by gowong.
the class NotesListFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(getLayoutResId(), container, false);
// Setup list
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.notes_list);
recyclerView.setLayoutManager(new StaggeredGridLayoutManager(getNumColumns(), StaggeredGridLayoutManager.VERTICAL));
recyclerView.setAdapter(new NotesAdapter(getActivity(), getNumItems()));
return view;
}
use of android.support.v7.widget.StaggeredGridLayoutManager in project CloudReader by youlookwhat.
the class BookCustomFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
showContentView();
bindingView.srlBook.setColorSchemeColors(CommonUtils.getColor(R.color.colorTheme));
bindingView.srlBook.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
DebugUtil.error("-----onRefresh");
// listTag= Arrays.asList(BookApiUtils.getApiTag(position));
// String tag=BookApiUtils.getRandomTAG(listTag);
// doubanBookPresenter.searchBookByTag(BookReadingFragment.this,tag,false);
bindingView.srlBook.postDelayed(new Runnable() {
@Override
public void run() {
mStart = 0;
loadCustomData();
}
}, 1000);
}
});
// mBookAdapter = new BookAdapter(getActivity());
// mLayoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL);
mLayoutManager = new GridLayoutManager(getActivity(), 3);
bindingView.xrvBook.setLayoutManager(mLayoutManager);
// bindingView.xrvBook.setAdapter(mBookAdapter);
scrollRecycleView();
// 准备就绪
mIsPrepared = true;
/**
* 因为启动时先走loadData()再走onActivityCreated,
* 所以此处要额外调用load(),不然最初不会加载内容
*/
loadData();
}
use of android.support.v7.widget.StaggeredGridLayoutManager in project CloudReader by youlookwhat.
the class WelfareFragment method setAdapter.
private void setAdapter(GankIoDataBean gankIoDataBean) {
// mWelfareAdapter = new WelfareAdapter();
mWelfareAdapter.addAll(gankIoDataBean.getResults());
//构造器中,第一个参数表示列数或者行数,第二个参数表示滑动方向,瀑布流
bindingView.xrvWelfare.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
bindingView.xrvWelfare.setAdapter(mWelfareAdapter);
mWelfareAdapter.notifyDataSetChanged();
mWelfareAdapter.setOnItemClickListener(new OnItemClickListener<GankIoDataBean.ResultBean>() {
@Override
public void onClick(GankIoDataBean.ResultBean resultsBean, int position) {
DebugUtil.error("-----" + imgList.toString());
DebugUtil.error("----imgList.size(): " + imgList.size());
Bundle bundle = new Bundle();
// 2,大图显示当前页数,1,头像,不显示页数
bundle.putInt("selet", 2);
//第几张
bundle.putInt("code", position);
bundle.putStringArrayList("imageuri", imgList);
Intent intent = new Intent(getContext(), ViewBigImageActivity.class);
intent.putExtras(bundle);
getContext().startActivity(intent);
}
});
// 显示成功后就不是第一次了,不再刷新
isFirst = false;
}
use of android.support.v7.widget.StaggeredGridLayoutManager in project SwipeRecyclerView by yanzhenjie.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, LinearLayoutManager.VERTICAL));
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
outRect.set(10, 10, 10, 15);
}
});
List<String> titles = Arrays.asList(getResources().getStringArray(R.array.main_item));
List<String> descriptions = Arrays.asList(getResources().getStringArray(R.array.main_item_des));
MainItemAdapter mainItemAdapter = new MainItemAdapter(titles, descriptions);
mainItemAdapter.setOnItemClickListener(this);
recyclerView.setAdapter(mainItemAdapter);
}
Aggregations