use of me.drakeet.multitype.sample.common.CategoryItemViewBinder in project MultiType by drakeet.
the class MultiTypeInstaller method start.
static void start() {
GlobalMultiTypePool.register(TextItem.class, new TextItemViewBinder());
GlobalMultiTypePool.register(ImageItem.class, new ImageItemViewBinder());
GlobalMultiTypePool.register(Category.class, new CategoryItemViewBinder());
}
use of me.drakeet.multitype.sample.common.CategoryItemViewBinder 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.register(Category.class, new CategoryItemViewBinder());
adapter.register(Post.class, new PostViewBinder());
adapter.register(PostList.class, new HorizontalPostsViewBinder());
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.CategoryItemViewBinder in project MultiType by drakeet.
the class MultiSelectableActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_multi_selectable);
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.register(Category.class, new CategoryItemViewBinder());
adapter.register(Square.class, new SquareViewBinder(selectedSet));
loadData();
assertAllRegistered(adapter, items);
recyclerView.setAdapter(adapter);
setupFAB();
}
Aggregations