|
8 | 8 | For example, a provider of text message entries: |
9 | 9 |
|
10 | 10 | /** |
11 | | - * https://github.com/chaychan |
12 | 11 | * @author ChayChan |
13 | | - * @description: Text ItemProvider |
14 | | - * @date 2018/3/30 11:39 |
| 12 | + * @description TextMessage's itemProvider |
| 13 | + * @date 2018/3/21 14:43 |
15 | 14 | */ |
16 | | - |
17 | | - @ItemProviderTag( |
18 | | - viewType = DemoMultipleItemRvAdapter.TYPE_TEXT, |
19 | | - layout = R.layout.item_text_view |
| 15 | + @ItemProviderTag( |
| 16 | + viewType = MessageListAdapter.TYPE_TEXT, |
| 17 | + layout = R.layout.item_text_message |
20 | 18 | ) |
21 | | - public class TextItemProvider extends BaseItemProvider<NormalMultipleEntity> { |
22 | | - |
| 19 | + public class TextMessageItemProvider extends BaseItemProvider<TextMessage> { |
| 20 | + |
23 | 21 | @Override |
24 | | - public void convert(BaseViewHolder helper, NormalMultipleEntity data, int position) { |
25 | | - helper.setText(R.id.tv, data.content); |
| 22 | + public void convert(BaseViewHolder helper, TextMessage data, int position) { |
| 23 | + helper.setText(R.id.tv_text, data.text); |
26 | 24 | } |
27 | 25 |
|
28 | 26 | @Override |
29 | | - public void onClick(BaseViewHolder helper, NormalMultipleEntity data, int position) { |
30 | | - Toast.makeText(mContext, "click", Toast.LENGTH_SHORT).show(); |
| 27 | + public void onClick(BaseViewHolder helper, TextMessage data, int position) { |
| 28 | + Toast.makeText(mContext, "Click: " + data.text, Toast.LENGTH_SHORT).show(); |
31 | 29 | } |
32 | 30 |
|
33 | 31 | @Override |
34 | | - public boolean onLongClick(BaseViewHolder helper, NormalMultipleEntity data, int position) { |
35 | | - Toast.makeText(mContext, "longClick", Toast.LENGTH_SHORT).show(); |
| 32 | + public boolean onLongClick(BaseViewHolder helper, TextMessage data, int position) { |
| 33 | + Toast.makeText(mContext, "longClick: " + data.text, Toast.LENGTH_SHORT).show(); |
36 | 34 | return true; |
37 | 35 | } |
38 | 36 | } |
|
0 commit comments