use of me.drakeet.multitype.MultiTypeAdapter in project GwellDemo by dxsdyhm.
the class DeviceActivity method initUI.
private void initUI() {
txDeviceinfo.setText(device.toString());
items = new Items();
adapter = new MultiTypeAdapter(items);
adapter.register(LogInfo.class, new LogInfoProvider());
ryContent.setLayoutManager(new LinearLayoutManager(this));
ryContent.setAdapter(adapter);
etIp.setText(IPDefault);
etPort.setText(String.valueOf(Server_port));
ryContent.setVisibility(View.GONE);
// setTitle(getString(R.string.wait_label));
String tips = getString(R.string.wait_label);
txUertips.setText(tips);
txUertips.append("\n");
txUertips.append(String.format(getString(R.string.tips2), surpprot_email));
Linkify.addLinks(txUertips, Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES);
}
use of me.drakeet.multitype.MultiTypeAdapter 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.MultiTypeAdapter in project MultiType by drakeet.
the class SimpleActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);
RecyclerView recyclerView = findViewById(R.id.list);
Items items = new Items();
adapter = new MultiTypeAdapter();
adapter.register(TextItem.class, new TextItemWithOutsizeDataViewBinder(aFieldValue));
recyclerView.setAdapter(adapter);
assertHasTheSameAdapter(recyclerView, adapter);
for (int i = 0; i < 20; i++) {
items.add(new TextItem(valueOf(i)));
}
adapter.setItems(items);
adapter.notifyDataSetChanged();
assertAllRegistered(adapter, items);
}
use of me.drakeet.multitype.MultiTypeAdapter 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();
}
use of me.drakeet.multitype.MultiTypeAdapter in project MultiType by drakeet.
the class NormalActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);
RecyclerView recyclerView = findViewById(R.id.list);
adapter = new MultiTypeAdapter();
adapter.register(TextItem.class, new TextItemViewBinder());
adapter.register(ImageItem.class, new ImageItemViewBinder());
adapter.register(RichItem.class, new RichItemViewBinder());
recyclerView.setAdapter(adapter);
TextItem textItem = new TextItem("world");
ImageItem imageItem = new ImageItem(R.mipmap.ic_launcher);
RichItem richItem = new RichItem("小艾大人赛高", R.mipmap.avatar);
items = new ArrayList<>();
for (int i = 0; i < 20; i++) {
items.add(textItem);
items.add(imageItem);
items.add(richItem);
}
adapter.setItems(items);
adapter.notifyDataSetChanged();
}
Aggregations