package com.tencent.mm.plugin.appbrand.ui;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.kernel.g;
import com.tencent.mm.plugin.appbrand.config.AppBrandInitConfigWC;
import com.tencent.mm.plugin.appbrand.config.a.a;
import com.tencent.mm.plugin.appbrand.game.preload.e;
import com.tencent.mm.plugin.appbrand.game.preload.ui.BootstrapProgressBar;
import com.tencent.mm.plugin.appbrand.launching.j;
import com.tencent.mm.plugin.appbrand.o;
import com.tencent.mm.plugin.appbrand.widget.actionbar.f;
import com.tencent.mm.plugin.expt.a.a$a;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.al;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.ui.statusbar.b;
import com.tencent.mm.ui.widget.ThreeDotsLoadingView;
import java.util.Timer;
import org.xwalk.core.XWalkFeature;

@SuppressLint({"ViewConstructor"})
final class c extends b implements j, q {
    private o gOq;
    private ThreeDotsLoadingView iDW;
    private ImageView iFV;
    private ImageView iFW;
    private TextView iFX;
    private LinearLayout iFY;
    private com.tencent.mm.plugin.appbrand.widget.actionbar.b iFZ;
    private TextView iGa;
    private a.b iGb = a.b.hiK;
    private TextView iGc;
    private boolean iGd;
    private Runnable iGe = null;
    private RelativeLayout iGf;
    private boolean iGg = false;
    private boolean iGh = false;
    private boolean iGi = false;
    private int iGj;
    private boolean iGk = false;
    private int iGl = 30;
    private RelativeLayout iGm;
    private ImageView iGn;
    private BootstrapProgressBar iGo;
    private boolean iGp;
    private boolean iGq;
    private ImageView kU;

