package vn.vinfast.charginguikit.ui.views;

/* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
/* JADX INFO: loaded from: E:\ios\vf_dex\classes6.dex */
@kotlin.Metadata(d1 = {"\u0000`\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0010\u0007\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\n\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\b\u0007\u0018\u00002\u00020\u0001B'\b\u0007\u0012\u0006\u0010\u0003\u001a\u00020\u0002\u0012\n\b\u0002\u0010\u0005\u001a\u0004\u0018\u00010\u0004\u0012\b\b\u0002\u0010\u0007\u001a\u00020\u0006¢\u0006\u0004\b\b\u0010\tJ\u001f\u0010\u000f\u001a\u00020\u000e2\u0006\u0010\u000b\u001a\u00020\n2\u0006\u0010\r\u001a\u00020\fH\u0002¢\u0006\u0004\b\u000f\u0010\u0010J\u001f\u0010\u0011\u001a\u00020\n2\u0006\u0010\u000b\u001a\u00020\n2\u0006\u0010\r\u001a\u00020\fH\u0002¢\u0006\u0004\b\u0011\u0010\u0012J\r\u0010\u0013\u001a\u00020\u000e¢\u0006\u0004\b\u0013\u0010\u0014J\u0017\u0010\u0017\u001a\u00020\u000e2\u0006\u0010\u0016\u001a\u00020\u0015H\u0014¢\u0006\u0004\b\u0017\u0010\u0018J\u000f\u0010\u0019\u001a\u00020\u000eH\u0014¢\u0006\u0004\b\u0019\u0010\u0014J\u0017\u0010\u001b\u001a\u0004\u0018\u00010\u001a2\u0006\u0010\r\u001a\u00020\f¢\u0006\u0004\b\u001b\u0010\u001cR*\u0010$\u001a\n\u0012\u0004\u0012\u00020\u000e\u0018\u00010\u001d8\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\b\u001e\u0010\u001f\u001a\u0004\b \u0010!\"\u0004\b\"\u0010#R*\u0010'\u001a\n\u0012\u0004\u0012\u00020\u000e\u0018\u00010\u001d8\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\b\u000f\u0010\u001f\u001a\u0004\b%\u0010!\"\u0004\b&\u0010#R\u0018\u0010*\u001a\u0004\u0018\u00010(8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\u001b\u0010)R\u0018\u0010.\u001a\u0004\u0018\u00010+8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b,\u0010-R\u0018\u00101\u001a\u0004\u0018\u00010/8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\u0011\u00100¨\u00062"}, d2 = {"Lvn/vinfast/charginguikit/ui/views/ViewDividerStep;", "Landroid/view/View;", "Landroid/content/Context;", "context", "Landroid/util/AttributeSet;", "attrs", "", "defStyleAttr", "<init>", "(Landroid/content/Context;Landroid/util/AttributeSet;I)V", "", "percent", "", "forward", "", "b", "(FZ)V", "e", "(FZ)F", "f", "()V", "Landroid/graphics/Canvas;", "canvas", "onDraw", "(Landroid/graphics/Canvas;)V", "onDetachedFromWindow", "Landroid/animation/Animator;", "c", "(Z)Landroid/animation/Animator;", "Lkotlin/Function0;", "a", "Lkotlin/jvm/functions/Function0;", "getOnAnimationEnd", "()Lkotlin/jvm/functions/Function0;", "setOnAnimationEnd", "(Lkotlin/jvm/functions/Function0;)V", "onAnimationEnd", "getOnAnimationStart", "setOnAnimationStart", "onAnimationStart", "Landroid/animation/ValueAnimator;", "Landroid/animation/ValueAnimator;", "animator", "Landroid/graphics/Paint;", "d", "Landroid/graphics/Paint;", "paint", "Landroid/graphics/RectF;", "Landroid/graphics/RectF;", "rect", "chargingkitui_release"}, k = 1, mv = {2, 2, 0}, xi = 48)
@android.annotation.SuppressLint({"Recycle", "CustomViewStyleable", "UseCompatLoadingForDrawables"})
@kotlin.jvm.internal.SourceDebugExtension
public final class ViewDividerStep extends android.view.View {

    /* JADX INFO: renamed from: a, reason: from kotlin metadata */
    private kotlin.jvm.functions.Function0 onAnimationEnd;

    /* JADX INFO: renamed from: b, reason: from kotlin metadata */
    private kotlin.jvm.functions.Function0 onAnimationStart;

    /* JADX INFO: renamed from: c, reason: from kotlin metadata */
    private android.animation.ValueAnimator animator;

    /* JADX INFO: renamed from: d, reason: from kotlin metadata */
    private android.graphics.Paint paint;

    /* JADX INFO: renamed from: e, reason: from kotlin metadata */
    private android.graphics.RectF rect;

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    @kotlin.jvm.JvmOverloads
    public ViewDividerStep(@org.jetbrains.annotations.NotNull android.content.Context context) {
        this(context, null, 0, 6, null);
        kotlin.jvm.internal.Intrinsics.l(context, "context");
    }

