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

import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.os.Looper;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.ai.f;
import com.tencent.mm.at.o;
import com.tencent.mm.compatible.util.e;
import com.tencent.mm.g.a.ik;
import com.tencent.mm.kernel.g;
import com.tencent.mm.plugin.card.base.b;
import com.tencent.mm.plugin.card.d.a.a;
import com.tencent.mm.plugin.card.d.d;
import com.tencent.mm.plugin.card.d.l;
import com.tencent.mm.plugin.card.model.CardGiftInfo;
import com.tencent.mm.plugin.card.model.CardGiftInfo$AcceptedCardItem;
import com.tencent.mm.plugin.card.model.CardInfo;
import com.tencent.mm.plugin.card.model.m;
import com.tencent.mm.plugin.card.model.t;
import com.tencent.mm.plugin.card.model.z;
import com.tencent.mm.pluginsdk.ui.e.j;
import com.tencent.mm.protocal.protobuf.cdc;
import com.tencent.mm.protocal.protobuf.oj;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.ak;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.ui.MMActivity;
import com.tencent.mm.ui.base.h;
import com.tencent.mm.ui.base.p;
import com.tencent.ytcommon.BuildConfig;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;

public class CardGiftReceiveUI extends MMActivity implements OnClickListener, f {
    private int fhF;
    private String fhG;
    private TextView kkA;
    private TextView kkB;
    private ImageView kkC;
    private ImageView kkD;
    private LinearLayout kkE;
    private RelativeLayout kkF;
    private RelativeLayout kkG;
    private TextView kkH;
    private ImageView kkI;
    private TextView kkJ;
    private TextView kkK;
    private TextView kkL;
    private ImageView kkM;
    private ImageView kkN;
    private View kkO;
    private TextView kkP;
    private LinearLayout kkQ;
    private ListView kkR;
    private RelativeLayout kkS;
    private LinearLayout kkT;
    private ImageView kkU;
    private TextView kkV;
    private LinearLayout kkW;
    private TextView kkX;
    private RelativeLayout kkY;
    private RelativeLayout kkZ;
    private CardGiftInfo kkk;
    private ProgressBar kko;
    private ak kkp = new ak(Looper.getMainLooper());
    private ScrollView kkx;
    private LinearLayout kky;
    private ImageView kkz;
    private ImageView kla;
    private ImageView klb;
    private TextView klc;
    private TextView kld;
    private ListView kle;
    private RelativeLayout klf;
    private TextView klg;
    private TextView klh;
    private View kli;
    a klj = new 4(this);
    private p tipDialog = null;

    class c extends BaseAdapter {
        private LinkedList<CardGiftInfo$AcceptedCardItem> klo;

        public final /* synthetic */ Object getItem(int i) {
            AppMethodBeat.i(88429);
            CardGiftInfo$AcceptedCardItem td = td(i);
            AppMethodBeat.o(88429);
            return td;
        }

        c(LinkedList<CardGiftInfo$AcceptedCardItem> linkedList) {
            this.klo = linkedList;
        }

        public final int getCount() {
            AppMethodBeat.i(88426);
            int size = this.klo.size();
            AppMethodBeat.o(88426);
            return size;
        }

        private CardGiftInfo$AcceptedCardItem td(int i) {
            AppMethodBeat.i(88427);
            CardGiftInfo$AcceptedCardItem cardGiftInfo$AcceptedCardItem = (CardGiftInfo$AcceptedCardItem) this.klo.get(i);
            AppMethodBeat.o(88427);
            return cardGiftInfo$AcceptedCardItem;
        }

        public final long getItemId(int i) {
            return (long) i;
        }

        public final View getView(int i, View view, ViewGroup viewGroup) {
            d dVar;
            AppMethodBeat.i(88428);
            CardGiftInfo$AcceptedCardItem td = td(i);
            if (view == null) {
                view = View.inflate(CardGiftReceiveUI.this, 2130968920, null);
                d dVar2 = new d(CardGiftReceiveUI.this);
                dVar2.gsf = (TextView) view.findViewById(2131822067);
                dVar2.kln = (TextView) view.findViewById(2131822068);
                view.setTag(dVar2);
                dVar = dVar2;
            } else {
                dVar = (d) view.getTag();
            }
            dVar.gsf.setText(td.kcU);
            dVar.kln.setText(td.kcV + CardGiftReceiveUI.this.mController.ylL.getString(2131297860));
            AppMethodBeat.o(88428);
            return view;
        }
    }

