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();
}
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();
}
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);
}
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);
}
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);
}
Aggregations