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

import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.Spannable;
import android.text.Spannable.Factory;
import android.text.method.LinkMovementMethod;
import android.view.View;
import android.view.View.OnClickListener;
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.ai.f;
import com.tencent.mm.ai.m;
import com.tencent.mm.compatible.e.q;
import com.tencent.mm.m.g;
import com.tencent.mm.model.aw;
import com.tencent.mm.plugin.ipcall.a.e.b;
import com.tencent.mm.protocal.d;
import com.tencent.mm.protocal.protobuf.aqq;
import com.tencent.mm.protocal.protobuf.crw;
import com.tencent.mm.sdk.b.a;
import com.tencent.mm.sdk.b.c;
import com.tencent.mm.sdk.platformtools.aa;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.ah;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.storage.ac;
import com.tencent.mm.ui.MMActivity;
import com.tencent.mm.ui.base.h;
import com.tencent.ytcommon.BuildConfig;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Iterator;
import java.util.LinkedList;

public class IPCallShareCouponUI extends MMActivity implements f {
    private String eeO = null;
    private String mTitle = null;
    private c nBm = new 1(this);
    private ProgressDialog nBv;
    private String nEP = null;
    private String nEQ = null;
    private String nER = null;
    private String nES = null;
    private String nET = null;
    private String nEU = null;
    private String nEV = null;
    private String nEW = null;
    private ImageView nFA;
    private TextView nFB;
    private TextView nFC;
    private View nFD;
    private IPCallDynamicTextView nFE;
    private b nFF = new b();
    private LinkedList<crw> nFG = null;
    private boolean nFH = false;
    private RelativeLayout nFk;
    private TextView nFl;
    private ImageView nFm;
    private RelativeLayout nFn;
    private TextView nFo;
    private ImageView nFp;
    private LinearLayout nFq;
    private LinearLayout nFr;
    private LinearLayout nFs;
    private LinearLayout nFt;
    private ImageView nFu;
    private LinearLayout nFv;
    private ImageView nFw;
    private TextView nFx;
    private TextView nFy;
    private TextView nFz;

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

    public IPCallShareCouponUI() {
        AppMethodBeat.i(22334);
        AppMethodBeat.o(22334);
    }

    public final int getForceOrientation() {
        return 1;
    }