    public void onWindowFocusChanged(boolean z) {
        super.onWindowFocusChanged(z);
        AppMethodBeat.at(this, z);
    }

    public CardGiftReceiveUI() {
        AppMethodBeat.i(88430);
        AppMethodBeat.o(88430);
    }

    public final int getLayoutId() {
        return 2130968925;
    }

    public void onCreate(Bundle bundle) {
        AppMethodBeat.i(88431);
        super.onCreate(bundle);
        this.fhG = getIntent().getStringExtra("key_order_id");
        this.fhF = getIntent().getIntExtra("key_biz_uin", -1);
        this.kkk = (CardGiftInfo) getIntent().getParcelableExtra("key_gift_into");
        ab.i("MicroMsg.CardGiftReceiveUI", "onCreate, orderId:%s, bizUin:%s", new Object[]{this.fhG, Integer.valueOf(this.fhF)});
        initView();
        g.RO().eJo.a(1165, this);
        g.RO().eJo.a(699, this);
        com.tencent.mm.plugin.card.d.a.a(this.klj);
        if (this.kkk == null) {
            ab.i("MicroMsg.CardGiftReceiveUI", "cardGiftInfo is null, sync GiftCard from serve");
            if (this.fhF == -1) {
                ab.e("MicroMsg.CardGiftReceiveUI", "NetSceneGetCardGiftInfo, bizUin is -1, fail!");
                AppMethodBeat.o(88431);
                return;
            }
            if (this.fhG == null) {
                ab.e("MicroMsg.CardGiftReceiveUI", "NetSceneGetCardGiftInfo, orderId is null, fail");
            }
            ab.e("MicroMsg.CardGiftReceiveUI", "doNetSceneGetCardGiftInfo");
            g.RO().eJo.a(new z(this.fhF, this.fhG), 0);
            this.tipDialog = h.b(this.mController.ylL, getString(2131300968), true, new 3(this));
            if (this.tipDialog != null) {
                this.tipDialog.show();
            }
            AppMethodBeat.o(88431);
            return;
        }
        bbB();
        AppMethodBeat.o(88431);
    }

    public void onDestroy() {
        AppMethodBeat.i(88432);
        super.onDestroy();
        g.RO().eJo.b(1165, this);
        g.RO().eJo.b(699, this);
        com.tencent.mm.plugin.card.d.a.b(this.klj);
        AppMethodBeat.o(88432);
    }

    private void bbB() {
        AppMethodBeat.i(88433);
        if (this.kkk == null) {
            ab.e("MicroMsg.CardGiftReceiveUI", "doUpdate due to cardGiftInfo is null!");
            AppMethodBeat.o(88433);
            return;
        }
        ab.i("MicroMsg.CardGiftReceiveUI", "cardGiftInfo.descLayoutMode:%d", new Object[]{Integer.valueOf(this.kkk.kcE)});
        if (this.kkk.kcE == 1 || this.kkk.kcE != 2) {
            bda();
        } else {
            bcZ();
        }
        bcY();
        bbS();
        bdb();
        if (bo.isNullOrNil(this.kkk.kcK) && bo.isNullOrNil(this.kkk.kcx)) {
            this.kkx.setFillViewport(true);
            AppMethodBeat.o(88433);
            return;
        }
        this.kkx.getViewTreeObserver().addOnGlobalLayoutListener(new 1(this));
        AppMethodBeat.o(88433);
    }

    private void bcY() {
        AppMethodBeat.i(88435);
        if (this.kkk.kcR == 1) {
            this.kkT.setVisibility(0);
            this.kkW.setVisibility(8);
            this.kkS.setVisibility(8);
            this.kkV.setText(j.b(this, this.kkk.cKE, this.kkV.getTextSize()));
            f(this.kkU);
            AppMethodBeat.o(88435);
            return;
        }
        this.kkT.setVisibility(8);
        this.kkW.setVisibility(0);
        this.kkS.setVisibility(0);
        f(this.klb);
        this.klc.setText(j.b(this, this.kkk.cKE, this.klc.getTextSize()));
        if ((bo.isNullOrNil(this.kkk.kcn) || "undefined".equals(this.kkk.kcn)) && (bo.isNullOrNil(this.kkk.kco) || "undefined".equals(this.kkk.kco))) {
            this.kkY.setVisibility(8);
            ab.i("MicroMsg.CardGiftReceiveUI", "fromUserImgUrl is empty");
        } else {
            this.kkY.setVisibility(0);
        }
        bdc();
        if (!bo.isNullOrNil(this.kkk.kcm)) {
            this.kkX.setText(j.b(this, this.kkk.kcm, this.kkX.getTextSize()));
        }
        AppMethodBeat.o(88435);
    }

