use of android.support.v7.widget.GridLayoutManager in project PhotoView by chrisbanes.
the class ActivityTransitionActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_transition);
RecyclerView list = (RecyclerView) findViewById(R.id.list);
list.setLayoutManager(new GridLayoutManager(this, 2));
ImageAdapter imageAdapter = new ImageAdapter(new ImageAdapter.Listener() {
@Override
public void onImageClicked(View view) {
transition(view);
}
});
list.setAdapter(imageAdapter);
}
use of android.support.v7.widget.GridLayoutManager in project philm by chrisbanes.
the class MovieDetailFragment method populateUi.
private void populateUi() {
if (mMovie == null) {
return;
}
if (mBackdropImageView != null) {
if (mMovie.hasBackdropUrl()) {
mBackdropImageView.loadBackdrop(mMovie);
}
}
if (mCollapsingToolbarLayout != null) {
mCollapsingToolbarLayout.setTitle(mMovie.getTitle());
}
mAdapter = new GroupAdapter();
mAdapter.add(new TitleItem());
mAdapter.add(new ButtonsItem());
if (!TextUtils.isEmpty(mMovie.getOverview())) {
mAdapter.add(new SummaryItem());
}
mAdapter.add(new RatingItem());
mAdapter.add(new DetailsGroup());
//
// if (!PhilmCollections.isEmpty(mMovie.getTrailers())) {
// mItems.add(DetailItemType.TRAILERS);
// }
//
// if (!PhilmCollections.isEmpty(mMovie.getCast())) {
// mItems.add(DetailItemType.CAST);
// }
//
// if (!PhilmCollections.isEmpty(mMovie.getCrew())) {
// mItems.add(DetailItemType.CREW);
// }
//
// if (!PhilmCollections.isEmpty(mMovie.getRelated())) {
// mItems.add(DetailItemType.RELATED);
// }
GridLayoutManager layoutManager = new GridLayoutManager(getContext(), mAdapter.getSpanCount());
layoutManager.setSpanSizeLookup(mAdapter.getSpanSizeLookup());
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.setAdapter(mAdapter);
}
use of android.support.v7.widget.GridLayoutManager in project AndroidAutoLayout by hongyangAndroid.
the class RecyclerViewGridFragment method initView.
private void initView() {
mContext = getActivity();
mRecyclerView = (RecyclerView) mView.findViewById(R.id.id_recyclerview);
mList = new ArrayList<String>();
for (int i = 0; i < 50; i++) {
mList.add(i + "");
}
mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2, GridLayoutManager.HORIZONTAL, false));
mRecyclerView.setAdapter(new MyAdapter());
}
use of android.support.v7.widget.GridLayoutManager in project baseAdapter by hongyangAndroid.
the class RecyclerViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recyclerview);
initDatas();
mRecyclerView = (RecyclerView) findViewById(R.id.id_recyclerview);
// mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setLayoutManager(new GridLayoutManager(this, 2));
// mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
mAdapter = new CommonAdapter<String>(this, R.layout.item_list, mDatas) {
@Override
protected void convert(ViewHolder holder, String s, int position) {
holder.setText(R.id.id_item_list_title, s + " : " + holder.getAdapterPosition() + " , " + holder.getLayoutPosition());
}
};
initHeaderAndFooter();
// initEmptyView();
mLoadMoreWrapper = new LoadMoreWrapper(mHeaderAndFooterWrapper);
mLoadMoreWrapper.setLoadMoreView(R.layout.default_loading);
mLoadMoreWrapper.setOnLoadMoreListener(new LoadMoreWrapper.OnLoadMoreListener() {
@Override
public void onLoadMoreRequested() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
for (int i = 0; i < 10; i++) {
mDatas.add("Add:" + i);
}
mLoadMoreWrapper.notifyDataSetChanged();
}
}, 3000);
}
});
mRecyclerView.setAdapter(mLoadMoreWrapper);
mAdapter.setOnItemClickListener(new CommonAdapter.OnItemClickListener() {
@Override
public void onItemClick(View view, RecyclerView.ViewHolder holder, int position) {
Toast.makeText(RecyclerViewActivity.this, "pos = " + position, Toast.LENGTH_SHORT).show();
mAdapter.notifyItemRemoved(position);
}
@Override
public boolean onItemLongClick(View view, RecyclerView.ViewHolder holder, int position) {
return false;
}
});
}
use of android.support.v7.widget.GridLayoutManager in project baseAdapter by hongyangAndroid.
the class WrapperUtils method onAttachedToRecyclerView.
public static void onAttachedToRecyclerView(RecyclerView.Adapter innerAdapter, RecyclerView recyclerView, final SpanSizeCallback callback) {
innerAdapter.onAttachedToRecyclerView(recyclerView);
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
if (layoutManager instanceof GridLayoutManager) {
final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
final GridLayoutManager.SpanSizeLookup spanSizeLookup = gridLayoutManager.getSpanSizeLookup();
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
return callback.getSpanSize(gridLayoutManager, spanSizeLookup, position);
}
});
gridLayoutManager.setSpanCount(gridLayoutManager.getSpanCount());
}
}
Aggregations