use of android.support.v7.widget.RecyclerView.LayoutManager in project MultiType by drakeet.
the class BilibiliActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);
adapter = new MultiTypeAdapter();
adapter.applyGlobalMultiTypePool();
adapter.register(Post.class, new PostViewBinder());
adapter.register(PostList.class, new HorizontalPostsViewBinder());
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
final GridLayoutManager layoutManager = new GridLayoutManager(this, SPAN_COUNT);
SpanSizeLookup spanSizeLookup = new SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
Object item = items.get(position);
return (item instanceof PostList || item instanceof Category) ? SPAN_COUNT : 1;
}
};
layoutManager.setSpanSizeLookup(spanSizeLookup);
recyclerView.setLayoutManager(layoutManager);
int space = getResources().getDimensionPixelSize(R.dimen.normal_space);
recyclerView.addItemDecoration(new PostItemDecoration(space, spanSizeLookup));
recyclerView.setAdapter(adapter);
JsonData data = new JsonData();
items = new ArrayList<>();
for (int i = 0; i < 10; i++) {
/* You also could use Category as your CategoryItemContent directly */
items.add(data.category0);
items.add(data.postArray[0]);
items.add(data.postArray[1]);
items.add(data.postArray[2]);
items.add(data.postArray[3]);
items.add(data.postArray[0]);
items.add(data.postArray[1]);
items.add(new PostList(data.postList));
}
adapter.setItems(items);
adapter.notifyDataSetChanged();
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project glide by bumptech.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView giphyLogoView = (ImageView) findViewById(R.id.giphy_logo_view);
Glide.with(this).load(R.raw.large_giphy_logo).into(giphyLogoView);
RecyclerView gifList = (RecyclerView) findViewById(R.id.gif_list);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
gifList.setLayoutManager(layoutManager);
RequestBuilder<Drawable> gifItemRequest = Glide.with(this).asDrawable();
ViewPreloadSizeProvider<Api.GifResult> preloadSizeProvider = new ViewPreloadSizeProvider<>();
adapter = new GifAdapter(this, gifItemRequest, preloadSizeProvider);
gifList.setAdapter(adapter);
RecyclerViewPreloader<Api.GifResult> preloader = new RecyclerViewPreloader<>(Glide.with(this), adapter, preloadSizeProvider, 4);
gifList.addOnScrollListener(preloader);
}
use of android.support.v7.widget.RecyclerView.LayoutManager 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.RecyclerView.LayoutManager in project MyDiary by erttyy8821.
the class ContactsActivity method initTopicAdapter.
private void initTopicAdapter() {
//Init topic adapter
layoutManager = new LinearLayoutManager(this);
RecyclerView_contacts.setLayoutManager(layoutManager);
RecyclerView_contacts.setHasFixedSize(true);
contactsAdapter = new ContactsAdapter(ContactsActivity.this, contactsNamesList, topicId, this);
RecyclerView_contacts.setAdapter(contactsAdapter);
}
use of android.support.v7.widget.RecyclerView.LayoutManager 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