    private void f(ImageView imageView) {
        AppMethodBeat.i(88436);
        if (bo.isNullOrNil(this.kkk.kcl)) {
            ab.i("MicroMsg.CardGiftReceiveUI", "fromUserImgUrl is null");
            AppMethodBeat.o(88436);
            return;
        }
        int fromDPToPix = com.tencent.mm.bz.a.fromDPToPix(this, 20);
        com.tencent.mm.at.a.a.c.a aVar = new com.tencent.mm.at.a.a.c.a();
        aVar.ePK = e.eSn;
        o.ahq();
        aVar.ePY = null;
        aVar.ePJ = m.Gz(this.kkk.kcl);
        aVar.ePH = true;
        aVar.eQf = true;
        aVar.eQg = 3.0f;
        aVar.ePF = true;
        aVar.ePO = fromDPToPix;
        aVar.ePN = fromDPToPix;
        aVar.ePU = new ColorDrawable(l.Hn("#CCCCCC"));
        o.ahp().a(this.kkk.kcl, imageView, aVar.ahG());
        AppMethodBeat.o(88436);
    }

    private void bcZ() {
        com.tencent.mm.at.a.a.c.a aVar;
        AppMethodBeat.i(88437);
        this.kkE.setVisibility(8);
        this.kky.setVisibility(0);
        this.kkA.setText(this.kkk.kcC);
        this.kkB.setText(this.kkk.kcv + "     " + this.kkk.kcw + this.mController.ylL.getString(2131297860));
        if (bo.isNullOrNil(this.kkk.kcD)) {
            this.kkz.setVisibility(8);
        } else {
            this.kkz.setVisibility(0);
            aVar = new com.tencent.mm.at.a.a.c.a();
            aVar.ePK = e.eSn;
            o.ahq();
            aVar.ePY = null;
            aVar.ePJ = m.Gz(this.kkk.kcD);
            aVar.ePH = true;
            aVar.ePF = true;
            o.ahp().a(this.kkk.kcD, this.kkz, aVar.ahG());
        }
        if (bo.isNullOrNil(this.kkk.kcG)) {
            ab.i("MicroMsg.CardGiftReceiveUI", "cardGiftInfo.descriptionTitleColor is empty");
        } else {
            this.kkA.setTextColor(bo.bS(this.kkk.kcG, getResources().getColor(2131689761)));
        }
        if (bo.isNullOrNil(this.kkk.kcH)) {
            ab.i("MicroMsg.CardGiftReceiveUI", "cardGiftInfo.cardTitleColor is empty");
        } else {
            this.kkB.setTextColor(bo.bS(this.kkk.kcH, getResources().getColor(2131689761)));
        }
        if (bo.isNullOrNil(this.kkk.kcu)) {
            ab.i("MicroMsg.CardGiftReceiveUI", "cardLogoLUrl is null");
        } else {
            aVar = new com.tencent.mm.at.a.a.c.a();
            aVar.ePK = e.eSn;
            o.ahq();
            aVar.ePY = null;
            aVar.ePJ = m.Gz(this.kkk.kcu);
            aVar.eQf = true;
            aVar.ePH = true;
            aVar.ePF = true;
            aVar.ePU = new ColorDrawable(l.Hn("#CCCCCC"));
            o.ahp().a(this.kkk.kcu, this.kkD, aVar.ahG());
        }
        if (bo.isNullOrNil(this.kkk.kct)) {
            ab.i("MicroMsg.CardGiftReceiveUI", "cardBackgroundPicUrl is null");
            AppMethodBeat.o(88437);
            return;
        }
        aVar = new com.tencent.mm.at.a.a.c.a();
        aVar.ePK = e.eSn;
        o.ahq();
        aVar.ePY = null;
        aVar.ePJ = m.Gz(this.kkk.kct);
        aVar.ePH = true;
        aVar.ePF = true;
        aVar.ePU = new ColorDrawable(l.Hn("#CCCCCC"));
        aVar.eQf = true;
        aVar.eQg = (float) com.tencent.mm.bz.a.fromDPToPix(this, 8);
        o.ahp().a(this.kkk.kct, this.kkC, aVar.ahG());
        AppMethodBeat.o(88437);
    }

