use of me.drakeet.multitype.sample.common.Category in project MultiType by drakeet.
the class MultiSelectActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_multi_select);
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
final GridLayoutManager layoutManager = new GridLayoutManager(this, SPAN_COUNT);
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
return (items.get(position) instanceof Category) ? SPAN_COUNT : 1;
}
});
selectedSet = new TreeSet<>();
recyclerView.setLayoutManager(layoutManager);
adapter = new MultiTypeAdapter();
adapter.applyGlobalMultiTypePool();
adapter.register(Square.class, new SquareViewBinder(selectedSet));
loadData();
assertAllRegistered(adapter, items);
recyclerView.setAdapter(adapter);
setupFAB();
}
use of me.drakeet.multitype.sample.common.Category 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 me.drakeet.multitype.sample.common.Category in project MultiType by drakeet.
the class MultiSelectActivity method loadData.
private void loadData() {
Category spacialCategory = new Category("特别篇");
items.add(spacialCategory);
for (int i = 0; i < 7; i++) {
items.add(new Square(i + 1));
}
Category currentCategory = new Category("本篇");
items.add(currentCategory);
for (int i = 0; i < 1000; i++) {
items.add(new Square(i + 1));
}
adapter.setItems(items);
adapter.notifyDataSetChanged();
}
Aggregations