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

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.GradientDrawable.Orientation;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
import android.widget.ImageView;
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.b$c;
import com.tencent.mm.plugin.sns.storage.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.d.b;
import com.tencent.mm.plugin.sns.ui.widget.SnsDrawGestureView;
import com.tencent.mm.protocal.protobuf.TimeLineObject;
import com.tencent.mm.protocal.protobuf.bau;
import com.tencent.mm.sdk.g.d;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.storage.az;
import com.tencent.mm.ui.widget.MMPinProgressBtn;
import com.tencent.mm.ui.widget.QImageView.a;
import com.tencent.mm.ui.widget.RoundedCornerRelativeLayout;

public final class c extends a {
    Context context;
    public View rGQ;
    public View rGR;
    private TextView rGS;
    private TextView rGT;
    private TextView rGU;
    private TextView rGV;
    public View rGW;
    public MaskImageView rGX;
    SnsDrawGestureView rGY;
    b$c rGZ;
    g rqn;

    public c(TimeLineObject timeLineObject, n nVar, 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(40102);
        this.contentView = view;
        this.rpP = view2;
        this.context = view.getContext();
        this.rGQ = view.findViewById(2131827880);
        this.rGR = view.findViewById(2131827883);
        this.rGS = (TextView) view.findViewById(2131827881);
        this.rGT = (TextView) view.findViewById(2131827882);
        this.rGU = (TextView) view.findViewById(2131827884);
        this.rGV = (TextView) view.findViewById(2131827885);
        this.rGW = view.findViewById(2131827886);
        this.rGX = (MaskImageView) view.findViewById(2131827878);
        this.rGY = (SnsDrawGestureView) view.findViewById(2131827887);
        this.rGX.setScaleType(a.zNT);
        this.rGD = new aj();
        this.rGD.rnt = view.findViewById(2131827879);
        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);
        ((SightPlayImageView) this.rGD.qzM).qyI = true;
        ((SightPlayImageView) this.rGD.qzM).setScaleType(a.zNT);
        AppMethodBeat.o(40102);
    }

    public final void refreshView() {
        bau bau;
        AppMethodBeat.i(40103);
        this.ros = h.YS(this.ros.cqA());
        this.rGZ = null;
        if (!(this.ros == null || this.ros.cqo() == null)) {
            this.rGZ = this.ros.cqo().qUY;
        }
        LayoutParams layoutParams = null;
        WindowManager windowManager = (WindowManager) this.context.getSystemService("window");
        int min = Math.min(windowManager.getDefaultDisplay().getWidth(), windowManager.getDefaultDisplay().getHeight());
        this.rGQ.setVisibility(8);
        this.rGS.setVisibility(8);
        this.rGT.setVisibility(8);
        this.rGR.setVisibility(8);
        this.rGU.setVisibility(8);
        this.rGV.setVisibility(8);
        this.rGW.setVisibility(8);
        if (this.rGZ != null) {
            LayoutParams layoutParams2;
            GradientDrawable gradientDrawable;
            int al = ((((min - 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);
            if (this.rGZ.qVk == 0) {
                layoutParams2 = new LayoutParams(-2, -2);
                layoutParams2.width = al;
                layoutParams2.height = (int) (((float) layoutParams2.width) * 0.75f);
                layoutParams = layoutParams2;
            } else if (this.rGZ.qVk == 1) {
                layoutParams2 = new LayoutParams(-2, -2);
                layoutParams2.width = al;
                layoutParams2.height = layoutParams2.width;
                layoutParams = layoutParams2;
            }
            if (layoutParams != null) {
                layoutParams2 = this.contentView.getLayoutParams();
                layoutParams2.width = layoutParams.width;
                layoutParams2.height = layoutParams.height;
                this.contentView.setLayoutParams(layoutParams2);
                ((RoundedCornerRelativeLayout) this.contentView).setRadius(8.0f);
                layoutParams2 = this.rGX.getLayoutParams();
                layoutParams2.width = layoutParams.width;
                layoutParams2.height = layoutParams.height;
                this.rGX.setLayoutParams(layoutParams2);
                layoutParams2 = this.rGD.rns.getLayoutParams();
                layoutParams2.width = layoutParams.width;
                layoutParams2.height = layoutParams.height;
                this.rGD.rns.setLayoutParams(layoutParams2);
                this.rGD.qzM.fi(layoutParams.width, layoutParams.height);
            }
            TextView textView;
            com.tencent.mm.cb.g dqQ;
            if (this.rGZ.qVm == 0) {
                gradientDrawable = new GradientDrawable(Orientation.TOP_BOTTOM, new int[]{Color.argb((int) (((float) this.rGZ.qVl) * 2.55f), 0, 0, 0), Color.argb(0, 0, 0, 0)});
                gradientDrawable.setGradientType(0);
                this.rGQ.setBackground(gradientDrawable);
                if (!(bo.isNullOrNil(this.rGZ.title) && bo.isNullOrNil(this.rGZ.description))) {
                    this.rGQ.setVisibility(0);
                }
                this.rGR.setVisibility(8);
                if (!bo.isNullOrNil(this.rGZ.title)) {
                    this.rGS.setVisibility(0);
                    textView = this.rGS;
                    dqQ = com.tencent.mm.cb.g.dqQ();
                    this.rGS.getContext();
                    textView.setText(dqQ.b(this.rGZ.title, this.rGS.getTextSize()));
                }
                if (!bo.isNullOrNil(this.rGZ.description)) {
                    this.rGT.setVisibility(0);
                    textView = this.rGT;
                    dqQ = com.tencent.mm.cb.g.dqQ();
                    this.rGT.getContext();
                    textView.setText(dqQ.b(this.rGZ.description, this.rGT.getTextSize()));
                }
            } else if (this.rGZ.qVm == 1) {
                gradientDrawable = new GradientDrawable(Orientation.BOTTOM_TOP, new int[]{Color.argb((int) (((float) this.rGZ.qVl) * 2.55f), 0, 0, 0), Color.argb(0, 0, 0, 0)});
                gradientDrawable.setGradientType(0);
                this.rGQ.setVisibility(8);
                this.rGR.setBackground(gradientDrawable);
                if (!(bo.isNullOrNil(this.rGZ.title) && bo.isNullOrNil(this.rGZ.description))) {
                    this.rGR.setVisibility(0);
                    RelativeLayout.LayoutParams layoutParams3 = (RelativeLayout.LayoutParams) this.rGW.getLayoutParams();
                    layoutParams3.topMargin = com.tencent.mm.bz.a.fromDPToPix(this.context, 4);
                    this.rGW.setLayoutParams(layoutParams3);
                }
                if (!bo.isNullOrNil(this.rGZ.title)) {
                    this.rGU.setVisibility(0);
                    textView = this.rGU;
                    dqQ = com.tencent.mm.cb.g.dqQ();
                    this.rGU.getContext();
                    textView.setText(dqQ.b(this.rGZ.title, this.rGU.getTextSize()));
                }
                if (!bo.isNullOrNil(this.rGZ.description)) {
                    this.rGV.setVisibility(0);
                    textView = this.rGV;
                    dqQ = com.tencent.mm.cb.g.dqQ();
                    this.rGV.getContext();
                    textView.setText(dqQ.b(this.rGZ.description, this.rGV.getTextSize()));
                }
            }
            if (this.ros.cqq().coI()) {
                gradientDrawable = new GradientDrawable(Orientation.BOTTOM_TOP, new int[]{Color.argb((int) (((float) this.rGZ.qVl) * 2.55f), 0, 0, 0), Color.argb(0, 0, 0, 0)});
                gradientDrawable.setGradientType(0);
                this.rGR.setVisibility(0);
                this.rGR.setBackground(gradientDrawable);
                this.rGW.setVisibility(0);
            }
        } else {
            ab.e("MicroMsg.FullCardAdDetailItem", "invalid full card");
        }
        if (this.timeLineObject.xfI == null || this.timeLineObject.xfI.wbK.size() <= 0) {
            bau = null;
        } else {
            bau = (bau) this.timeLineObject.xfI.wbK.get(0);
        }
        this.rGD.a(this.timeLineObject, 0, this.ros.cqU(), true);
        this.rGD.raQ.setVisibility(8);
        com.tencent.mm.plugin.sns.model.g cnC = af.cnC();
        if (bau != null) {
            final long j = this.ros.field_snsId;
            if (this.timeLineObject.xfI.wbJ == 1) {
                this.rGX.setVisibility(0);
                this.rGX.setTag(this);
                this.rGX.setOnClickListener(this.rqo.rKn);
                MaskImageView maskImageView = this.rGX;
                int hashCode = this.context.hashCode();
                az dtg = az.dtg();
                dtg.oyB = this.timeLineObject.pcX;
                cnC.a(bau, maskImageView, -1, hashCode, dtg, 3);
                AppMethodBeat.o(40103);
                return;
            }
            if (this.timeLineObject.xfI.wbJ == 15 || this.timeLineObject.xfI.wbJ == 5) {
                long nanoTime = System.nanoTime() - System.nanoTime();
                ab.i("MicroMsg.FullCardAdDetailItem", "isMediaSightExist %b duration %s", new Object[]{Boolean.valueOf(com.tencent.mm.plugin.sns.model.g.t(bau)), Long.valueOf(nanoTime)});
                this.rGD.qzM.setOnCompletionListener(new e() {
                    public final void c(com.tencent.mm.plugin.sight.decode.a.b bVar, int i) {
                        AppMethodBeat.i(40094);
                        if (i != -1) {
                            c.this.rqn.u(j, false);
                        }
                        AppMethodBeat.o(40094);
                    }
                });
                if (!(this.rqn == null || this.rqn.jO(j))) {
                    this.rGD.qzM.setOnDecodeDurationListener(new 2(this, j));
                }
                b$c.a aVar = this.rGZ.qVn;
                String coW = this.ros.cqo().coW();
                if (!bo.isNullOrNil(coW) && aVar != null && aVar.startTime >= 0 && aVar.endTime > aVar.startTime) {
                    d.post(new 3(this, coW), "preDownloadFloatPage");
                }
                if (r4) {
                    if (cnC.u(bau)) {
                        this.rGD.raP.setVisibility(0);
                        this.rGD.rnu.setVisibility(8);
                        this.rGD.raP.setImageDrawable(com.tencent.mm.bz.a.g(this.context, 2131231923));
                        this.rGD.raP.setContentDescription(this.context.getString(2131301953));
                    } else if (cnC.v(bau)) {
                        this.rGD.raP.setVisibility(8);
                        this.rGD.rnu.setVisibility(8);
                    } else if (cnC.b(this.ros, null) <= 5) {
                        this.rGD.raP.setVisibility(8);
                        this.rGD.rnu.setVisibility(8);
                    } else {
                        cnC.y(bau);
                        this.rGD.raP.setVisibility(0);
                        this.rGD.rnu.setVisibility(8);
                        this.rGD.raP.setImageDrawable(com.tencent.mm.bz.a.g(this.context, 2131231923));
                        this.rGD.raP.setContentDescription(this.context.getString(2131301953));
                    }
                    if (this.rGD.qzM.ckY()) {
                        ab.d("MicroMsg.FullCardAdDetailItem", "play video error " + bau.Id + " " + bau.Url + " " + bau.wEH);
                        cnC.y(bau);
                        this.rGD.raP.setVisibility(0);
                        this.rGD.rnu.setVisibility(8);
                        this.rGD.raP.setImageDrawable(com.tencent.mm.bz.a.g(this.context, 2131231923));
                        this.rGD.raP.setContentDescription(this.context.getString(2131301953));
                    }
                } else if (cnC.w(bau)) {
                    this.rGD.raP.setVisibility(8);
                    this.rGD.rnu.setVisibility(0);
                    this.rGD.rnu.dKB();
                } else if (cnC.b(this.ros, null) == 5) {
                    cnC.A(bau);
                    this.rGD.raP.setVisibility(8);
                    this.rGD.rnu.setVisibility(0);
                    this.rGD.rnu.dKB();
                } else if (cnC.x(bau)) {
                    this.rGD.rnu.setVisibility(8);
                    this.rGD.raP.setImageResource(2130840197);
                    this.rGD.raP.setVisibility(0);
                } else {
                    cnC.y(bau);
                    this.rGD.raP.setVisibility(0);
                    this.rGD.rnu.setVisibility(8);
                    this.rGD.raP.setImageDrawable(com.tencent.mm.bz.a.g(this.context, 2131231923));
                    this.rGD.raP.setContentDescription(this.context.getString(2131301953));
                    if (cnC.b(this.ros, null) == 4) {
                        this.rGD.raQ.setVisibility(0);
                    }
                }
                this.rGD.rns.setVisibility(0);
                this.rGD.qzM.setTagObject(this.rGD);
                this.rGD.rnt.setTag(this);
                this.rGD.rns.setOnClickListener(this.rqo.rKn);
                n nVar = this.ros;
                com.tencent.mm.plugin.sight.decode.a.a aVar2 = this.rGD.qzM;
                int hashCode2 = this.context.hashCode();
                az dtg2 = az.dtg();
                dtg2.oyB = this.timeLineObject.pcX;
                cnC.a(nVar, bau, aVar2, hashCode2, 0, dtg2, true, true);
                String fZ = an.fZ(af.getAccSnsPath(), bau.Id);
                String j2 = i.j(bau);
                if (this.rqn != null) {
                    if (com.tencent.mm.vfs.e.ct(fZ + j2)) {
                        this.rqn.v(j, true);
                    } else {
                        this.rqn.v(j, false);
                    }
                    this.rqn.c(j, af.cnC().b(this.ros, null) == 5, false);
                }
            }
            AppMethodBeat.o(40103);
            return;
        }
        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(40103);
    }
}