    private void bda() {
        com.tencent.mm.at.a.a.c.a aVar;
        AppMethodBeat.i(88438);
        this.kky.setVisibility(8);
        this.kkE.setVisibility(0);
        this.kkJ.setText(this.kkk.kcv);
        if (this.kkk.kcR == 1) {
            this.kkM.setAlpha(0.5f);
            this.kkK.setVisibility(8);
            this.kkL.setVisibility(8);
            this.kkG.setVisibility(8);
            this.kkF.setVisibility(8);
        } else {
            this.kkK.setVisibility(0);
            this.kkL.setVisibility(0);
            this.kkG.setVisibility(0);
            this.kkF.setVisibility(0);
            this.kkK.setText(this.kkk.kcw);
            this.kkL.setText(2131297860);
            if (bo.isNullOrNil(this.kkk.kcw)) {
                this.kkK.setVisibility(8);
                this.kkL.setVisibility(8);
            }
            if (bo.isNullOrNil(this.kkk.kcI)) {
                ab.i("MicroMsg.CardGiftReceiveUI", "cardGiftInfo.cardPriceTitleColor is empty");
            } else {
                this.kkK.setTextColor(bo.bS(this.kkk.kcI, getResources().getColor(2131689761)));
            }
        }
        if (bo.isNullOrNil(this.kkk.kcD)) {
            this.kkI.setVisibility(8);
            ab.i("MicroMsg.CardGiftReceiveUI", "descIconUrl is null");
        } else {
            this.kkI.setVisibility(0);
            aVar = new com.tencent.mm.at.a.a.c.a();
            aVar.ePK = e.eSn;
            o.ahq();
            aVar.ePY = null;
            aVar.ePJ = m.Gz(this.kkk.kcD);
            aVar.ePH = true;
            aVar.ePF = true;
            o.ahp().a(this.kkk.kcD, this.kkI, aVar.ahG());
        }
        if (bo.isNullOrNil(this.kkk.kcC)) {
            this.kkH.setVisibility(8);
            ab.i("MicroMsg.CardGiftReceiveUI", "descIconUrl is null");
        } else {
            this.kkH.setVisibility(0);
            this.kkH.setText(this.kkk.kcC);
            if (bo.isNullOrNil(this.kkk.kcG)) {
                ab.i("MicroMsg.CardGiftReceiveUI", "cardGiftInfo.descriptionTitleColor is empty");
            } else {
                this.kkH.setTextColor(bo.bS(this.kkk.kcG, getResources().getColor(2131689761)));
            }
        }
        if (bo.isNullOrNil(this.kkk.kcH)) {
            ab.i("MicroMsg.CardGiftReceiveUI", "cardGiftInfo.cardTitleColor is empty");
        } else {
            this.kkJ.setTextColor(bo.bS(this.kkk.kcH, getResources().getColor(2131689761)));
        }
        if (bo.isNullOrNil(this.kkk.kcu)) {
            ab.i("MicroMsg.CardGiftReceiveUI", "cardLogoLUrl is null");
        } else {
            aVar = new com.tencent.mm.at.a.a.c.a();
            aVar.ePK = e.eSn;
            o.ahq();
            aVar.ePY = null;
            aVar.ePJ = m.Gz(this.kkk.kcu);
            aVar.eQf = true;
            aVar.ePH = true;
            aVar.ePF = true;
            aVar.ePU = new ColorDrawable(l.Hn("#CCCCCC"));
            o.ahp().a(this.kkk.kcu, this.kkN, aVar.ahG());
        }
        if (bo.isNullOrNil(this.kkk.kct)) {
            ab.i("MicroMsg.CardGiftReceiveUI", "cardBackgroundPicUrl is null");
            AppMethodBeat.o(88438);
            return;
        }
        aVar = new com.tencent.mm.at.a.a.c.a();
        aVar.ePK = e.eSn;
        o.ahq();
        aVar.ePY = null;
        aVar.ePJ = m.Gz(this.kkk.kct);
        aVar.ePH = true;
        aVar.ePF = true;
        aVar.ePU = new ColorDrawable(l.Hn("#CCCCCC"));
        aVar.eQf = true;
        aVar.eQg = (float) com.tencent.mm.bz.a.fromDPToPix(this, 8);
        o.ahp().a(this.kkk.kct, this.kkM, aVar.ahG());
        AppMethodBeat.o(88438);
    }

