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

Class HeaderCell

app/src/main/java/cc/ioctl/tmoe/ui/wrapper/cell/HeaderCell.java:29–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27import cc.ioctl.tmoe.ui.Theme;
28
29@SuppressLint("RtlHardcoded")
30public class HeaderCell extends FrameLayout {
31
32 private TextView textView;
33 private TextView textView2;
34 private int height = 40;
35
36 public HeaderCell(Context context) {
37 this(context, Theme.key_windowBackgroundWhiteBlueHeader, 21, 15, false);
38 }
39
40 public HeaderCell(Context context, int padding) {
41 this(context, Theme.key_windowBackgroundWhiteBlueHeader, padding, 15, false);
42 }
43
44 public HeaderCell(Context context, String textColorKey, int padding, int topMargin, boolean text2) {
45 super(context);
46
47 textView = new TextView(getContext());
48 textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
49 textView.setTypeface(LayoutHelper.getTypeface("fonts/rmedium.ttf"));
50 textView.setEllipsize(TextUtils.TruncateAt.END);
51 textView.setGravity((LocaleController.isRTL() ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
52 textView.setMinHeight(LayoutHelper.dp(height - topMargin));
53 textView.setTextColor(getThemedColor(textColorKey));
54 textView.setTag(textColorKey);
55 addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL() ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, padding, topMargin, padding, 0));
56
57 if (text2) {
58 textView2 = new TextView(getContext());
59 textView2.setTextSize(13);
60 textView2.setGravity((LocaleController.isRTL() ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP);
61 addView(textView2, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL() ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, padding, 21, padding, 0));
62 }
63
64 ViewCompat.setAccessibilityHeading(this, true);
65 }
66
67 public void setHeight(int value) {
68 textView.setMinHeight(LayoutHelper.dp(height = value) - ((LayoutParams) textView.getLayoutParams()).topMargin);
69 }
70
71 public void setEnabled(boolean value, ArrayList<Animator> animators) {
72 if (animators != null) {
73 animators.add(ObjectAnimator.ofFloat(textView, "alpha", value ? 1.0f : 0.5f));
74 } else {
75 textView.setAlpha(value ? 1.0f : 0.5f);
76 }
77 }
78
79 @Override
80 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
81 super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
82 }
83
84 public void setText(CharSequence text) {
85 textView.setText(text);
86 }

Callers 1

createViewHolderMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected