package com.tencent.mm.plugin.sns.ui.c.a;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout.LayoutParams;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.plugin.sight.decode.a.b.e;
import com.tencent.mm.plugin.sight.decode.ui.SightPlayImageView;
import com.tencent.mm.plugin.sns.a.b.g;
import com.tencent.mm.plugin.sns.data.i;
import com.tencent.mm.plugin.sns.model.af;
import com.tencent.mm.plugin.sns.model.an;
import com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.f;
import com.tencent.mm.plugin.sns.storage.AdLandingPagesStorage.h;
import com.tencent.mm.plugin.sns.storage.n;
import com.tencent.mm.plugin.sns.ui.MaskImageView;
import com.tencent.mm.plugin.sns.ui.aj;
import com.tencent.mm.plugin.sns.ui.widget.SnsCardAdTagListView;
import com.tencent.mm.pluginsdk.ui.e.j;
import com.tencent.mm.protocal.protobuf.TimeLineObject;
import com.tencent.mm.protocal.protobuf.bau;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.sdk.platformtools.d;
import com.tencent.mm.storage.az;
import com.tencent.mm.ui.widget.MMPinProgressBtn;
import com.tencent.mm.ui.widget.QImageView;
import com.tencent.mm.ui.widget.b.a;

public final class b extends a {
    private Context context;
    private a jMO;
    public TextView rGE;
    public TextView rGF;
    public View rGG;
    public Button rGH;
    public Button rGI;
    public View rGJ;
    public MaskImageView rGK;
    public SnsCardAdTagListView rGL;
    public View rGM;
    public View rGN;
    public View rGO;
    g rqn;

    public b(TimeLineObject timeLineObject, n nVar, com.tencent.mm.plugin.sns.ui.d.b bVar, g gVar) {
        this.timeLineObject = timeLineObject;
        this.ros = nVar;
        this.rqo = bVar;
        this.rqn = gVar;
    }