    private void bbS() {
        int i = 0;
        AppMethodBeat.i(88439);
        if (this.kkk.kcO.size() > 0) {
            this.kkO.setVisibility(0);
            this.kkR.setVisibility(8);
            if (this.kkk.kcO.size() <= 2) {
                this.kkP.setVisibility(8);
                L(this.kkk.kcO);
                AppMethodBeat.o(88439);
                return;
            }
            LinkedList linkedList = new LinkedList();
            linkedList.add(this.kkk.kcO.get(0));
            linkedList.add(this.kkk.kcO.get(1));
            L(linkedList);
            this.kkP.setVisibility(0);
            this.kkP.setOnClickListener(this);
            linkedList = new LinkedList();
            while (i < this.kkk.kcO.size()) {
                if (!(i == 0 || i == 1)) {
                    linkedList.add(this.kkk.kcO.get(i));
                }
                i++;
            }
            this.kkR.setAdapter(new c(linkedList));
            b(this.kkR);
            AppMethodBeat.o(88439);
            return;
        }
        this.kkO.setVisibility(8);
        this.kkP.setVisibility(8);
        this.kkR.setVisibility(8);
        AppMethodBeat.o(88439);
    }

    private void L(LinkedList<CardGiftInfo$AcceptedCardItem> linkedList) {
        AppMethodBeat.i(88440);
        Iterator it = linkedList.iterator();
        while (it.hasNext()) {
            CardGiftInfo$AcceptedCardItem cardGiftInfo$AcceptedCardItem = (CardGiftInfo$AcceptedCardItem) it.next();
            View inflate = View.inflate(this, 2130968920, null);
            TextView textView = (TextView) inflate.findViewById(2131822068);
            ((TextView) inflate.findViewById(2131822067)).setText(cardGiftInfo$AcceptedCardItem.kcU);
            textView.setText(cardGiftInfo$AcceptedCardItem.kcV + this.mController.ylL.getString(2131297860));
            this.kkQ.addView(inflate);
        }
        AppMethodBeat.o(88440);
    }

    private void bdb() {
        AppMethodBeat.i(88441);
        if (this.kkk.kcP.size() > 0) {
            this.klf.setVisibility(0);
            this.kle.setVisibility(0);
            this.kle.setAdapter(new a(this));
            b(this.kle);
            if (!bo.isNullOrNil(this.kkk.kcQ)) {
                this.kld.setVisibility(0);
                this.kld.setText(this.kkk.kcQ);
            }
            AppMethodBeat.o(88441);
            return;
        }
        this.klf.setVisibility(0);
        this.kle.setVisibility(0);
        this.kld.setVisibility(0);
        if (!bo.isNullOrNil(this.kkk.kcQ)) {
            this.kld.setVisibility(0);
            this.kld.setText(this.kkk.kcQ);
        }
        AppMethodBeat.o(88441);
    }

    private static void b(ListView listView) {
        AppMethodBeat.i(88442);
        ListAdapter adapter = listView.getAdapter();
        if (adapter == null) {
            AppMethodBeat.o(88442);
            return;
        }
        int count = adapter.getCount();
        int i = 0;
        for (int i2 = 0; i2 < count; i2++) {
            View view = adapter.getView(i2, null, listView);
            view.measure(0, 0);
            i += view.getMeasuredHeight();
        }
        LayoutParams layoutParams = listView.getLayoutParams();
        layoutParams.height = (listView.getDividerHeight() * (adapter.getCount() - 1)) + i;
        listView.setLayoutParams(layoutParams);
        AppMethodBeat.o(88442);
    }