    public void onCreate(Bundle bundle) {
        boolean z;
        AppMethodBeat.i(22335);
        super.onCreate(bundle);
        aw.Rg().a(257, this);
        a.xxA.c(this.nBm);
        setMMTitle(2131300790);
        setBackBtn(new 8(this));
        this.mController.removeAllOptionMenu();
        addIconOptionMenu(0, 2130839555, new 6(this));
        this.nFE = (IPCallDynamicTextView) findViewById(2131825050);
        this.nFk = (RelativeLayout) findViewById(2131825055);
        this.nFl = (TextView) findViewById(2131825056);
        this.nFm = (ImageView) findViewById(2131825057);
        aw.ZK();
        if (((Boolean) com.tencent.mm.model.c.Ry().get(ac.a.xLy, Boolean.FALSE)).booleanValue()) {
            this.nFm.setVisibility(0);
        }
        aw.ZK();
        this.nFl.setText((String) com.tencent.mm.model.c.Ry().get(ac.a.xLx, BuildConfig.FLAVOR));
        this.nFn = (RelativeLayout) findViewById(2131825058);
        this.nFo = (TextView) findViewById(2131825059);
        this.nFp = (ImageView) findViewById(2131825060);
        aw.ZK();
        this.nFo.setText((String) com.tencent.mm.model.c.Ry().get(ac.a.xLz, BuildConfig.FLAVOR));
        this.nFB = (TextView) findViewById(2131825051);
        this.nFC = (TextView) findViewById(2131825053);
        this.nFD = findViewById(2131825052);
        this.nFq = (LinearLayout) findViewById(2131825069);
        this.nFA = (ImageView) findViewById(2131825070);
        aw.ZK();
        if (((Boolean) com.tencent.mm.model.c.Ry().get(ac.a.xLA, Boolean.FALSE)).booleanValue()) {
            this.nFA.setVisibility(0);
        }
        this.nFx = (TextView) findViewById(2131825074);
        this.nFy = (TextView) findViewById(2131825075);
        this.nFz = (TextView) findViewById(2131825073);
        this.nFr = (LinearLayout) findViewById(2131825062);
        this.nFs = (LinearLayout) findViewById(2131825064);
        this.nFv = (LinearLayout) findViewById(2131825071);
        this.nFw = (ImageView) findViewById(2131825072);
        this.nFt = (LinearLayout) findViewById(2131825067);
        this.nFu = (ImageView) findViewById(2131825068);
        aw.ZK();
        if (((Boolean) com.tencent.mm.model.c.Ry().get(ac.a.xLG, Boolean.FALSE)).booleanValue()) {
            this.nFu.setVisibility(0);
        }
        if (com.tencent.mm.plugin.ipcall.b.c.bIT()) {
            z = true;
        } else {
            if (g.Nu().getInt("WCOPurchaseSwitch", 0) == 1) {
                z = true;
            } else {
                z = false;
            }
            if (z) {
                z = true;
            } else {
                z = false;
            }
        }
        if (z) {
            this.nFk.setVisibility(8);
        }
        if (com.tencent.mm.plugin.ipcall.b.c.bIT() || g.Nu().getInt("WCOPackagePurchaseSwitch", 0) == 0) {
            z = false;
        } else {
            z = true;
        }
        if (z) {
            this.nFn.setVisibility(0);
        }
        if (g.Nu().getInt("WCOAccountDetailSwitch", 0) == 1) {
            z = true;
        } else {
            z = false;
        }
        if (z) {
            this.nFq.setVisibility(8);
        }
        if (com.tencent.mm.plugin.ipcall.b.c.bIT()) {
            z = true;
        } else {
            if (g.Nu().getInt("WCOInviteFriend", 0) == 1) {
                z = true;
            } else {
                z = false;
            }
            if (z) {
                z = true;
            } else {
                z = false;
            }
        }
        if (z) {
            this.nFr.setVisibility(8);
        }
        this.nFx.setOnClickListener(new 9(this));
        this.nFy.setOnClickListener(new 10(this));
        this.nFq.setOnClickListener(new OnClickListener() {
            public final void onClick(View view) {
                AppMethodBeat.i(22329);
                IPCallShareCouponUI.f(IPCallShareCouponUI.this);
                AppMethodBeat.o(22329);
            }
        });
        this.nFr.setOnClickListener(new 12(this));
        this.nFt.setOnClickListener(new 13(this));
        this.nFs.setOnClickListener(new 14(this));
        this.nFk.setOnClickListener(new 15(this));
        this.nFn.setOnClickListener(new 2(this));
        this.nFv.setOnClickListener(new 3(this));
        aqq bIU = com.tencent.mm.plugin.ipcall.b.c.bIU();
        if (bIU != null) {
            a(bIU);
            refreshView();
        } else {
            this.nFE.setText("0");
            AppCompatActivity appCompatActivity = this.mController.ylL;
            getString(2131297061);
            this.nBv = h.b(appCompatActivity, getString(2131300739), true, new 4(this));
        }
        if (com.tencent.mm.plugin.ipcall.b.c.bIT()) {
            String string = getString(2131300846);
            String str = string + getString(2131300845);
            5 5 = new 5(this);
            Spannable newSpannable = Factory.getInstance().newSpannable(str);
            int length = string.length();
            int length2 = newSpannable.length();
            if (length < 0 || length >= length2 || length2 < 0 || length2 > newSpannable.length()) {
                newSpannable.setSpan(5, 0, newSpannable.length(), 33);
            } else {
                newSpannable.setSpan(5, length, length2, 33);
            }
            this.nFz.setText(newSpannable);
            this.nFz.setMovementMethod(LinkMovementMethod.getInstance());
            this.nFz.setVisibility(0);
        } else {
            this.nFz.setVisibility(8);
        }
        LinearLayout linearLayout = (LinearLayout) findViewById(2131825054);
        if (linearLayout != null && this.nFk.getVisibility() == 8 && this.nFn.getVisibility() == 8) {
            linearLayout.setVisibility(8);
        }
        linearLayout = (LinearLayout) findViewById(2131825061);
        if (linearLayout != null && this.nFr.getVisibility() == 8 && this.nFs.getVisibility() == 8) {
            linearLayout.setVisibility(8);
        }
        this.nFF.start();
        AppMethodBeat.o(22335);
    }