    public c(Context context, o oVar) {
        super(context);
        AppMethodBeat.i(132947);
        this.gOq = oVar;
        ab.i("MicroMsg.AppBrandGameUILoadingSplash", "init");
        setClickable(true);
        setLayoutParams(new LayoutParams(-1, -1));
        LayoutInflater.from(getContext()).inflate(2130968736, this);
        this.iGm = (RelativeLayout) findViewById(2131821382);
        this.iGn = (ImageView) findViewById(2131821383);
        this.iGo = (BootstrapProgressBar) findViewById(2131821384);
        e.aBD().cY(999, 1);
        if (((com.tencent.mm.plugin.expt.a.a) g.K(com.tencent.mm.plugin.expt.a.a.class)).a(a$a.clicfg_appbrand_game_splashscreen, false) && this.gOq != null) {
            long yz = bo.yz();
            AppBrandInitConfigWC atI = this.gOq.atI();
            String str = atI.hgL;
            if (com.tencent.magicbrush.c.isNullOrNil(str)) {
                e.aBD().cY(XWalkFeature.INTERFACE_GEO_LOCATION_PERMISSION, 0);
            } else {
                this.iGg = true;
                ab.i("MicroMsg.AppBrandGameUILoadingSplash", "loadingImgUrl:%s", new Object[]{str});
                e.aBD().cY(XWalkFeature.INTERFACE_GEO_LOCATION_PERMISSION, 1);
            }
            com.tencent.mm.ce.a.post(new 2(this, str, new 1(this, yz)));
            if (bo.isNullOrNil(atI.hgM)) {
                this.iGj = getContext().getResources().getColor(2131689689);
                this.iGo.setProgressColor(this.iGj);
            } else {
                this.iGj = Color.parseColor(atI.hgM);
                this.iGo.setProgressColor(this.iGj);
                ab.i("MicroMsg.AppBrandGameUILoadingSplash", "loadingProgressBarColor:%s", new Object[]{Integer.valueOf(this.iGj)});
            }
            al.n(new 3(this), 1000);
            al.n(new 4(this), 2000);
        }
        this.iGf = (RelativeLayout) findViewById(2131821373);
        this.kU = (ImageView) findViewById(2131821379);
        this.kU.setImageDrawable(com.tencent.mm.modelappbrand.a.a.abQ());
        this.iFX = (TextView) findViewById(2131821374);
        this.iFV = (ImageView) findViewById(2131821381);
        this.iDW = (ThreeDotsLoadingView) findViewById(2131821376);
        this.iFW = (ImageView) findViewById(2131821375);
        this.iFY = (LinearLayout) findViewById(2131821372);
        this.iGa = (TextView) findViewById(2131821377);
        this.iGc = (TextView) findViewById(2131821378);
        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) this.iDW.getLayoutParams();
        RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) this.iFW.getLayoutParams();
        RelativeLayout.LayoutParams layoutParams3 = (RelativeLayout.LayoutParams) this.iFV.getLayoutParams();
        this.iFZ = f.a.dh(getContext());
        LinearLayout.LayoutParams layoutParams4 = new LinearLayout.LayoutParams(-2, -2);
        layoutParams4.gravity = 21;
        layoutParams4.rightMargin = com.tencent.mm.bz.a.am(getContext(), 2131428004);
        layoutParams4.topMargin = com.tencent.mm.bz.a.am(getContext(), 2131428005);
        this.iFY.addView(this.iFZ.getActionView(), layoutParams4);
        if (this.gOq.atI().hgD == 1) {
            this.iFW.setVisibility(0);
        } else {
            this.iFW.setVisibility(8);
        }
        RelativeLayout.LayoutParams layoutParams5 = (RelativeLayout.LayoutParams) this.iGo.getLayoutParams();
        this.iGb = a.t(this.gOq.atM()).dI(a.ayQ());
        ab.i("MicroMsg.AppBrandGameUILoadingSplash", "mLastDeviceOrientation :%s", new Object[]{this.iGb});
        if (this.iGb == a.b.hiM || this.iGb == a.b.hiN || this.iGb == a.b.hiO || this.iGb == a.b.hiP) {
            if (this.iFW.getVisibility() == 0) {
                layoutParams.topMargin = com.tencent.mm.bz.a.am(getContext(), 2131428010);
                layoutParams3.bottomMargin = com.tencent.mm.bz.a.am(getContext(), 2131428006);
                layoutParams2.topMargin = com.tencent.mm.bz.a.am(getContext(), 2131428013);
                this.iFW.setLayoutParams(layoutParams2);
            } else {
                layoutParams.topMargin = com.tencent.mm.bz.a.am(getContext(), 2131428014);
                layoutParams3.bottomMargin = com.tencent.mm.bz.a.am(getContext(), 2131428007);
            }
            layoutParams5.bottomMargin = com.tencent.mm.bz.a.am(getContext(), 2131428000);
            layoutParams5.width = com.tencent.mm.bz.a.am(getContext(), 2131428001);
        } else {
            if (this.iFW.getVisibility() == 0) {
                layoutParams.topMargin = com.tencent.mm.bz.a.am(getContext(), 2131428012);
                layoutParams3.bottomMargin = com.tencent.mm.bz.a.am(getContext(), 2131428007);
                layoutParams2.topMargin = com.tencent.mm.bz.a.am(getContext(), 2131428015);
                this.iFW.setLayoutParams(layoutParams2);
            } else {
                layoutParams.topMargin = com.tencent.mm.bz.a.am(getContext(), 2131428011);
                layoutParams3.bottomMargin = com.tencent.mm.bz.a.am(getContext(), 2131428007);
            }
            layoutParams5.width = com.tencent.mm.bz.a.am(getContext(), 2131428003);
            layoutParams5.bottomMargin = com.tencent.mm.bz.a.am(getContext(), 2131428002);
        }
        this.iDW.setLayoutParams(layoutParams);
        this.iGo.setLayoutParams(layoutParams5);
        this.iFV.setLayoutParams(layoutParams3);
        K(-1, true);
        this.iFZ.setBackgroundColor(0);
        this.iFZ.setForegroundStyle("black");
        this.iFZ.setNavBackOrClose(false);
        7 7 = new 7(this);
        this.iFZ.setCloseButtonClickListener(7);
        this.iFZ.setBackButtonClickListener(7);
        n.q(getContext(), true);
        if (this.iGg) {
            this.iDW.setVisibility(4);
            this.iGa.setVisibility(4);
            AppMethodBeat.o(132947);
            return;
        }
        this.iDW.dKS();
        AppMethodBeat.o(132947);
    }

    public final void cz(String str, String str2) {
        AppMethodBeat.i(132948);
        com.tencent.mm.modelappbrand.a.b.abR().a(this.kU, str, null, com.tencent.mm.modelappbrand.a.f.fqH);
        this.iFX.setText(str2);
        AppMethodBeat.o(132948);
    }

    public final void aHS() {
        AppMethodBeat.i(132949);
        ab.w("MicroMsg.AppBrandGameUILoadingSplash", "animateHide");
        post(new 5(this));
        AppMethodBeat.o(132949);
    }

    public final void aHT() {
    }

    public final View getView() {
        return this;
    }

    /* Access modifiers changed, original: protected|final */
    public final void onLayout(boolean z, int i, int i2, int i3, int i4) {
        AppMethodBeat.i(132950);
        super.onLayout(z, i, i2, i3, i4);
        a.b dI = a.t(this.gOq.atM()).dI(a.ayQ());
        if (dI != this.iGb) {
            this.iGb = dI;
            RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) this.iDW.getLayoutParams();
            RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) this.iFW.getLayoutParams();
            RelativeLayout.LayoutParams layoutParams3 = (RelativeLayout.LayoutParams) this.iGo.getLayoutParams();
            RelativeLayout.LayoutParams layoutParams4 = (RelativeLayout.LayoutParams) this.iFV.getLayoutParams();
            if (dI == a.b.hiM || dI == a.b.hiN || dI == a.b.hiO || dI == a.b.hiP) {
                if (this.iFW.getVisibility() == 0) {
                    layoutParams.topMargin = com.tencent.mm.bz.a.am(getContext(), 2131428010);
                    layoutParams4.bottomMargin = com.tencent.mm.bz.a.am(getContext(), 2131428006);
                    layoutParams2.topMargin = com.tencent.mm.bz.a.am(getContext(), 2131428013);
                    this.iFW.setLayoutParams(layoutParams2);
                } else {
                    layoutParams.topMargin = com.tencent.mm.bz.a.am(getContext(), 2131428014);
                    layoutParams4.bottomMargin = com.tencent.mm.bz.a.am(getContext(), 2131428007);
                }
                layoutParams3.width = com.tencent.mm.bz.a.am(getContext(), 2131428001);
                layoutParams3.bottomMargin = com.tencent.mm.bz.a.am(getContext(), 2131428000);
            } else {
                if (this.iFW.getVisibility() == 0) {
                    layoutParams.topMargin = com.tencent.mm.bz.a.am(getContext(), 2131428012);
                    layoutParams4.bottomMargin = com.tencent.mm.bz.a.am(getContext(), 2131428007);
                    layoutParams2.topMargin = com.tencent.mm.bz.a.am(getContext(), 2131428015);
                    this.iFW.setLayoutParams(layoutParams2);
                } else {
                    layoutParams.topMargin = com.tencent.mm.bz.a.am(getContext(), 2131428011);
                    layoutParams4.bottomMargin = com.tencent.mm.bz.a.am(getContext(), 2131428007);
                }
                layoutParams3.width = com.tencent.mm.bz.a.am(getContext(), 2131428003);
                layoutParams3.bottomMargin = com.tencent.mm.bz.a.am(getContext(), 2131428002);
            }
            this.iGo.setLayoutParams(layoutParams3);
            this.iDW.setLayoutParams(layoutParams);
            this.iFV.setLayoutParams(layoutParams4);
            requestLayout();
        }
        AppMethodBeat.o(132950);
    }

    public final void setProgress(int i) {
        AppMethodBeat.i(132951);
        if (this.iGg) {
            if (this.iGh || !this.iGk) {
                if (i < 100) {
                    if (this.iGm.getVisibility() == 0) {
                        this.iGo.setProgress((float) (i / 2));
                        AppMethodBeat.o(132951);
                        return;
                    }
                } else if (!this.iGq) {
                    this.iGq = true;
                    new Timer(true).scheduleAtFixedRate(new a(this), 0, (long) (XWalkFeature.INTERFACE_GEO_LOCATION_PERMISSION / this.iGl));
                }
            } else if (i < 100) {
                this.iGa.setText(String.format("%d%%", new Object[]{Integer.valueOf(i / 2)}));
                AppMethodBeat.o(132951);
                return;
            } else if (!this.iGp) {
                this.iGp = true;
                new Timer(true).scheduleAtFixedRate(new b(this), 0, 100);
                AppMethodBeat.o(132951);
                return;
            }
        } else if (i < 100) {
            this.iGa.setText(String.format("%d%%", new Object[]{Integer.valueOf(i / 2)}));
            AppMethodBeat.o(132951);
            return;
        } else if (!this.iGp) {
            this.iGp = true;
            new Timer(true).scheduleAtFixedRate(new b(this), 0, 50);
            AppMethodBeat.o(132951);
            return;
        }
        AppMethodBeat.o(132951);
    }

    public final void nm(final int i) {
        AppMethodBeat.i(132952);
        al.d(new Runnable() {
            public final void run() {
                AppMethodBeat.i(132941);
                ab.i("MicroMsg.AppBrandGameUILoadingSplash", "onDataTransferState  state=" + i);
                if (i == 3) {
                    if (c.this.iGd) {
                        c.this.iGc.setVisibility(0);
                        c.this.iGc.setText(2131297094);
                        c.this.iGa.setVisibility(4);
                        AppMethodBeat.o(132941);
                        return;
                    }
                    c.this.iGe = this;
                }
                AppMethodBeat.o(132941);
            }
        });
        AppMethodBeat.o(132952);
    }

    static /* synthetic */ void d(c cVar) {
        AppMethodBeat.i(132953);
        if (cVar.iGi && cVar.iGh) {
            ab.i("MicroMsg.AppBrandGameUILoadingSplash", "showCutomView");
            cVar.iGm.setVisibility(0);
            cVar.iGf.setVisibility(4);
            cVar.iGo.bringToFront();
            cVar.iFY.bringToFront();
            AppMethodBeat.o(132953);
            return;
        }
        AppMethodBeat.o(132953);
    }

    static /* synthetic */ void l(c cVar) {
        AppMethodBeat.i(132954);
        cVar.iDW.dKS();
        AppMethodBeat.o(132954);
    }
}
