121 lines
3.9 KiB
Java
121 lines
3.9 KiB
Java
package androidx.appcompat.widget;
|
|
|
|
import android.content.res.ColorStateList;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.PorterDuff;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.util.AttributeSet;
|
|
import android.widget.SeekBar;
|
|
import androidx.appcompat.R$styleable;
|
|
import androidx.core.graphics.drawable.DrawableCompat;
|
|
import androidx.core.view.ViewCompat;
|
|
|
|
/* loaded from: classes.dex */
|
|
class AppCompatSeekBarHelper extends AppCompatProgressBarHelper {
|
|
private final SeekBar d;
|
|
private Drawable e;
|
|
private ColorStateList f;
|
|
private PorterDuff.Mode g;
|
|
private boolean h;
|
|
private boolean i;
|
|
|
|
AppCompatSeekBarHelper(SeekBar seekBar) {
|
|
super(seekBar);
|
|
this.f = null;
|
|
this.g = null;
|
|
this.h = false;
|
|
this.i = false;
|
|
this.d = seekBar;
|
|
}
|
|
|
|
private void d() {
|
|
if (this.e != null) {
|
|
if (this.h || this.i) {
|
|
this.e = DrawableCompat.h(this.e.mutate());
|
|
if (this.h) {
|
|
DrawableCompat.a(this.e, this.f);
|
|
}
|
|
if (this.i) {
|
|
DrawableCompat.a(this.e, this.g);
|
|
}
|
|
if (this.e.isStateful()) {
|
|
this.e.setState(this.d.getDrawableState());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.AppCompatProgressBarHelper
|
|
void a(AttributeSet attributeSet, int i) {
|
|
super.a(attributeSet, i);
|
|
TintTypedArray a = TintTypedArray.a(this.d.getContext(), attributeSet, R$styleable.AppCompatSeekBar, i, 0);
|
|
Drawable c = a.c(R$styleable.AppCompatSeekBar_android_thumb);
|
|
if (c != null) {
|
|
this.d.setThumb(c);
|
|
}
|
|
a(a.b(R$styleable.AppCompatSeekBar_tickMark));
|
|
if (a.g(R$styleable.AppCompatSeekBar_tickMarkTintMode)) {
|
|
this.g = DrawableUtils.a(a.d(R$styleable.AppCompatSeekBar_tickMarkTintMode, -1), this.g);
|
|
this.i = true;
|
|
}
|
|
if (a.g(R$styleable.AppCompatSeekBar_tickMarkTint)) {
|
|
this.f = a.a(R$styleable.AppCompatSeekBar_tickMarkTint);
|
|
this.h = true;
|
|
}
|
|
a.a();
|
|
d();
|
|
}
|
|
|
|
void b() {
|
|
Drawable drawable = this.e;
|
|
if (drawable != null && drawable.isStateful() && drawable.setState(this.d.getDrawableState())) {
|
|
this.d.invalidateDrawable(drawable);
|
|
}
|
|
}
|
|
|
|
void c() {
|
|
Drawable drawable = this.e;
|
|
if (drawable != null) {
|
|
drawable.jumpToCurrentState();
|
|
}
|
|
}
|
|
|
|
void a(Drawable drawable) {
|
|
Drawable drawable2 = this.e;
|
|
if (drawable2 != null) {
|
|
drawable2.setCallback(null);
|
|
}
|
|
this.e = drawable;
|
|
if (drawable != null) {
|
|
drawable.setCallback(this.d);
|
|
DrawableCompat.a(drawable, ViewCompat.k(this.d));
|
|
if (drawable.isStateful()) {
|
|
drawable.setState(this.d.getDrawableState());
|
|
}
|
|
d();
|
|
}
|
|
this.d.invalidate();
|
|
}
|
|
|
|
void a(Canvas canvas) {
|
|
if (this.e != null) {
|
|
int max = this.d.getMax();
|
|
if (max > 1) {
|
|
int intrinsicWidth = this.e.getIntrinsicWidth();
|
|
int intrinsicHeight = this.e.getIntrinsicHeight();
|
|
int i = intrinsicWidth >= 0 ? intrinsicWidth / 2 : 1;
|
|
int i2 = intrinsicHeight >= 0 ? intrinsicHeight / 2 : 1;
|
|
this.e.setBounds(-i, -i2, i, i2);
|
|
float width = ((this.d.getWidth() - this.d.getPaddingLeft()) - this.d.getPaddingRight()) / max;
|
|
int save = canvas.save();
|
|
canvas.translate(this.d.getPaddingLeft(), this.d.getHeight() / 2);
|
|
for (int i3 = 0; i3 <= max; i3++) {
|
|
this.e.draw(canvas);
|
|
canvas.translate(width, 0.0f);
|
|
}
|
|
canvas.restoreToCount(save);
|
|
}
|
|
}
|
|
}
|
|
}
|