    public void onResume() {
        AppMethodBeat.i(22336);
        super.onResume();
        com.tencent.mm.plugin.ipcall.a.f.b.bHU().it(false);
        AppMethodBeat.o(22336);
    }

    public void onDestroy() {
        AppMethodBeat.i(22337);
        super.onDestroy();
        aw.Rg().b(257, this);
        a.xxA.d(this.nBm);
        this.nFF.nyL = bo.anU();
        this.nFF.finish();
        AppMethodBeat.o(22337);
    }

    public final int getLayoutId() {
        return 2130969887;
    }

    private void refreshView() {
        AppMethodBeat.i(22338);
        if (!bo.isNullOrNil(this.nEU)) {
            if (this.nET == null) {
                this.nFE.setValue(this.nEU, this.nEU);
            } else {
                this.nFE.setValue(this.nET, this.nEU);
            }
            this.nET = this.nEU;
        }
        this.nFB.getText();
        this.nFB.setText(this.nEV);
        if (bo.isNullOrNil(this.nEV)) {
            this.nFB.setVisibility(8);
        } else {
            this.nFB.setVisibility(0);
        }
        StringBuffer stringBuffer = new StringBuffer(BuildConfig.FLAVOR);
        if (this.nFG != null && this.nFG.size() > 0) {
            Iterator it = this.nFG.iterator();
            while (it.hasNext()) {
                crw crw = (crw) it.next();
                if (!(crw == null || bo.isNullOrNil(crw.xpw))) {
                    stringBuffer.append(crw.xpw).append(10);
                }
            }
        }
        if (bo.isNullOrNil(stringBuffer.toString())) {
            this.nFC.setText(BuildConfig.FLAVOR);
            this.nFC.setVisibility(8);
        } else {
            if (stringBuffer.charAt(stringBuffer.length() - 1) == 10) {
                stringBuffer.deleteCharAt(stringBuffer.length() - 1);
            }
            this.nFC.setText(stringBuffer.toString());
            this.nFC.setVisibility(0);
        }
        if (this.nFB.getVisibility() == 0 && this.nFC.getVisibility() == 0) {
            this.nFD.setVisibility(0);
            AppMethodBeat.o(22338);
            return;
        }
        this.nFD.setVisibility(8);
        AppMethodBeat.o(22338);
    }

    public void onSceneEnd(int i, int i2, String str, m mVar) {
        AppMethodBeat.i(22339);
        if (mVar instanceof com.tencent.mm.plugin.ipcall.a.d.g) {
            if (i == 0 && i2 == 0) {
                a(((com.tencent.mm.plugin.ipcall.a.d.g) mVar).nyt);
                refreshView();
                if (this.nBv != null && this.nBv.isShowing()) {
                    this.nBv.dismiss();
                }
                AppMethodBeat.o(22339);
                return;
            } else if (this.nBv != null && this.nBv.isShowing()) {
                this.nBv.dismiss();
                h.a(this.mController.ylL, getString(2131300737), getString(2131300730), new 7(this));
            }
        }
        AppMethodBeat.o(22339);
    }

    private void a(aqq aqq) {
        this.nEP = aqq.wut;
        this.eeO = aqq.Desc;
        this.nEQ = aqq.wuu;
        this.mTitle = aqq.Title;
        this.nER = aqq.nzz;
        this.nES = aqq.wuv;
        this.nEU = aqq.wuw;
        this.nEV = aqq.wux;
        this.nEW = aqq.wuy;
        this.nFG = aqq.wuh;
    }

