MCPcopy Create free account
hub / github.com/cinit/TMoe / TextInfo2Cell

Class TextInfo2Cell

app/src/main/java/cc/ioctl/tmoe/ui/wrapper/cell/TextInfo2Cell.java:32–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30import cc.ioctl.tmoe.ui.Theme;
31
32@SuppressLint("RtlHardcoded")
33public class TextInfo2Cell extends FrameLayout {
34
35 private final TextView textView;
36 private String linkTextColorKey = Theme.key_windowBackgroundWhiteLinkText;
37 private int topPadding = 10;
38 private int bottomPadding = 17;
39 private int fixedSize;
40
41 private CharSequence text;
42
43 public TextInfo2Cell(Context context) {
44 this(context, 21);
45 }
46
47
48 public TextInfo2Cell(Context context, int padding) {
49 super(context);
50
51 textView = new androidx.appcompat.widget.AppCompatTextView(context) {
52 @Override
53 protected void onDraw(Canvas canvas) {
54 onTextDraw();
55 super.onDraw(canvas);
56 afterTextDraw();
57 }
58 };
59 textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
60 textView.setGravity(LocaleController.isRTL() ? Gravity.RIGHT : Gravity.LEFT);
61 textView.setPadding(0, LayoutHelper.dp(10), 0, LayoutHelper.dp(17));
62 textView.setMovementMethod(LinkMovementMethod.getInstance());
63 textView.setTextColor(getThemedColor(Theme.key_windowBackgroundWhiteGrayText4));
64 textView.setLinkTextColor(getThemedColor(linkTextColorKey));
65 textView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
66 addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT,
67 (LocaleController.isRTL() ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, padding, 0, padding, 0));
68 }
69
70 protected void onTextDraw() {
71 }
72
73 protected void afterTextDraw() {
74 }
75
76 public void setLinkTextColorKey(String key) {
77 linkTextColorKey = key;
78 }
79
80 @Override
81 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
82 if (fixedSize != 0) {
83 super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(LayoutHelper.dp(fixedSize), MeasureSpec.EXACTLY));
84 } else {
85 super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
86 }
87 }
88
89 public void setTopPadding(int topPadding) {

Callers 1

createViewHolderMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected