package com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.AdLandingPageComponent.component.widget.verticalviewpager.adapter;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.memory.n;
import com.tencent.mm.plugin.sns.lucky.a.a;
import com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.h;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.al;
import com.tencent.mm.sdk.platformtools.d;
import com.tencent.mm.vfs.e;
import com.tencent.ytcommon.BuildConfig;

class ContentFragment$3 implements Runnable {
    final /* synthetic */ String bSt;
    final /* synthetic */ String hWi;
    final /* synthetic */ ContentFragment rdr;
    final /* synthetic */ String rds;

    ContentFragment$3(ContentFragment contentFragment, String str, String str2, String str3) {
        this.rdr = contentFragment;
        this.bSt = str;
        this.rds = str2;
        this.hWi = str3;
    }

    public final void run() {
        float f = 1.0f;
        Bitmap bitmap = null;
        AppMethodBeat.i(37618);
        ab.i("ContentFragment", "download bg ok path %s ", new Object[]{this.bSt});
        try {
            if (ContentFragment.d(this.rdr).rei) {
                ContentFragment.e(this.rdr);
                String gj = h.gj(this.rds, this.hWi + "_blurimg");
                if (e.ct(gj)) {
                    bitmap = BitmapFactory.decodeFile(gj);
                } else {
                    Bitmap decodeFile = d.decodeFile(this.bSt, null);
                    if (decodeFile != null) {
                        n a;
                        if (decodeFile.getHeight() < ContentFragment.f(this.rdr) || decodeFile.getWidth() < ContentFragment.g(this.rdr)) {
                            f = Math.max((((float) ContentFragment.g(this.rdr)) * 1.0f) / ((float) decodeFile.getWidth()), (1.0f * ((float) ContentFragment.f(this.rdr))) / ((float) decodeFile.getHeight()));
                        }
                        Bitmap a2 = d.a(decodeFile, f, f);
                        try {
                            a2 = Bitmap.createBitmap(a2, (a2.getWidth() - ContentFragment.g(this.rdr)) >>> 1, (a2.getHeight() - ContentFragment.f(this.rdr)) >>> 1, ContentFragment.g(this.rdr), ContentFragment.f(this.rdr));
                        } catch (OutOfMemoryError e) {
                            ab.printErrStackTrace("ContentFragment", e, BuildConfig.FLAVOR, new Object[0]);
                            a2 = null;
                        }
                        if (a2 != null) {
                            a = a.a(a2, gj, Color.argb(140, 0, 0, 0), 180);
                        } else {
                            a = null;
                        }
                        if (a != null) {
                            bitmap = a.Xi();
                        }
                    }
                }
            } else {
                bitmap = d.decodeFile(this.bSt, null);
            }
            al.d(new Runnable() {
                public final void run() {
                    AppMethodBeat.i(37617);
                    if (bitmap == null) {
                        ab.i("ContentFragment", "decode img fail, set bg color %s", new Object[]{ContentFragment$3.this.hWi});
                        ContentFragment.h(ContentFragment$3.this.rdr);
                        AppMethodBeat.o(37617);
                        return;
                    }
                    ab.i("ContentFragment", "set bg with bitmap");
                    ContentFragment.i(ContentFragment$3.this.rdr).put(ContentFragment$3.this.hWi, bitmap);
                    ContentFragment.a(ContentFragment$3.this.rdr, bitmap);
                    AppMethodBeat.o(37617);
                }
            });
            AppMethodBeat.o(37618);
        } catch (Exception e2) {
            ab.e("ContentFragment", "the backgroundCoverUrl is set error ,because " + e2.toString());
            AppMethodBeat.o(37618);
        }
    }
}