    public final void initView() {
        AppMethodBeat.i(88443);
        this.kkx = (ScrollView) findViewById(2131822102);
        this.kky = (LinearLayout) findViewById(2131822104);
        this.kkz = (ImageView) findViewById(2131822105);
        this.kkA = (TextView) findViewById(2131822106);
        this.kkB = (TextView) findViewById(2131822109);
        this.kkC = (ImageView) findViewById(2131822107);
        this.kkD = (ImageView) findViewById(2131822108);
        this.kkC.setOnClickListener(this);
        this.kkE = (LinearLayout) findViewById(2131822110);
        this.kkF = (RelativeLayout) findViewById(2131822111);
        this.kkG = (RelativeLayout) findViewById(2131822112);
        this.kkH = (TextView) findViewById(2131822085);
        this.kkJ = (TextView) findViewById(2131822088);
        this.kkI = (ImageView) findViewById(2131822087);
        this.kkK = (TextView) findViewById(2131822089);
        this.kkL = (TextView) findViewById(2131822113);
        this.kkM = (ImageView) findViewById(2131822091);
        this.kkN = (ImageView) findViewById(2131822092);
        this.kkM.setOnClickListener(this);
        this.kkO = findViewById(2131822117);
        this.kkP = (TextView) findViewById(2131822120);
        this.kkQ = (LinearLayout) findViewById(2131822118);
        this.kkR = (ListView) findViewById(2131822119);
        this.kkS = (RelativeLayout) findViewById(2131822121);
        this.kkT = (LinearLayout) findViewById(2131822114);
        this.kkU = (ImageView) findViewById(2131822115);
        this.kkV = (TextView) findViewById(2131822116);
        this.kkW = (LinearLayout) findViewById(2131822123);
        this.klb = (ImageView) findViewById(2131822099);
        this.klc = (TextView) findViewById(2131822100);
        this.kkX = (TextView) findViewById(2131822124);
        this.kkY = (RelativeLayout) findViewById(2131822125);
        this.kkZ = (RelativeLayout) findViewById(2131822126);
        this.kla = (ImageView) findViewById(2131822096);
        this.kkY.setOnClickListener(this);
        this.kkZ.setOnClickListener(this);
        this.kld = (TextView) findViewById(2131822129);
        this.kle = (ListView) findViewById(2131822130);
        this.klf = (RelativeLayout) findViewById(2131822127);
        this.kko = (ProgressBar) findViewById(2131822082);
        com.tencent.mm.plugin.card.d.m.d(this);
        setMMTitle(BuildConfig.FLAVOR);
        setBackBtn(new 2(this));
        AppMethodBeat.o(88443);
    }

    public void onSceneEnd(int i, int i2, String str, com.tencent.mm.ai.m mVar) {
        AppMethodBeat.i(88444);
        if (this.tipDialog != null && this.tipDialog.isShowing()) {
            this.tipDialog.dismiss();
        }
        if (i == 0 && i2 == 0) {
            if (mVar instanceof z) {
                ab.i("MicroMsg.CardGiftReceiveUI", "card gift info cgi success!");
                this.kkk = ((z) mVar).kdV;
                bbB();
                AppMethodBeat.o(88444);
                return;
            } else if (mVar instanceof t) {
                Intent intent = new Intent(this, CardDetailUI.class);
                LinkedList linkedList = ((t) mVar).kdZ;
                if (linkedList == null || linkedList.size() == 0) {
                    ab.e("MicroMsg.CardGiftReceiveUI", "NetSceneBatchGetCardItemByTpInfo resp cardinfo list  size is null or empty!");
                    AppMethodBeat.o(88444);
                    return;
                }
                b bVar = (b) linkedList.get(0);
                if (bVar == null || !(bVar instanceof CardInfo)) {
                    ab.e("MicroMsg.CardGiftReceiveUI", "NetSceneBatchGetCardItemByTpInfo resp cardInfo  is null!");
                    AppMethodBeat.o(88444);
                    return;
                }
                ArrayList arrayList = new ArrayList();
                Iterator it = linkedList.iterator();
                while (it.hasNext()) {
                    arrayList.add((CardInfo) it.next());
                }
                intent.putExtra("key_card_info", (CardInfo) bVar);
                intent.putExtra("key_previous_scene", 27);
                intent.putExtra("key_from_scene", 27);
                intent.putExtra("key_from_appbrand_type", intent.getIntExtra("key_from_appbrand_type", 0));
                intent.putExtra("key_card_git_info", this.kkk);
                startActivity(intent);
                AppMethodBeat.o(88444);
                return;
            }
        } else if (mVar instanceof z) {
            ab.e("MicroMsg.CardGiftReceiveUI", "NetSceneGetCardGiftInfo onSceneEnd fail, errType = %d, errCode = %d, errMsg = %s", new Object[]{Integer.valueOf(i), Integer.valueOf(i2), str});
            d.a(this, str, true);
            AppMethodBeat.o(88444);
            return;
        } else if (mVar instanceof t) {
            ab.e("MicroMsg.CardGiftReceiveUI", ", NetSceneBatchGetCardItemByTpInfo onSceneEnd fail return!  errType = %d, errCode = %d, errMsg = %s", new Object[]{Integer.valueOf(i), Integer.valueOf(i2), str});
            AppMethodBeat.o(88444);
            return;
        }
        AppMethodBeat.o(88444);
    }

