Search in sources :

Example 6 with MultiTypeAdapter

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);
}
Also used : LogInfoProvider(adapter.LogInfoProvider) Items(me.drakeet.multitype.Items) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) MultiTypeAdapter(me.drakeet.multitype.MultiTypeAdapter)

Example 7 with MultiTypeAdapter

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();
}
Also used : Category(me.drakeet.multitype.sample.common.Category) CategoryItemViewBinder(me.drakeet.multitype.sample.common.CategoryItemViewBinder) SpanSizeLookup(android.support.v7.widget.GridLayoutManager.SpanSizeLookup) GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) MultiTypeAdapter(me.drakeet.multitype.MultiTypeAdapter)

Example 8 with MultiTypeAdapter

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);
}
Also used : TextItem(me.drakeet.multitype.sample.normal.TextItem) RecyclerView(android.support.v7.widget.RecyclerView) Items(me.drakeet.multitype.Items) MultiTypeAdapter(me.drakeet.multitype.MultiTypeAdapter)

Example 9 with MultiTypeAdapter

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();
}
Also used : Category(me.drakeet.multitype.sample.common.Category) GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) MultiTypeAdapter(me.drakeet.multitype.MultiTypeAdapter) CategoryItemViewBinder(me.drakeet.multitype.sample.common.CategoryItemViewBinder)

Example 10 with MultiTypeAdapter

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();
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) MultiTypeAdapter(me.drakeet.multitype.MultiTypeAdapter)

Aggregations

MultiTypeAdapter (me.drakeet.multitype.MultiTypeAdapter)16 Items (me.drakeet.multitype.Items)11 RecyclerView (android.support.v7.widget.RecyclerView)8 GridLayoutManager (android.support.v7.widget.GridLayoutManager)4 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)4 Category (me.drakeet.multitype.sample.common.Category)3 TextItem (me.drakeet.multitype.sample.normal.TextItem)3 CategoryItemViewBinder (me.drakeet.multitype.sample.common.CategoryItemViewBinder)2 AlarmInfoProvider (adapter.AlarmInfoProvider)1 LogInfoProvider (adapter.LogInfoProvider)1 RecordFileProvider (adapter.RecordFileProvider)1 SensorProvider (adapter.SensorProvider)1 SerialAppProvider (adapter.SerialAppProvider)1 SuppressLint (android.annotation.SuppressLint)1 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)1 SpanSizeLookup (android.support.v7.widget.GridLayoutManager.SpanSizeLookup)1 Category (com.jweihao.jdemo.bean.Category)1 Post (com.jweihao.jdemo.bean.Post)1