deliver offsetPercent to QMUITabIndicator

This commit is contained in:
cgspine
2020-05-11 15:14:02 +08:00
parent d915f643c7
commit aaae2e7d8c
2 changed files with 11 additions and 5 deletions
@@ -534,7 +534,7 @@ public class QMUIBasicTabSegment extends HorizontalScrollView implements IQMUILa
if (model == null || mIndicator == null) {
return;
}
mIndicator.updateInfo(model.contentLeft, model.contentWidth, model.selectedColorAttr == 0 ? model.selectColor : QMUISkinHelper.getSkinColor(this, model.selectedColorAttr));
mIndicator.updateInfo(model.contentLeft, model.contentWidth, model.selectedColorAttr == 0 ? model.selectColor : QMUISkinHelper.getSkinColor(this, model.selectedColorAttr), 0f);
if (invalidate) {
mContentLayout.invalidate();
}
@@ -552,7 +552,7 @@ public class QMUIBasicTabSegment extends HorizontalScrollView implements IQMUILa
preModel.selectedColorAttr == 0 ? preModel.selectColor : QMUISkinHelper.getSkinColor(this, preModel.selectedColorAttr),
targetModel.selectedColorAttr == 0 ? targetModel.selectColor : QMUISkinHelper.getSkinColor(this, targetModel.selectedColorAttr),
offsetPercent);
mIndicator.updateInfo(targetLeft, targetWidth, indicatorColor);
mIndicator.updateInfo(targetLeft, targetWidth, indicatorColor, offsetPercent);
mContentLayout.invalidate();
}
@@ -30,6 +30,7 @@ import com.qmuiteam.qmui.util.QMUIResHelper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.graphics.drawable.DrawableCompat;
public class QMUITabIndicator {
@@ -99,7 +100,8 @@ public class QMUITabIndicator {
return mIndicatorTop;
}
protected void updateInfo(int left, int width, int color) {
@Deprecated
protected void updateInfo(int left, int width, int color){
if (mIndicatorRect == null) {
mIndicatorRect = new Rect(left, 0,
left + width, 0);
@@ -112,9 +114,13 @@ public class QMUITabIndicator {
}
}
private void updateColor(int color){
protected void updateInfo(int left, int width, int color, float offsetPercent) {
updateInfo(left, width, color);
}
protected void updateColor(int color){
if (mIndicatorDrawable != null) {
QMUIDrawableHelper.setDrawableTintColor(mIndicatorDrawable, color);
DrawableCompat.setTint(mIndicatorDrawable, color);
} else {
if (mIndicatorPaint == null) {
mIndicatorPaint = new Paint();