    private void bdc() {
        AppMethodBeat.i(88445);
        if (this.kkk == null || bo.isNullOrNil(this.kkk.kcn)) {
            ab.e("MicroMsg.CardGiftReceiveUI", "fromUserContentPicUrl is null");
        } else {
            com.tencent.mm.plugin.card.d.a.g(this.kkk.kcn, this.kkk.kcq, this.kkk.kcz, 2);
        }
        if (this.kkk == null || bo.isNullOrNil(this.kkk.kcp)) {
            ab.e("MicroMsg.CardGiftReceiveUI", "fromUserContentThumbPicUrl is null");
            AppMethodBeat.o(88445);
            return;
        }
        com.tencent.mm.plugin.card.d.a.g(this.kkk.kcp, this.kkk.kcs, this.kkk.kcB, 2);
        AppMethodBeat.o(88445);
    }

    public void onClick(View view) {
        AppMethodBeat.i(88446);
        Intent intent;
        if (view.getId() == 2131822126) {
            if (!bo.isNullOrNil(this.kkk.kco)) {
                intent = new Intent(this, CardGiftVideoUI.class);
                intent.putExtra("key_gift_into", this.kkk);
                intent.putExtra("key_is_mute", false);
                startActivity(intent);
                overridePendingTransition(0, 0);
                com.tencent.mm.plugin.report.service.h.pYm.e(13866, new Object[]{Integer.valueOf(3), this.fhG, com.tencent.mm.a.p.getString(this.fhF)});
                AppMethodBeat.o(88446);
                return;
            }
        } else if (view.getId() == 2131822125) {
            if (this.kko.getVisibility() == 0) {
                AppMethodBeat.o(88446);
                return;
            } else if (!bo.isNullOrNil(this.kkk.kcn)) {
                intent = new Intent(this, CardGiftImageUI.class);
                intent.putExtra("key_gift_into", this.kkk);
                startActivity(intent);
                overridePendingTransition(0, 0);
                com.tencent.mm.plugin.report.service.h.pYm.e(13866, new Object[]{Integer.valueOf(4), this.fhG, com.tencent.mm.a.p.getString(this.fhF)});
                AppMethodBeat.o(88446);
                return;
            }
        } else if (view.getId() == 2131822078) {
            if (this.kkk != null && this.kkk.kcy) {
                com.tencent.mm.plugin.report.service.h.pYm.e(13866, new Object[]{Integer.valueOf(7), this.fhG, com.tencent.mm.a.p.getString(this.fhF)});
                ik ikVar = new ik();
                ikVar.cDz.context = this.mController.ylL;
                ikVar.cDz.scene = 2;
                com.tencent.mm.sdk.b.a.xxA.m(ikVar);
                ab.i("MicroMsg.CardGiftReceiveUI", "enter to cardhome");
                finish();
                overridePendingTransition(0, 0);
                AppMethodBeat.o(88446);
                return;
            }
        } else if (view.getId() == 2131822077) {
            if (!TextUtils.isEmpty(this.kkk.kcS) && !TextUtils.isEmpty(this.kkk.kcT)) {
                com.tencent.mm.plugin.card.d.b.d(this.kkk.kcJ, this.kkk.kcS, this.kkk.kcT, 1062, getIntent().getIntExtra("key_from_appbrand_type", 0));
                com.tencent.mm.plugin.report.service.h.pYm.e(13866, new Object[]{Integer.valueOf(8), this.fhG, com.tencent.mm.a.p.getString(this.fhF)});
                AppMethodBeat.o(88446);
                return;
            } else if (!bo.isNullOrNil(this.kkk.kcL)) {
                com.tencent.mm.plugin.card.d.b.a(this, this.kkk.kcL, 0);
                com.tencent.mm.plugin.report.service.h.pYm.e(13866, new Object[]{Integer.valueOf(8), this.fhG, com.tencent.mm.a.p.getString(this.fhF)});
                AppMethodBeat.o(88446);
                return;
            }
        } else if (view.getId() == 2131822091 || view.getId() == 2131822107) {
            if (bo.isNullOrNil(this.kkk.kcM) || bo.isNullOrNil(this.kkk.kcN)) {
                ab.e("MicroMsg.CardGiftReceiveUI", "cardGiftInfo.userCardId is null");
                AppMethodBeat.o(88446);
                return;
            }
            LinkedList linkedList = new LinkedList();
            oj ojVar = new oj();
            ojVar.kbU = this.kkk.kcM;
            ojVar.code = this.kkk.kcN;
            linkedList.add(ojVar);
            String stringExtra = getIntent().getStringExtra("key_template_id");
            cdc cdc = new cdc();
            cdc.xcM = stringExtra;
            ab.i("MicroMsg.CardGiftReceiveUI", "doBatchGetCardItemByTpInfo templateId:%s", new Object[]{stringExtra});
            g.RO().eJo.a(new t(linkedList, cdc, 27), 0);
            com.tencent.mm.plugin.report.service.h.pYm.e(13866, new Object[]{Integer.valueOf(9), this.fhG, com.tencent.mm.a.p.getString(this.fhF)});
            AppMethodBeat.o(88446);
            return;
        } else if (view.getId() == 2131822120) {
            if (this.kkR.getVisibility() == 0) {
                this.kkR.setVisibility(8);
                this.kkP.setText("查看全部");
                AppMethodBeat.o(88446);
                return;
            }
            this.kkR.setVisibility(0);
            this.kkP.setText("收起");
        }
        AppMethodBeat.o(88446);
    }

