Search in sources :

Example 1 with Items

use of me.drakeet.multitype.Items 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 2 with Items

use of me.drakeet.multitype.Items 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 3 with Items

use of me.drakeet.multitype.Items 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 4 with Items

use of me.drakeet.multitype.Items 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)

Example 5 with Items

use of me.drakeet.multitype.Items 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)

Aggregations

Items (me.drakeet.multitype.Items)12 MultiTypeAdapter (me.drakeet.multitype.MultiTypeAdapter)11 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)4 RecyclerView (android.support.v7.widget.RecyclerView)4 TextItem (me.drakeet.multitype.sample.normal.TextItem)3 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 GridLayoutManager (android.support.v7.widget.GridLayoutManager)1 Category (com.jweihao.jdemo.bean.Category)1 Post (com.jweihao.jdemo.bean.Post)1 PostList (com.jweihao.jdemo.bean.PostList)1 Song (com.jweihao.jdemo.bean.Song)1 CategoryViewBinder (com.jweihao.jdemo.ui.activity.md.viewBinder.CategoryViewBinder)1