package com.vinfast.companion.core.utils.glideTransformation;

/* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
/* JADX INFO: loaded from: E:\ios\vf_dex\classes15.dex */
@kotlin.Metadata(d1 = {"\u0000<\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0007\n\u0002\b\u0006\u0018\u00002\u00020\u0001:\u0002\u001c\u001dB/\u0012\u0006\u0010\u0003\u001a\u00020\u0002\u0012\b\b\u0002\u0010\u0005\u001a\u00020\u0004\u0012\b\b\u0002\u0010\u0006\u001a\u00020\u0004\u0012\n\b\u0002\u0010\b\u001a\u0004\u0018\u00010\u0007¢\u0006\u0004\b\t\u0010\nJ\u0017\u0010\u000e\u001a\u00020\r2\u0006\u0010\f\u001a\u00020\u000bH\u0016¢\u0006\u0004\b\u000e\u0010\u000fR\u0014\u0010\u0005\u001a\u00020\u00048\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0010\u0010\u0011R\u0016\u0010\b\u001a\u0004\u0018\u00010\u00078\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0012\u0010\u0013R\u001a\u0010\u0017\u001a\b\u0012\u0004\u0012\u00020\u00020\u00148\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0015\u0010\u0016R\u0016\u0010\u001b\u001a\u00020\u00188\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\u0019\u0010\u001a¨\u0006\u001e"}, d2 = {"Lcom/vinfast/companion/core/utils/glideTransformation/GlideImageGetter;", "Landroid/text/Html$ImageGetter;", "Landroidx/appcompat/widget/AppCompatTextView;", "textView", "", "matchParentWidth", "densityAware", "Lcom/vinfast/companion/core/utils/glideTransformation/GlideImageGetter$HtmlImagesHandler;", "imagesHandler", "<init>", "(Landroidx/appcompat/widget/AppCompatTextView;ZZLcom/vinfast/companion/core/utils/glideTransformation/GlideImageGetter$HtmlImagesHandler;)V", "", "source", "Landroid/graphics/drawable/Drawable;", "getDrawable", "(Ljava/lang/String;)Landroid/graphics/drawable/Drawable;", "a", "Z", "b", "Lcom/vinfast/companion/core/utils/glideTransformation/GlideImageGetter$HtmlImagesHandler;", "Ljava/lang/ref/WeakReference;", "c", "Ljava/lang/ref/WeakReference;", "container", "", "d", "F", "density", "BitmapDrawablePlaceholder", "HtmlImagesHandler", "core_release"}, k = 1, mv = {2, 2, 0}, xi = 48)
public final class GlideImageGetter implements android.text.Html.ImageGetter {

    /* JADX INFO: renamed from: a, reason: from kotlin metadata */
    private final boolean matchParentWidth;

    /* JADX INFO: renamed from: b, reason: from kotlin metadata */
    private final com.vinfast.companion.core.utils.glideTransformation.GlideImageGetter.HtmlImagesHandler imagesHandler;

    /* JADX INFO: renamed from: c, reason: from kotlin metadata */
    private final java.lang.ref.WeakReference container;

    /* JADX INFO: renamed from: d, reason: from kotlin metadata */
    private float density;

