From 3d751dcd8c1a09c8384d1e051cd37e446d4c0cb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=B3=A2?= <349637011@qq.com> Date: Mon, 4 Jan 2021 17:09:06 +0800 Subject: [PATCH] fix progressbar font --- .../com/pichs/common/widget/progressbar/XProgressBar.java | 4 ++++ .../java/com/pichs/common/widget/view/XCheckedTextView.java | 3 ++- .../src/main/java/com/pichs/common/widget/view/XEditText.java | 2 +- .../src/main/java/com/pichs/common/widget/view/XTextView.java | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/widget/src/main/java/com/pichs/common/widget/progressbar/XProgressBar.java b/widget/src/main/java/com/pichs/common/widget/progressbar/XProgressBar.java index 10dc242..bc20a6a 100644 --- a/widget/src/main/java/com/pichs/common/widget/progressbar/XProgressBar.java +++ b/widget/src/main/java/com/pichs/common/widget/progressbar/XProgressBar.java @@ -23,13 +23,16 @@ import android.graphics.Paint; import android.graphics.Point; import android.graphics.RectF; +import android.graphics.Typeface; import android.util.AttributeSet; import androidx.annotation.IntDef; +import androidx.annotation.Nullable; import androidx.core.view.ViewCompat; import com.pichs.common.widget.R; import com.pichs.common.widget.utils.XDisplayHelper; +import com.pichs.common.widget.utils.XTypefaceHelper; import com.pichs.common.widget.view.XView; import java.lang.annotation.Retention; @@ -115,6 +118,7 @@ public XProgressBar(Context context, AttributeSet attrs, int defStyleAttr) { } public void setup(Context context, AttributeSet attrs) { + XTypefaceHelper.observer(this, typeface -> mTextPaint.setTypeface(typeface)); TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.XProgressBar); mType = array.getInt(R.styleable.XProgressBar_xp_progressType, TYPE_RECT); mProgressColor = array.getColor(R.styleable.XProgressBar_xp_progressColor, DEFAULT_PROGRESS_COLOR); diff --git a/widget/src/main/java/com/pichs/common/widget/view/XCheckedTextView.java b/widget/src/main/java/com/pichs/common/widget/view/XCheckedTextView.java index 72859bf..8eddef4 100644 --- a/widget/src/main/java/com/pichs/common/widget/view/XCheckedTextView.java +++ b/widget/src/main/java/com/pichs/common/widget/view/XCheckedTextView.java @@ -30,7 +30,6 @@ public XCheckedTextView(Context context) { public XCheckedTextView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); init(context, attrs, 0); - XTypefaceHelper.observer(this, this::setTypeface); } public XCheckedTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { @@ -41,6 +40,8 @@ public XCheckedTextView(Context context, @Nullable AttributeSet attrs, int defSt private void init(Context context, AttributeSet attrs, int defStyleAttr) { backgroundHelper = new XBackgroundHelper(context, attrs, defStyleAttr, this); textViewHelper = new XTextViewHelper(context, attrs, defStyleAttr, this); + init(context, attrs, defStyleAttr); + XTypefaceHelper.observer(this, this::setTypeface); } @Override diff --git a/widget/src/main/java/com/pichs/common/widget/view/XEditText.java b/widget/src/main/java/com/pichs/common/widget/view/XEditText.java index 74420b1..ca6b217 100644 --- a/widget/src/main/java/com/pichs/common/widget/view/XEditText.java +++ b/widget/src/main/java/com/pichs/common/widget/view/XEditText.java @@ -42,7 +42,6 @@ public XEditText(@NonNull Context context, @Nullable AttributeSet attrs) { public XEditText(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(context, attrs, defStyleAttr); - XTypefaceHelper.observer(this, this::setTypeface); } @@ -55,6 +54,7 @@ private void init(Context context, AttributeSet attrs, int defStyleAttr) { if (disableCopyAndPaste) { XEditTextHelper.disableCopyAndPaste(this); } + XTypefaceHelper.observer(this, this::setTypeface); } public boolean isDisableCopyAndPaste() { diff --git a/widget/src/main/java/com/pichs/common/widget/view/XTextView.java b/widget/src/main/java/com/pichs/common/widget/view/XTextView.java index 97c0242..b901788 100644 --- a/widget/src/main/java/com/pichs/common/widget/view/XTextView.java +++ b/widget/src/main/java/com/pichs/common/widget/view/XTextView.java @@ -34,12 +34,12 @@ public XTextView(Context context, @Nullable AttributeSet attrs) { public XTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(context, attrs, defStyleAttr); - XTypefaceHelper.observer(this, this::setTypeface); } private void init(Context context, AttributeSet attrs, int defStyleAttr) { backgroundHelper = new XBackgroundHelper(context, attrs, defStyleAttr, this); textViewHelper = new XTextViewHelper(context, attrs, defStyleAttr, this); + XTypefaceHelper.observer(this, this::setTypeface); } @Override