    private int ad(int i) {
        AppMethodBeat.i(88434);
        int fromDPToPix = com.tencent.mm.bz.a.fromDPToPix(this.mController.ylL, i);
        AppMethodBeat.o(88434);
        return fromDPToPix;
    }

    static /* synthetic */ void a(CardGiftReceiveUI cardGiftReceiveUI, boolean z) {
        AppMethodBeat.i(88447);
        RelativeLayout relativeLayout = (RelativeLayout) View.inflate(cardGiftReceiveUI, 2130968922, null);
        cardGiftReceiveUI.kli = relativeLayout.findViewById(2131822076);
        cardGiftReceiveUI.klg = (TextView) relativeLayout.findViewById(2131822077);
        cardGiftReceiveUI.klh = (TextView) relativeLayout.findViewById(2131822078);
        cardGiftReceiveUI.klg.setOnClickListener(cardGiftReceiveUI);
        cardGiftReceiveUI.klh.setOnClickListener(cardGiftReceiveUI);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, -2);
        if (z) {
            if (cardGiftReceiveUI.klf.getVisibility() == 0) {
                layoutParams.addRule(3, 2131822130);
            } else {
                layoutParams.addRule(3, 2131822122);
            }
            layoutParams.bottomMargin = cardGiftReceiveUI.ad(30);
            layoutParams.topMargin = cardGiftReceiveUI.ad(40);
        } else {
            layoutParams.addRule(12, -1);
            layoutParams.bottomMargin = cardGiftReceiveUI.ad(30);
            layoutParams.topMargin = cardGiftReceiveUI.ad(40);
        }
        LinearLayout.LayoutParams layoutParams2;
        if (cardGiftReceiveUI.klf.getVisibility() == 0) {
            layoutParams2 = new LinearLayout.LayoutParams(-1, -1);
            if (cardGiftReceiveUI.kkY.getVisibility() == 0) {
                layoutParams2.topMargin = cardGiftReceiveUI.ad(0);
                cardGiftReceiveUI.klf.setLayoutParams(layoutParams2);
            } else {
                layoutParams2.topMargin = cardGiftReceiveUI.ad(60);
            }
            cardGiftReceiveUI.klf.setLayoutParams(layoutParams2);
            cardGiftReceiveUI.klf.addView(relativeLayout, layoutParams);
        } else {
            layoutParams2 = new LinearLayout.LayoutParams(-1, -1);
            layoutParams2.topMargin = cardGiftReceiveUI.ad(60);
            cardGiftReceiveUI.kkS.setLayoutParams(layoutParams2);
            cardGiftReceiveUI.kkS.addView(relativeLayout, layoutParams);
        }
        if (bo.isNullOrNil(cardGiftReceiveUI.kkk.kcK)) {
            cardGiftReceiveUI.klg.setVisibility(8);
        } else {
            cardGiftReceiveUI.klg.setVisibility(0);
            cardGiftReceiveUI.klg.setText(cardGiftReceiveUI.kkk.kcK);
        }
        if (bo.isNullOrNil(cardGiftReceiveUI.kkk.kcx)) {
            cardGiftReceiveUI.kli.setVisibility(8);
            cardGiftReceiveUI.klh.setVisibility(8);
        } else {
            cardGiftReceiveUI.kli.setVisibility(0);
            cardGiftReceiveUI.klh.setVisibility(0);
            cardGiftReceiveUI.klh.setText(cardGiftReceiveUI.kkk.kcx);
        }
        if (bo.isNullOrNil(cardGiftReceiveUI.kkk.kcm)) {
            cardGiftReceiveUI.kkS.setVisibility(8);
        }
        AppMethodBeat.o(88447);
    }
}