    public final void g(View view, View view2) {
        AppMethodBeat.i(40091);
        this.contentView = view;
        this.rpP = view2;
        this.context = view.getContext();
        this.rGN = view.findViewById(2131827604);
        this.rGO = view.findViewById(2131827607);
        this.rGG = view.findViewById(2131827611);
        this.rGG.setVisibility(8);
        this.rGJ = view.findViewById(2131827614);
        this.rGJ.setVisibility(8);
        this.rGK = (MaskImageView) view.findViewById(2131827605);
        this.rGH = (Button) view.findViewById(2131827612);
        this.rGI = (Button) view.findViewById(2131827613);
        com.tencent.mm.plugin.sns.storage.a cqq = this.ros.cqq();
        if (!(cqq == null || !cqq.coI() || this.ros.crg())) {
            this.rGJ.setVisibility(0);
        }
        this.rGF = (TextView) view.findViewById(2131827609);
        this.rGF.setClickable(false);
        this.rGF.setLongClickable(false);
        WindowManager windowManager = (WindowManager) this.context.getSystemService("window");
        int min = ((((Math.min(windowManager.getDefaultDisplay().getWidth(), windowManager.getDefaultDisplay().getHeight()) - com.tencent.mm.bz.a.al(this.context, 2131428663)) - com.tencent.mm.bz.a.al(this.context, 2131427865)) - this.context.getResources().getDimensionPixelSize(2131427812)) - this.context.getResources().getDimensionPixelSize(2131427812)) - this.context.getResources().getDimensionPixelSize(2131427858);
        LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
        layoutParams.topMargin = this.context.getResources().getDimensionPixelOffset(2131427796);
        layoutParams.bottomMargin = 0;
        layoutParams.width = min;
        layoutParams.height = -2;
        view.setLayoutParams(layoutParams);
        view.setBackground(this.context.getResources().getDrawable(2130840250));
        this.rGE = (TextView) view.findViewById(2131827608);
        this.rGE.setClickable(false);
        this.rGE.setLongClickable(false);
        if (bo.isNullOrNil(this.ros.cqo().qUS)) {
            this.rGE.setVisibility(8);
        } else {
            this.rGE.setText(this.ros.cqo().qUS + " ");
            j.h(this.rGE, 2);
            this.rGE.setVisibility(0);
        }
        String str = bo.isNullOrNil(this.ros.cqo().qUT) ? this.timeLineObject.xfF : this.ros.cqo().qUT;
        if (bo.isNullOrNil(str)) {
            this.rGF.setVisibility(8);
        } else {
            this.rGF.setText(str + " ");
            j.h(this.rGF, 2);
            this.rGF.setVisibility(0);
        }
        this.jMO = new a(this.context);
        this.jMO.c(view, this.rqo.rJZ, this.rqo.rJH);
        if (this.ros.cqo().coR() || this.ros.cqo().coS()) {
            this.rGG.setVisibility(0);
            G(this.ros);
        } else {
            this.rGG.setVisibility(8);
        }
        this.rGD = new aj();
        this.rGD.rnt = view.findViewById(2131827606);
        this.rGD.rns = this.rGD.rnt;
        this.rGD.rnt.setOnClickListener(this.rqo.rKe);
        this.rGD.qzM = (com.tencent.mm.plugin.sight.decode.a.a) this.rGD.rnt.findViewById(2131820629);
        this.rGD.raP = (ImageView) this.rGD.rnt.findViewById(2131820981);
        this.rGD.rnu = (MMPinProgressBtn) this.rGD.rnt.findViewById(2131821370);
        this.rGD.rnv = (TextView) this.rGD.rnt.findViewById(2131827571);
        this.rGD.raQ = (TextView) this.rGD.rnt.findViewById(2131827572);
        RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) this.rGK.getLayoutParams();
        layoutParams2.leftMargin = com.tencent.mm.bz.a.fromDPToPix(this.context, 10);
        layoutParams2.rightMargin = com.tencent.mm.bz.a.fromDPToPix(this.context, 10);
        layoutParams2.topMargin = com.tencent.mm.bz.a.fromDPToPix(this.context, 10);
        layoutParams2.bottomMargin = com.tencent.mm.bz.a.fromDPToPix(this.context, 10);
        this.rGK.setLayoutParams(layoutParams2);
        layoutParams2 = (RelativeLayout.LayoutParams) this.rGD.rns.getLayoutParams();
        layoutParams2.leftMargin = com.tencent.mm.bz.a.al(this.context, 2131427796);
        layoutParams2.rightMargin = com.tencent.mm.bz.a.al(this.context, 2131427796);
        layoutParams2.topMargin = com.tencent.mm.bz.a.fromDPToPix(this.context, 10);
        layoutParams2.bottomMargin = com.tencent.mm.bz.a.al(this.context, 2131427796);
        this.rGD.rns.setLayoutParams(layoutParams2);
        this.rGM = view.findViewById(2131827874);
        layoutParams2 = (RelativeLayout.LayoutParams) this.rGM.getLayoutParams();
        layoutParams2.leftMargin = com.tencent.mm.bz.a.fromDPToPix(this.context, 10);
        layoutParams2.rightMargin = com.tencent.mm.bz.a.fromDPToPix(this.context, 10);
        layoutParams2.topMargin = com.tencent.mm.bz.a.fromDPToPix(this.context, 10);
        this.rGM.setLayoutParams(layoutParams2);
        this.rGL = (SnsCardAdTagListView) this.contentView.findViewById(2131827610);
        this.rGL.setActivityContext((Activity) this.context);
        this.rGL.removeAllViews();
        if (this.ros.cqo().qUW.size() > 0) {
            this.rGL.setVisibility(0);
            this.rGL.setTagSpace(com.tencent.mm.bz.a.fromDPToPix(this.context, 6));
            this.rGL.dB(this.ros.cqo().qUW);
        }
        if (!bo.isNullOrNil(this.ros.cqo().qUU)) {
            this.rGM.setVisibility(0);
            this.rGM.findViewById(2131827876).setVisibility(0);
            ((TextView) this.rGM.findViewById(2131827876)).setText(this.ros.cqo().qUU);
        }
        if (!bo.isNullOrNil(this.ros.cqo().qUV)) {
            h.a(this.ros.cqo().qUV, new f.a() {
                public final void cpu() {
                }

                public final void cmD() {
                }

                public final void YJ(String str) {
                    AppMethodBeat.i(40090);
                    if (!bo.isNullOrNil(str)) {
                        Bitmap decodeFile = d.decodeFile(str, null);
                        if (decodeFile != null) {
                            b.this.rGM.setVisibility(0);
                            ImageView imageView = (ImageView) b.this.rGM.findViewById(2131827875);
                            imageView.setImageBitmap(decodeFile);
                            imageView.setVisibility(0);
                        }
                    }
                    AppMethodBeat.o(40090);
                }
            });
        }
        this.jMO.c(view, this.rqo.rJZ, this.rqo.rJH);
        this.rGK.setVisibility(8);
        this.rGK.setScaleType(QImageView.a.zNT);
        this.rGD.rns.setVisibility(8);
        ((SightPlayImageView) this.rGD.qzM).qyI = true;
        ((SightPlayImageView) this.rGD.qzM).setScaleType(QImageView.a.zNT);
        view.setBackgroundResource(2130840250);
        view.setOnClickListener(this.rqo.rKn);
        AppMethodBeat.o(40091);
    }

    public final void refreshView() {
        bau bau;
        AppMethodBeat.i(40092);
        this.ros = com.tencent.mm.plugin.sns.storage.h.YS(this.ros.cqA());
        ab.i("MicroMsg.CardAdDetailItemView", "refreshView");
        G(this.ros);
        this.rGD.raQ.setVisibility(8);
        com.tencent.mm.plugin.sns.model.g cnC = af.cnC();
        if (this.timeLineObject.xfI == null || this.timeLineObject.xfI.wbK.size() <= 0) {
            bau = null;
        } else {
            bau = (bau) this.timeLineObject.xfI.wbK.get(0);
        }
        int width = ((WindowManager) this.context.getSystemService("window")).getDefaultDisplay().getWidth();
        if (bau != null) {
            width = (((((width - com.tencent.mm.bz.a.fromDPToPix(this.context, 50)) - this.context.getResources().getDimensionPixelSize(2131427812)) - this.context.getResources().getDimensionPixelSize(2131427812)) - this.context.getResources().getDimensionPixelSize(2131427858)) - this.context.getResources().getDimensionPixelSize(2131427796)) - this.context.getResources().getDimensionPixelSize(2131427796);
            int i = (int) ((((float) width) * bau.wEK.wFy) / bau.wEK.wFx);
            if (this.timeLineObject.xfI.wbJ == 1) {
                ViewGroup.LayoutParams layoutParams = this.rGK.getLayoutParams();
                layoutParams.width = width;
                layoutParams.height = i;
                this.rGK.setLayoutParams(layoutParams);
                af.cnC().b(bau, this.rGK, -1, this.context.hashCode(), az.xYT);
                this.rGK.setVisibility(0);
                this.rGK.setTag(this);
                this.contentView.setTag(this);
                this.rGH.setTag(this);
                this.rGI.setTag(this);
                this.rGK.setOnClickListener(this.rqo.rjy);
                this.jMO.c(this.rGK, this.rqo.rJZ, this.rqo.rJH);
                AppMethodBeat.o(40092);
                return;
            } else if (this.timeLineObject.xfI.wbJ == 5 || this.timeLineObject.xfI.wbJ == 15) {
                this.rGD.rns.setVisibility(0);
                this.jMO.c(this.rGD.rnt, this.rqo.rJZ, this.rqo.rJH);
                ViewGroup.LayoutParams layoutParams2 = this.rGD.rns.getLayoutParams();
                layoutParams2.width = width;
                layoutParams2.height = i;
                this.rGD.rns.setLayoutParams(layoutParams2);
                this.rGD.qzM.fi(width, i);
                this.rGD.qzM.setOnCompletionListener(new e() {
                    public final void c(com.tencent.mm.plugin.sight.decode.a.b bVar, int i) {
                        AppMethodBeat.i(40088);
                        if (!(i == -1 || b.this.rqn == null)) {
                            b.this.rqn.u(b.this.ros.field_snsId, false);
                        }
                        AppMethodBeat.o(40088);
                    }
                });
                if (!(this.rqn == null || this.rqn.jO(this.ros.field_snsId))) {
                    this.rGD.qzM.setOnDecodeDurationListener(new 2(this));
                }
                long nanoTime = System.nanoTime() - System.nanoTime();
                ab.i("MicroMsg.CardAdDetailItemView", "isMediaSightExist %b duration %s", new Object[]{Boolean.valueOf(com.tencent.mm.plugin.sns.model.g.t(bau)), Long.valueOf(nanoTime)});
                aj ajVar = this.rGD;
                this.rGD.cwT = this.ros.cqU();
                if (com.tencent.mm.plugin.sns.model.g.t(bau)) {
                    if (cnC.u(bau)) {
                        ajVar.raP.setVisibility(0);
                        ajVar.rnu.setVisibility(8);
                        ajVar.raP.setImageDrawable(com.tencent.mm.bz.a.g(this.context, 2131231923));
                        ajVar.raP.setContentDescription(this.context.getResources().getString(2131301953));
                    } else if (cnC.v(bau)) {
                        ajVar.raP.setVisibility(8);
                        ajVar.rnu.setVisibility(8);
                    } else if (cnC.b(this.ros, null) <= 5) {
                        ajVar.raP.setVisibility(8);
                        ajVar.rnu.setVisibility(8);
                    } else {
                        cnC.y(bau);
                        ajVar.raP.setVisibility(0);
                        ajVar.rnu.setVisibility(8);
                        ajVar.raP.setImageDrawable(com.tencent.mm.bz.a.g(this.context, 2131231923));
                        ajVar.raP.setContentDescription(this.context.getResources().getString(2131301953));
                    }
                    if (ajVar.qzM.ckY()) {
                        ab.d("MicroMsg.CardAdDetailItemView", "play video error " + bau.Id + " " + bau.Url + " " + bau.wEH);
                        cnC.y(bau);
                        ajVar.raP.setVisibility(0);
                        ajVar.rnu.setVisibility(8);
                        ajVar.raP.setImageDrawable(com.tencent.mm.bz.a.g(this.context, 2131231923));
                        ajVar.raP.setContentDescription(this.context.getResources().getString(2131301953));
                    }
                } else if (cnC.w(bau)) {
                    ajVar.raP.setVisibility(8);
                    ajVar.rnu.setVisibility(0);
                    ajVar.rnu.dKB();
                } else if (cnC.b(this.ros, null) == 5) {
                    cnC.A(bau);
                    ajVar.raP.setVisibility(8);
                    ajVar.rnu.setVisibility(0);
                    ajVar.rnu.dKB();
                } else if (cnC.x(bau)) {
                    ajVar.rnu.setVisibility(8);
                    ajVar.raP.setImageResource(2130840197);
                    ajVar.raP.setVisibility(0);
                } else {
                    cnC.y(bau);
                    ajVar.raP.setVisibility(0);
                    ajVar.rnu.setVisibility(8);
                    ajVar.raP.setImageDrawable(com.tencent.mm.bz.a.g(this.context, 2131231923));
                    ajVar.raP.setContentDescription(this.context.getResources().getString(2131301953));
                    if (cnC.b(this.ros, null) == 4) {
                        ajVar.raQ.setVisibility(0);
                    }
                }
                this.rGD.rns.setVisibility(0);
                ajVar.qzM.setTagObject(ajVar);
                ajVar.rnt.setTag(this);
                this.contentView.setTag(this);
                this.rGH.setTag(this);
                this.rGI.setTag(this);
                cnC.a(this.ros, bau, ajVar.qzM, this.context.hashCode(), 0, az.xYT, true, true);
                if (this.rqn != null) {
                    if (com.tencent.mm.vfs.e.ct(an.fZ(af.getAccSnsPath(), bau.Id) + i.j(bau))) {
                        this.rqn.v(this.ros.field_snsId, true);
                    } else {
                        this.rqn.v(this.ros.field_snsId, false);
                    }
                    this.rqn.c(this.ros.field_snsId, af.cnC().b(this.ros, null) == 5, false);
                }
                AppMethodBeat.o(40092);
                return;
            } else {
                cnC.a(this.rGD.qzM, this.context.hashCode());
                this.rGD.rnv.setVisibility(8);
                this.rGD.qzM.setOnSightCompletionAction(null);
                this.rGD.qzM.setOnCompletionListener(null);
                this.rGD.qzM.setOnDecodeDurationListener(null);
            }
        }
        AppMethodBeat.o(40092);
    }

    /* JADX WARNING: Removed duplicated region for block: B:19:0x009a  */
    private void G(com.tencent.mm.plugin.sns.storage.n r10) {
        /*
        r9 = this;
        r0 = 0;
        r8 = 2130840254; // 0x7f020abe float:1.7285542E38 double:1.0527749663E-314;
        r7 = 40093; // 0x9c9d float:5.6182E-41 double:1.98086E-319;
        r1 = 1;
        r6 = -16777216; // 0xffffffffff000000 float:-1.7014118E38 double:NaN;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r7);
        if (r10 == 0) goto L_0x0015;
    L_0x000f:
        r2 = r10.coP();
        if (r2 != 0) goto L_0x0019;
    L_0x0015:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r7);
    L_0x0018:
        return;
    L_0x0019:
        r2 = "#cdcdcd";
        r2 = android.graphics.Color.parseColor(r2);
        r3 = "#ffffff";
        r3 = android.graphics.Color.parseColor(r3);
        r4 = r9.rGH;
        if (r4 == 0) goto L_0x002f;
    L_0x002b:
        r4 = r9.rGI;
        if (r4 != 0) goto L_0x0033;
    L_0x002f:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r7);
        goto L_0x0018;
    L_0x0033:
        r4 = r9.rGH;
        r5 = r9.rqo;
        r5 = r5.rKl;
        r4.setOnClickListener(r5);
        r4 = r9.rGI;
        r5 = r9.rqo;
        r5 = r5.rKm;
        r4.setOnClickListener(r5);
        r4 = r10.cqo();
        r4 = r4.coS();
        if (r4 == 0) goto L_0x0103;
    L_0x004f:
        r4 = r10.cqo();
        r4 = r4.qVh;
        r4 = r4.qVu;
        r5 = r10.crc();
        r4 = com.tencent.mm.plugin.sns.storage.v.gr(r4, r5);
        if (r4 <= 0) goto L_0x0103;
    L_0x0061:
        r5 = 2;
        if (r4 > r5) goto L_0x0103;
    L_0x0064:
        if (r4 != r1) goto L_0x00cd;
    L_0x0066:
        r4 = r9.rGI;
        r4.setBackgroundColor(r3);
        r3 = r9.rGI;
        r3.setTextColor(r2);
        r2 = r9.rGI;
        r3 = r10.cqo();
        r3 = r3.qVh;
        r1 = r3.Dm(r1);
        r2.setText(r1);
        r1 = r9.rGH;
        r1.setBackgroundResource(r8);
        r1 = r9.rGH;
        r1.setTextColor(r6);
        r1 = r9.rGH;
        r2 = r10.cqo();
        r2 = r2.qVh;
        r2 = r2.Dl(r0);
        r1.setText(r2);
    L_0x0098:
        if (r0 == 0) goto L_0x00c8;
    L_0x009a:
        r0 = r9.rGH;
        r0.setTextColor(r6);
        r0 = r9.rGH;
        r0.setBackgroundResource(r8);
        r0 = r9.rGI;
        r0.setTextColor(r6);
        r0 = r9.rGI;
        r0.setBackgroundResource(r8);
        r0 = r9.rGH;
        r1 = r10.cqo();
        r1 = r1.coL();
        r0.setText(r1);
        r0 = r9.rGI;
        r1 = r10.cqo();
        r1 = r1.coM();
        r0.setText(r1);
    L_0x00c8:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r7);
        goto L_0x0018;
    L_0x00cd:
        r5 = 2;
        if (r4 != r5) goto L_0x0098;
    L_0x00d0:
        r4 = r9.rGH;
        r4.setBackgroundColor(r3);
        r3 = r9.rGH;
        r3.setTextColor(r2);
        r2 = r9.rGH;
        r3 = r10.cqo();
        r3 = r3.qVh;
        r3 = r3.Dm(r0);
        r2.setText(r3);
        r2 = r9.rGI;
        r2.setBackgroundResource(r8);
        r2 = r9.rGI;
        r2.setTextColor(r6);
        r2 = r9.rGI;
        r3 = r10.cqo();
        r3 = r3.qVh;
        r1 = r3.Dl(r1);
        r2.setText(r1);
        goto L_0x0098;
    L_0x0103:
        r0 = r1;
        goto L_0x0098;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.plugin.sns.ui.c.a.b.G(com.tencent.mm.plugin.sns.storage.n):void");
    }
}