    static /* synthetic */ void d(IPCallShareCouponUI iPCallShareCouponUI) {
        AppMethodBeat.i(22340);
        b bVar = iPCallShareCouponUI.nFF;
        bVar.nyN++;
        com.tencent.mm.plugin.report.service.h.pYm.a(257, 2, 1, true);
        String string = ah.getContext().getString(2131300743);
        try {
            com.tencent.mm.kernel.g.RN();
            int QF = com.tencent.mm.kernel.a.QF();
            String encode = URLEncoder.encode(d.DEVICE_NAME, "utf-8");
            String encode2 = URLEncoder.encode(bo.dpA(), "utf-8");
            String encode3 = URLEncoder.encode(q.LK(), "utf-8");
            String encode4 = URLEncoder.encode(d.vxi, "utf-8");
            String encode5 = URLEncoder.encode(d.vxj, "utf-8");
            String encode6 = URLEncoder.encode(d.vxk, "utf-8");
            String encode7 = URLEncoder.encode(aw.Rb(), "utf-8");
            string = string + "&version=" + d.vxo + "&lang=" + aa.gw(ah.getContext()) + ("&uin=" + QF + "&deviceName=" + encode + "&timeZone=" + encode2 + "&imei=" + encode3 + "&deviceBrand=" + encode4 + "&deviceModel=" + encode5 + "&ostype=" + encode6 + "&clientSeqID=" + encode7 + "&signature=" + URLEncoder.encode(bo.gS(ah.getContext()), "utf-8") + "&scene=0");
        } catch (UnsupportedEncodingException e) {
            ab.e("MicroMsg.IPCallShareCouponUI", "[royle]UnsupportedEncodingException:%s", new Object[]{e.getMessage()});
        }
        Intent intent = new Intent();
        intent.putExtra("rawUrl", string);
        intent.putExtra("showShare", false);
        com.tencent.mm.bp.d.b(iPCallShareCouponUI, "webview", ".ui.tools.WebViewUI", intent);
        AppMethodBeat.o(22340);
    }

    static /* synthetic */ void e(IPCallShareCouponUI iPCallShareCouponUI) {
        AppMethodBeat.i(22341);
        b bVar = iPCallShareCouponUI.nFF;
        bVar.nyO++;
        com.tencent.mm.plugin.report.service.h.pYm.a(257, 3, 1, true);
        Intent intent = new Intent();
        intent.putExtra("rawUrl", iPCallShareCouponUI.getString(2131300712));
        intent.putExtra("showShare", false);
        com.tencent.mm.bp.d.b(iPCallShareCouponUI, "webview", ".ui.tools.WebViewUI", intent);
        AppMethodBeat.o(22341);
    }

    static /* synthetic */ void f(IPCallShareCouponUI iPCallShareCouponUI) {
        AppMethodBeat.i(22342);
        b bVar = iPCallShareCouponUI.nFF;
        bVar.nyM++;
        com.tencent.mm.plugin.report.service.h.pYm.a(257, 1, 1, true);
        aw.ZK();
        com.tencent.mm.model.c.Ry().set(ac.a.xLA, Boolean.FALSE);
        iPCallShareCouponUI.nFA.setVisibility(8);
        Intent intent = new Intent();
        intent.putExtra("rawUrl", iPCallShareCouponUI.getString(2131300728));
        intent.putExtra("showShare", false);
        com.tencent.mm.bp.d.b(iPCallShareCouponUI, "webview", ".ui.tools.WebViewUI", intent);
        AppMethodBeat.o(22342);
    }

    static /* synthetic */ void i(IPCallShareCouponUI iPCallShareCouponUI) {
        AppMethodBeat.i(22343);
        aqq bIU = com.tencent.mm.plugin.ipcall.b.c.bIU();
        if (!(bIU == null || bo.isNullOrNil(bIU.wuD))) {
            Intent intent = new Intent();
            intent.putExtra("rawUrl", bIU.wuD);
            intent.putExtra("showShare", false);
            com.tencent.mm.bp.d.b(iPCallShareCouponUI, "webview", ".ui.tools.WebViewUI", intent);
        }
        AppMethodBeat.o(22343);
    }
}
