Search in sources :

Example 1 with MultiTypeAdapter

use of me.drakeet.multitype.MultiTypeAdapter in project MultiType by drakeet.

the class MultiSelectActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_multi_select);
    RecyclerView 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.applyGlobalMultiTypePool();
    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)

Example 2 with MultiTypeAdapter

use of me.drakeet.multitype.MultiTypeAdapter in project KL2 by jweihao.

the class RecyclerViewMultiTypeActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_recycler_view_multi_type);
    ButterKnife.bind(this);
    LinearLayoutManager manager = new LinearLayoutManager(this);
    manager.setOrientation(LinearLayoutManager.VERTICAL);
    mRecyclerView.setLayoutManager(manager);
    mTypeAdapter = new MultiTypeAdapter();
    /* 注册类型和View的对应关系 */
    mTypeAdapter.register(Category.class, new CategoryViewBinder());
    mTypeAdapter.register(Song.class, new SongViewBinder());
    mTypeAdapter.register(PostList.class, new HorizontalItemViewBinder());
    mRecyclerView.setAdapter(mTypeAdapter);
    /* 模拟加载数据,也可以稍后再加载,然后使用
         * mTypeAdapter.notifyDataSetChanged(); 刷新列表 */
    mItems = new Items();
    List<Post> posts = new ArrayList();
    for (int i = 0; i < 30; i++) {
        mItems.add(new Category("天青色等烟雨,而我在等你。"));
        mItems.add(new Song("Android", R.drawable.ic_launcher));
        mItems.add(new Song("IOS", R.mipmap.ic_launcher_round));
        // mItems.add(new PostList(new Post(R.drawable.ic_launcher, "机器人"), 1));
        posts.add(new Post(R.mipmap.ic_launcher_round, "机器人"));
    }
    mItems.add(2, new PostList(posts));
    mTypeAdapter.setItems(mItems);
    mTypeAdapter.notifyDataSetChanged();
}
Also used : SongViewBinder(com.jweihao.jdemo.ui.activity.md.viewBinder.SongViewBinder) Category(com.jweihao.jdemo.bean.Category) CategoryViewBinder(com.jweihao.jdemo.ui.activity.md.viewBinder.CategoryViewBinder) HorizontalItemViewBinder(com.jweihao.jdemo.ui.activity.md.viewBinder.HorizontalItemViewBinder) Post(com.jweihao.jdemo.bean.Post) ArrayList(java.util.ArrayList) PostList(com.jweihao.jdemo.bean.PostList) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Song(com.jweihao.jdemo.bean.Song) Items(me.drakeet.multitype.Items) MultiTypeAdapter(me.drakeet.multitype.MultiTypeAdapter)

Example 3 with MultiTypeAdapter

use of me.drakeet.multitype.MultiTypeAdapter in project GwellDemo by dxsdyhm.

the class AllarmImageListActivity method initData.

private void initData() {
    items = new Items();
    adapter = new MultiTypeAdapter(items);
    creatFile();
    AlarmInfoProvider p = new AlarmInfoProvider();
    p.setOnItemClickListner(listner);
    adapter.register(AlarmInfo.class, p);
    rcAllarm.setLayoutManager(new LinearLayoutManager(this));
    rcAllarm.setAdapter(adapter);
}
Also used : AlarmInfoProvider(adapter.AlarmInfoProvider) Items(me.drakeet.multitype.Items) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) MultiTypeAdapter(me.drakeet.multitype.MultiTypeAdapter)

Example 4 with MultiTypeAdapter

use of me.drakeet.multitype.MultiTypeAdapter in project GwellDemo by dxsdyhm.

the class RecordFilesActivity method getRecordFiles.

private void getRecordFiles() {
    txLoading.setVisibility(View.VISIBLE);
    txLoading.setText(R.string.loading);
    // 经过转换后的设备密码
    devicePwd = P2PHandler.getInstance().EntryPassword(devicePwd);
    items = new Items();
    adapter = new MultiTypeAdapter(items);
    Date endDate = new Date(System.currentTimeMillis());
    RecordFileProvider recordFileProvider = new RecordFileProvider();
    adapter.register(RecordFile.class, recordFileProvider);
    recordFileProvider.setOnItemClickListner(new RecordFileProvider.OnItemClickListner() {

        @Override
        public void onItemClick(int position, RecordFile recordFile) {
            Intent intent = new Intent(RecordFilesActivity.this, PlayBackActivity.class);
            Bundle bundle = new Bundle();
            bundle.putSerializable("file", recordFile);
            intent.putExtra("recordFile", bundle);
            intent.putExtra("deviceId", deviceId);
            intent.putExtra("devicePwd", devicePwd);
            startActivity(intent);
        }
    });
    // 获取录像列表
    P2PHandler.getInstance().getRecordFiles(deviceId, devicePwd, startDate, endDate);
    rcRecordfiles.setAdapter(adapter);
    new Timer().schedule(new TimerTask() {

        @Override
        public void run() {
            if (items.size() == 0) {
                hander.sendEmptyMessage(0);
            }
        }
    }, 8000);
}
Also used : Bundle(android.os.Bundle) RecordFileProvider(adapter.RecordFileProvider) Intent(android.content.Intent) Date(java.util.Date) RecordFile(entity.RecordFile) Timer(java.util.Timer) TimerTask(java.util.TimerTask) Items(me.drakeet.multitype.Items) MultiTypeAdapter(me.drakeet.multitype.MultiTypeAdapter)

Example 5 with MultiTypeAdapter

use of me.drakeet.multitype.MultiTypeAdapter in project GwellDemo by dxsdyhm.

the class SensorActivity method initRC.

private void initRC() {
    rcSensor.setLayoutManager(new GridLayoutManager(this, 8));
    items = new Items();
    adapter = new MultiTypeAdapter(items);
    SensorProvider provider = new SensorProvider();
    adapter.register(Integer.class, provider);
    provider.setOnItemClickListner(new SensorProvider.OnItemClickListner() {

        @Override
        public void onItemClick(int position, Integer integer) {
            if (integer == 1) {
                // 学习配对
                P2PHandler.getInstance().setDefenceAreaState(deviceId, devicePass, position / 8, position % 8, 0);
                Toast.makeText(SensorActivity.this, R.string.start_pair, Toast.LENGTH_SHORT).show();
                currentPositon = position;
            }
        }
    });
    rcSensor.setAdapter(adapter);
}
Also used : SensorProvider(adapter.SensorProvider) GridLayoutManager(android.support.v7.widget.GridLayoutManager) Items(me.drakeet.multitype.Items) 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