Search in sources :

Example 1 with Message

use of com.shizhefei.test.view.adapters.multitype.Message in project MVCHelper by LuckyJayce.

the class MyDataSource method refresh.

@Override
public List<Object> refresh() throws Exception {
    Thread.sleep(1000);
    List<Object> list = new ArrayList<>();
    list.add(new Message("1", "你知道你这次比赛用了多少时间么?"));
    list.add(new Message("2", "不知道"));
    list.add(new Message("1", "58秒95"));
    list.add(new Message("2", "58秒95?"));
    list.add(new Message("2", "自己都没想到自己"));
    list.add(new Message("2", "我以为是59秒"));
    list.add(new Message("2", "啊~~我有这么快??"));
    list.add(new Message("2", "我很满意"));
    list.add(new Message("1", "今天这个状态有所保留么?"));
    list.add(new Message("2", "没有保留!我已经,我已经用了洪荒之力啦!"));
    list.add(new Message("1", "是不是对明天的决赛充满希望"));
    list.add(new Message("2", "我已经很满意啦。"));
    list.add(new Message("1", "明天加油"));
    list.add(new Message("2", "啦。。。啦。。。"));
    hasMore = true;
    return list;
}
Also used : Message(com.shizhefei.test.view.adapters.multitype.Message) ArrayList(java.util.ArrayList)

Example 2 with Message

use of com.shizhefei.test.view.adapters.multitype.Message 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);
}
Also used : MyDataSource(com.shizhefei.test.models.datasource.MyDataSource) MessageProvider(com.shizhefei.test.view.adapters.multitype.provider.MessageProvider) Message(com.shizhefei.test.view.adapters.multitype.Message) ItemBinderFactory(com.shizhefei.view.multitype.ItemBinderFactory) DefaultHeader(com.shizhefei.view.coolrefreshview.header.DefaultHeader) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BookProvider(com.shizhefei.test.view.adapters.multitype.provider.BookProvider)

Aggregations

Message (com.shizhefei.test.view.adapters.multitype.Message)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 MyDataSource (com.shizhefei.test.models.datasource.MyDataSource)1 BookProvider (com.shizhefei.test.view.adapters.multitype.provider.BookProvider)1 MessageProvider (com.shizhefei.test.view.adapters.multitype.provider.MessageProvider)1 DefaultHeader (com.shizhefei.view.coolrefreshview.header.DefaultHeader)1 ItemBinderFactory (com.shizhefei.view.multitype.ItemBinderFactory)1 ArrayList (java.util.ArrayList)1