Search in sources :

Example 1 with SimpleImage

use of me.drakeet.multitype.sample.weibo.content.SimpleImage in project MultiType by drakeet.

the class WeiboActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
    /* WeiboAdapter! */
    adapter = new WeiboAdapter();
    adapter.register(SimpleText.class, new SimpleTextViewBinder());
    adapter.register(SimpleImage.class, new SimpleImageViewBinder());
    recyclerView.setAdapter(adapter);
    items = new Items();
    User user = new User("drakeet", R.mipmap.avatar);
    SimpleText simpleText = new SimpleText("A simple text Weibo: Hello World.");
    SimpleImage simpleImage = new SimpleImage(R.drawable.img_10);
    for (int i = 0; i < 20; i++) {
        items.add(new Weibo(user, simpleText));
        items.add(new Weibo(user, simpleImage));
    }
    adapter.setItems(items);
    adapter.notifyDataSetChanged();
    assertAllRegistered(adapter, items);
    loadRemoteData();
}
Also used : SimpleText(me.drakeet.multitype.sample.weibo.content.SimpleText) SimpleImageViewBinder(me.drakeet.multitype.sample.weibo.content.SimpleImageViewBinder) SimpleImage(me.drakeet.multitype.sample.weibo.content.SimpleImage) SimpleTextViewBinder(me.drakeet.multitype.sample.weibo.content.SimpleTextViewBinder) RecyclerView(android.support.v7.widget.RecyclerView) Items(me.drakeet.multitype.Items)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)1 Items (me.drakeet.multitype.Items)1 SimpleImage (me.drakeet.multitype.sample.weibo.content.SimpleImage)1 SimpleImageViewBinder (me.drakeet.multitype.sample.weibo.content.SimpleImageViewBinder)1 SimpleText (me.drakeet.multitype.sample.weibo.content.SimpleText)1 SimpleTextViewBinder (me.drakeet.multitype.sample.weibo.content.SimpleTextViewBinder)1