    private final void b(float percent, boolean forward) {
        this.rect = new android.graphics.RectF(0.0f, 0.0f, e(percent, forward), getHeight());
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void d(vn.vinfast.charginguikit.ui.views.ViewDividerStep viewDividerStep, boolean z, android.animation.ValueAnimator valueAnimator) {
        kotlin.jvm.internal.Intrinsics.l(valueAnimator, "it");
        java.lang.Object animatedValue = valueAnimator.getAnimatedValue();
        kotlin.jvm.internal.Intrinsics.j(animatedValue, "null cannot be cast to non-null type kotlin.Float");
        viewDividerStep.b(((java.lang.Float) animatedValue).floatValue(), z);
        viewDividerStep.invalidate();
    }

    private final float e(float percent, boolean forward) {
        if (!forward) {
            percent = 100 - percent;
        }
        return (getWidth() * percent) / 100;
    }

    public final android.animation.Animator c(final boolean forward) {
        android.animation.ValueAnimator valueAnimatorOfFloat = android.animation.ValueAnimator.ofFloat(0.0f, 100.0f);
        valueAnimatorOfFloat.setDuration(300L);
        this.animator = valueAnimatorOfFloat;
        valueAnimatorOfFloat.addUpdateListener(new android.animation.ValueAnimator.AnimatorUpdateListener() { // from class: l6.e
            @Override // android.animation.ValueAnimator.AnimatorUpdateListener
            public final void onAnimationUpdate(android.animation.ValueAnimator valueAnimator) {
                vn.vinfast.charginguikit.ui.views.ViewDividerStep.d(this.a, forward, valueAnimator);
            }
        });
        android.animation.ValueAnimator valueAnimator = this.animator;
        if (valueAnimator != null) {
            valueAnimator.addListener(new android.animation.Animator.AnimatorListener(this) { // from class: vn.vinfast.charginguikit.ui.views.ViewDividerStep$getAnimator$$inlined$addListener$default$1
                @Override // android.animation.Animator.AnimatorListener
                public void onAnimationEnd(android.animation.Animator animator) {
                    kotlin.jvm.functions.Function0<kotlin.Unit> onAnimationEnd = this.a.getOnAnimationEnd();
                    if (onAnimationEnd != null) {
                        onAnimationEnd.invoke();
                    }
                }

                @Override // android.animation.Animator.AnimatorListener
                public void onAnimationStart(android.animation.Animator animator) {
                    kotlin.jvm.functions.Function0<kotlin.Unit> onAnimationStart = this.a.getOnAnimationStart();
                    if (onAnimationStart != null) {
                        onAnimationStart.invoke();
                    }
                }

                @Override // android.animation.Animator.AnimatorListener
                public void onAnimationCancel(android.animation.Animator animator) {
                }

                @Override // android.animation.Animator.AnimatorListener
                public void onAnimationRepeat(android.animation.Animator animator) {
                }
            });
        }
        return this.animator;
    }

    public final void f() {
        this.rect = null;
        invalidate();
    }

    @org.jetbrains.annotations.Nullable
    public final kotlin.jvm.functions.Function0<kotlin.Unit> getOnAnimationEnd() {
        return this.onAnimationEnd;
    }

    @org.jetbrains.annotations.Nullable
    public final kotlin.jvm.functions.Function0<kotlin.Unit> getOnAnimationStart() {
        return this.onAnimationStart;
    }

    @Override // android.view.View
    protected void onDetachedFromWindow() {
        android.animation.ValueAnimator valueAnimator = this.animator;
        if (valueAnimator != null) {
            valueAnimator.removeAllListeners();
        }
        android.animation.ValueAnimator valueAnimator2 = this.animator;
        if (valueAnimator2 != null) {
            valueAnimator2.cancel();
        }
        this.animator = null;
        super.onDetachedFromWindow();
    }

    @Override // android.view.View
    protected void onDraw(android.graphics.Canvas canvas) {
        kotlin.jvm.internal.Intrinsics.l(canvas, "canvas");
        super.onDraw(canvas);
        canvas.drawColor(getContext().getColor(vn.vinfast.charginguikit.R.color.colorDivider), android.graphics.PorterDuff.Mode.SRC_ATOP);
        android.graphics.RectF rectF = this.rect;
        if (rectF != null) {
            timber.log.Timber.a.a("Run Animation draw " + rectF, new java.lang.Object[0]);
            android.graphics.Paint paint = this.paint;
            kotlin.jvm.internal.Intrinsics.i(paint);
            canvas.drawRect(rectF, paint);
        }
    }

    public final void setOnAnimationEnd(@org.jetbrains.annotations.Nullable kotlin.jvm.functions.Function0<kotlin.Unit> function0) {
        this.onAnimationEnd = function0;
    }

    public final void setOnAnimationStart(@org.jetbrains.annotations.Nullable kotlin.jvm.functions.Function0<kotlin.Unit> function0) {
        this.onAnimationStart = function0;
    }

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    @kotlin.jvm.JvmOverloads
    public ViewDividerStep(@org.jetbrains.annotations.NotNull android.content.Context context, @org.jetbrains.annotations.Nullable android.util.AttributeSet attributeSet) {
        this(context, attributeSet, 0, 4, null);
        kotlin.jvm.internal.Intrinsics.l(context, "context");
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    @kotlin.jvm.JvmOverloads
    public ViewDividerStep(@org.jetbrains.annotations.NotNull android.content.Context context, @org.jetbrains.annotations.Nullable android.util.AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        kotlin.jvm.internal.Intrinsics.l(context, "context");
        android.graphics.Paint paint = new android.graphics.Paint();
        paint.setColor(context.getColor(vn.vinfast.charginguikit.R.color.white));
        paint.setAntiAlias(true);
        paint.setStrokeWidth(12.0f);
        this.paint = paint;
    }

    public /* synthetic */ ViewDividerStep(android.content.Context context, android.util.AttributeSet attributeSet, int i, int i2, kotlin.jvm.internal.DefaultConstructorMarker defaultConstructorMarker) {
        this(context, (i2 & 2) != 0 ? null : attributeSet, (i2 & 4) != 0 ? 0 : i);
    }
}