    /* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
    @kotlin.Metadata(d1 = {"\u0000\u0016\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0003\bf\u0018\u00002\u00020\u0001J\u0019\u0010\u0005\u001a\u00020\u00042\b\u0010\u0003\u001a\u0004\u0018\u00010\u0002H&¢\u0006\u0004\b\u0005\u0010\u0006¨\u0006\u0007À\u0006\u0003"}, d2 = {"Lcom/vinfast/companion/core/utils/glideTransformation/GlideImageGetter$HtmlImagesHandler;", "", "", "uri", "", "a", "(Ljava/lang/String;)V", "core_release"}, k = 1, mv = {2, 2, 0}, xi = 48)
    public interface HtmlImagesHandler {
        void a(java.lang.String uri);
    }

    public GlideImageGetter(androidx.appcompat.widget.AppCompatTextView appCompatTextView, boolean z, boolean z2, com.vinfast.companion.core.utils.glideTransformation.GlideImageGetter.HtmlImagesHandler htmlImagesHandler) {
        androidx.appcompat.widget.AppCompatTextView appCompatTextView2;
        kotlin.jvm.internal.Intrinsics.l(appCompatTextView, "textView");
        this.matchParentWidth = z;
        this.imagesHandler = htmlImagesHandler;
        java.lang.ref.WeakReference weakReference = new java.lang.ref.WeakReference(appCompatTextView);
        this.container = weakReference;
        this.density = 1.0f;
        if (!z2 || (appCompatTextView2 = (androidx.appcompat.widget.AppCompatTextView) weakReference.get()) == null) {
            return;
        }
        this.density = appCompatTextView2.getResources().getDisplayMetrics().density;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void e(androidx.appcompat.widget.AppCompatTextView appCompatTextView, java.lang.String str, com.vinfast.companion.core.utils.glideTransformation.GlideImageGetter.BitmapDrawablePlaceholder bitmapDrawablePlaceholder) {
        com.bumptech.glide.Glide.t(appCompatTextView.getContext()).f().I0(str).A0(bitmapDrawablePlaceholder);
    }

    @Override // android.text.Html.ImageGetter
    public android.graphics.drawable.Drawable getDrawable(final java.lang.String source) {
        kotlin.jvm.internal.Intrinsics.l(source, "source");
        com.vinfast.companion.core.utils.glideTransformation.GlideImageGetter.HtmlImagesHandler htmlImagesHandler = this.imagesHandler;
        if (htmlImagesHandler != null) {
            htmlImagesHandler.a(source);
        }
        final com.vinfast.companion.core.utils.glideTransformation.GlideImageGetter.BitmapDrawablePlaceholder bitmapDrawablePlaceholder = new com.vinfast.companion.core.utils.glideTransformation.GlideImageGetter.BitmapDrawablePlaceholder();
        final androidx.appcompat.widget.AppCompatTextView appCompatTextView = (androidx.appcompat.widget.AppCompatTextView) this.container.get();
        if (appCompatTextView != null) {
            appCompatTextView.post(new java.lang.Runnable() { // from class: com.vinfast.companion.core.utils.glideTransformation.a
                @Override // java.lang.Runnable
                public final void run() {
                    com.vinfast.companion.core.utils.glideTransformation.GlideImageGetter.e(appCompatTextView, source, bitmapDrawablePlaceholder);
                }
            });
        }
        return bitmapDrawablePlaceholder;
    }

    public /* synthetic */ GlideImageGetter(androidx.appcompat.widget.AppCompatTextView appCompatTextView, boolean z, boolean z2, com.vinfast.companion.core.utils.glideTransformation.GlideImageGetter.HtmlImagesHandler htmlImagesHandler, int i, kotlin.jvm.internal.DefaultConstructorMarker defaultConstructorMarker) {
        this(appCompatTextView, (i & 2) != 0 ? false : z, (i & 4) != 0 ? false : z2, (i & 8) != 0 ? null : htmlImagesHandler);
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
    @kotlin.Metadata(d1 = {"\u0000B\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u000e\b\u0082\u0004\u0018\u00002\u00020\u00012\b\u0012\u0004\u0012\u00020\u00030\u0002B\u0007¢\u0006\u0004\b\u0004\u0010\u0005J\u0017\u0010\t\u001a\u00020\b2\u0006\u0010\u0007\u001a\u00020\u0006H\u0016¢\u0006\u0004\b\t\u0010\nJ\u0019\u0010\r\u001a\u00020\b2\b\u0010\f\u001a\u0004\u0018\u00010\u000bH\u0016¢\u0006\u0004\b\r\u0010\u000eJ\u0019\u0010\u0010\u001a\u00020\b2\b\u0010\u000f\u001a\u0004\u0018\u00010\u000bH\u0016¢\u0006\u0004\b\u0010\u0010\u000eJ)\u0010\u0014\u001a\u00020\b2\u0006\u0010\u0011\u001a\u00020\u00032\u0010\u0010\u0013\u001a\f\u0012\u0006\b\u0000\u0012\u00020\u0003\u0018\u00010\u0012H\u0016¢\u0006\u0004\b\u0014\u0010\u0015J\u0019\u0010\u0016\u001a\u00020\b2\b\u0010\f\u001a\u0004\u0018\u00010\u000bH\u0016¢\u0006\u0004\b\u0016\u0010\u000eJ\u0017\u0010\u0019\u001a\u00020\b2\u0006\u0010\u0018\u001a\u00020\u0017H\u0016¢\u0006\u0004\b\u0019\u0010\u001aJ\u0017\u0010\u001c\u001a\u00020\b2\u0006\u0010\u001b\u001a\u00020\u0017H\u0016¢\u0006\u0004\b\u001c\u0010\u001aJ\u0019\u0010\u001f\u001a\u00020\b2\b\u0010\u001e\u001a\u0004\u0018\u00010\u001dH\u0016¢\u0006\u0004\b\u001f\u0010 J\u0011\u0010!\u001a\u0004\u0018\u00010\u001dH\u0016¢\u0006\u0004\b!\u0010\"J\u000f\u0010#\u001a\u00020\bH\u0016¢\u0006\u0004\b#\u0010$J\u000f\u0010%\u001a\u00020\bH\u0016¢\u0006\u0004\b%\u0010$J\u000f\u0010&\u001a\u00020\bH\u0016¢\u0006\u0004\b&\u0010$R(\u0010*\u001a\u0004\u0018\u00010\u000b2\b\u0010'\u001a\u0004\u0018\u00010\u000b8\u0002@BX\u0082\u000e¢\u0006\f\n\u0004\b!\u0010(\"\u0004\b)\u0010\u000e¨\u0006+"}, d2 = {"Lcom/vinfast/companion/core/utils/glideTransformation/GlideImageGetter$BitmapDrawablePlaceholder;", "Landroid/graphics/drawable/BitmapDrawable;", "Lcom/bumptech/glide/request/target/Target;", "Landroid/graphics/Bitmap;", "<init>", "(Lcom/vinfast/companion/core/utils/glideTransformation/GlideImageGetter;)V", "Landroid/graphics/Canvas;", "canvas", "", "draw", "(Landroid/graphics/Canvas;)V", "Landroid/graphics/drawable/Drawable;", "placeholderDrawable", "g", "(Landroid/graphics/drawable/Drawable;)V", "errorDrawable", "i", "bitmap", "Lcom/bumptech/glide/request/transition/Transition;", "transition", "c", "(Landroid/graphics/Bitmap;Lcom/bumptech/glide/request/transition/Transition;)V", "d", "Lcom/bumptech/glide/request/target/SizeReadyCallback;", "sizeReadyCallback", "j", "(Lcom/bumptech/glide/request/target/SizeReadyCallback;)V", "cb", "b", "Lcom/bumptech/glide/request/Request;", "request", "h", "(Lcom/bumptech/glide/request/Request;)V", "a", "()Lcom/bumptech/glide/request/Request;", "onStart", "()V", "onStop", "onDestroy", "value", "Landroid/graphics/drawable/Drawable;", "f", "drawable", "core_release"}, k = 1, mv = {2, 2, 0}, xi = 48)
    final class BitmapDrawablePlaceholder extends android.graphics.drawable.BitmapDrawable implements com.bumptech.glide.request.target.Target<android.graphics.Bitmap> {

        /* JADX INFO: renamed from: a, reason: from kotlin metadata */
        private android.graphics.drawable.Drawable drawable;

        /* JADX WARN: Illegal instructions before constructor call */
        public BitmapDrawablePlaceholder() {
            androidx.appcompat.widget.AppCompatTextView appCompatTextView = (androidx.appcompat.widget.AppCompatTextView) com.vinfast.companion.core.utils.glideTransformation.GlideImageGetter.this.container.get();
            super(appCompatTextView != null ? appCompatTextView.getResources() : null, android.graphics.Bitmap.createBitmap(1, 1, android.graphics.Bitmap.Config.ARGB_8888));
        }

        private final void f(android.graphics.drawable.Drawable drawable) {
            this.drawable = drawable;
            if (drawable != null) {
                com.vinfast.companion.core.utils.glideTransformation.GlideImageGetter glideImageGetter = com.vinfast.companion.core.utils.glideTransformation.GlideImageGetter.this;
                int intrinsicWidth = (int) (drawable.getIntrinsicWidth() * glideImageGetter.density);
                int intrinsicHeight = (int) (drawable.getIntrinsicHeight() * glideImageGetter.density);
                java.lang.Object obj = glideImageGetter.container.get();
                kotlin.jvm.internal.Intrinsics.i(obj);
                int measuredWidth = ((androidx.appcompat.widget.AppCompatTextView) obj).getMeasuredWidth();
                if (intrinsicWidth > measuredWidth || glideImageGetter.matchParentWidth) {
                    int i = (intrinsicHeight * measuredWidth) / intrinsicWidth;
                    drawable.setBounds(0, 0, measuredWidth, i);
                    setBounds(0, 0, measuredWidth, i);
                } else {
                    drawable.setBounds(0, 0, intrinsicWidth, intrinsicHeight);
                    setBounds(0, 0, intrinsicWidth, intrinsicHeight);
                }
                androidx.appcompat.widget.AppCompatTextView appCompatTextView = (androidx.appcompat.widget.AppCompatTextView) glideImageGetter.container.get();
                if (appCompatTextView != null) {
                    androidx.appcompat.widget.AppCompatTextView appCompatTextView2 = (androidx.appcompat.widget.AppCompatTextView) glideImageGetter.container.get();
                    appCompatTextView.setText(appCompatTextView2 != null ? appCompatTextView2.getText() : null);
                }
            }
        }

        public com.bumptech.glide.request.Request a() {
            return null;
        }

        public void b(com.bumptech.glide.request.target.SizeReadyCallback cb) {
            kotlin.jvm.internal.Intrinsics.l(cb, "cb");
        }

        /* JADX INFO: renamed from: c, reason: merged with bridge method [inline-methods] */
        public void e(android.graphics.Bitmap bitmap, com.bumptech.glide.request.transition.Transition transition) {
            kotlin.jvm.internal.Intrinsics.l(bitmap, "bitmap");
            java.lang.Object obj = com.vinfast.companion.core.utils.glideTransformation.GlideImageGetter.this.container.get();
            kotlin.jvm.internal.Intrinsics.i(obj);
            f(new android.graphics.drawable.BitmapDrawable(((androidx.appcompat.widget.AppCompatTextView) obj).getResources(), bitmap));
        }

        public void d(android.graphics.drawable.Drawable placeholderDrawable) {
            if (placeholderDrawable != null) {
                f(placeholderDrawable);
            }
        }

        @Override // android.graphics.drawable.BitmapDrawable, android.graphics.drawable.Drawable
        public void draw(android.graphics.Canvas canvas) {
            kotlin.jvm.internal.Intrinsics.l(canvas, "canvas");
            android.graphics.drawable.Drawable drawable = this.drawable;
            if (drawable != null) {
                drawable.draw(canvas);
            }
        }

        public void g(android.graphics.drawable.Drawable placeholderDrawable) {
            if (placeholderDrawable != null) {
                f(placeholderDrawable);
            }
        }

        public void i(android.graphics.drawable.Drawable errorDrawable) {
            if (errorDrawable != null) {
                f(errorDrawable);
            }
        }

        public void j(com.bumptech.glide.request.target.SizeReadyCallback sizeReadyCallback) {
            kotlin.jvm.internal.Intrinsics.l(sizeReadyCallback, "sizeReadyCallback");
            sizeReadyCallback.e(Integer.MIN_VALUE, Integer.MIN_VALUE);
        }

        public void onDestroy() {
        }

        public void onStart() {
        }

        public void onStop() {
        }

        public void h(com.bumptech.glide.request.Request request) {
        }
    }
}
