-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimpleTextHolder.java
51 lines (40 loc) · 1.29 KB
/
SimpleTextHolder.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package com.nstd.rvsample.holders;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.TextView;
import com.nstd.rvsample.R;
import com.nstd.rvadapter.SimpleHolderLayout;
import com.nstd.rvadapter.SimpleRVHolder;
/**
* Created by Nstd on 2019-08-26 11:08.
*/
@SimpleHolderLayout(R.layout.text_holder_view)
public class SimpleTextHolder extends SimpleRVHolder<String> {
public static final String CONF_SHOW_INDEX = "conf_show_index";
TextView mTextView;
Boolean mShowIndex;
public SimpleTextHolder(@NonNull View view) {
super(view);
mTextView = findViewById(R.id.tv_text);
}
@Override
public void bindData(Context ctx) {
mShowIndex = getConfig(CONF_SHOW_INDEX, false);
int mode = (getAdapterPosition() + 1) % 3;
switch (mode) {
case 0:
removeItemClickListener();
removeItemLongClickListener();
break;
case 1:
removeItemLongClickListener();
break;
case 2:
removeItemClickListener();
break;
}
String prefix = mShowIndex ? getAdapterPosition() + " " : "";
mTextView.setText(prefix + mItemData);
}
}