use of com.shizhefei.test.view.adapters.multitype.provider.MessageProvider in project MVCHelper by LuckyJayce.
the class MultiTypeActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_multi_type);
backButton = findViewById(R.id.button1);
coolRefreshView = (CoolRefreshView) findViewById(R.id.multiType_coolRefreshView);
recyclerView = (RecyclerView) findViewById(R.id.multiType_recyclerView);
coolRefreshView.setPullHeader(new DefaultHeader());
recyclerView.setLayoutManager(new LinearLayoutManager(this));
ItemBinderFactory factory = new ItemBinderFactory();
factory.registerProvider(Book.class, new BookProvider());
factory.registerProvider(Message.class, new ItemViewProviderSet<Message>(new MessageProvider(MessageProvider.ALIGN_LEFT), new MessageProvider(MessageProvider.ALIGN_RIGHT)) {
@Override
protected int selectIndex(Message message) {
return myUserId.equals(message.userId) ? 1 : 0;
}
});
multiTypeDataAdapter = new MultiTypeDataAdapter<>(factory);
// adapter.addHeader(view);
multiTypeDataAdapter.setOnItemClickListener(OnItemClickListener);
mvcHelper = new MVCCoolHelper<>(coolRefreshView);
mvcHelper.setDataSource(new MyDataSource());
mvcHelper.setAdapter(multiTypeDataAdapter);
mvcHelper.refresh();
backButton.setOnClickListener(OnClickListener);
}
Aggregations