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

import android.os.Bundle;
import android.text.ClipboardManager;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.View;
import android.widget.TextView;
import android.widget.TextView.BufferType;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.plugin.sns.model.af;
import com.tencent.mm.plugin.sns.model.ap;
import com.tencent.mm.plugin.sns.model.ap.b;
import com.tencent.mm.plugin.sns.storage.n;
import com.tencent.mm.pluginsdk.ui.e.j;
import com.tencent.mm.pluginsdk.ui.e.m;
import com.tencent.mm.protocal.protobuf.cat;
import com.tencent.mm.sdk.b.a;
import com.tencent.mm.sdk.b.c;
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.ui.MMActivity;
import com.tencent.mm.ui.base.n.d;
import com.tencent.ytcommon.BuildConfig;
import java.io.IOException;

public class SnsSingleTextViewUI extends MMActivity {
    private String czD;
    private d jOb = new 5(this);
    private ClipboardManager mmO;
    private n qNM;
    protected int requestType = 0;
    private TextView rxb;
    private String rxc = null;
    private String rxd = null;
    private int rxe;
    private byte[] rxf = null;
    private cat rxg = null;
    private boolean rxh = false;
    private SnsTranslateResultView rxi;
    private c rxj = new 1(this);
    private c rxk = new 2(this);
    private c rxl = new 3(this);
    private String text;

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

    public SnsSingleTextViewUI() {
        AppMethodBeat.i(39306);
        AppMethodBeat.o(39306);
    }

    public void onCreate(Bundle bundle) {
        AppMethodBeat.i(39307);
        super.onCreate(bundle);
        this.mmO = (ClipboardManager) ah.getContext().getSystemService("clipboard");
        setMMTitle(2131303597);
        setBackBtn(new 4(this));
        this.text = getIntent().getStringExtra("sns_text_show");
        this.czD = bo.bc(getIntent().getStringExtra("sns_local_id"), BuildConfig.FLAVOR);
        this.rxf = getIntent().getByteArrayExtra("sns_comment_buf");
        if (this.rxf != null && this.rxf.length > 0) {
            this.rxg = new cat();
            try {
                long j;
                this.rxg.parseFrom(this.rxf);
                StringBuilder stringBuilder = new StringBuilder();
                if (this.rxg.wZG != 0) {
                    j = (long) this.rxg.wZG;
                } else {
                    j = this.rxg.wZJ;
                }
                this.rxc = stringBuilder.append(j).toString();
            } catch (IOException e) {
                ab.printErrStackTrace("MicroMsg.SnsSingleTextViewUI", e, "initCommentInfo error.", new Object[0]);
            }
        }
        this.qNM = af.cnF().YT(this.czD);
        if (bo.isNullOrNil(this.text)) {
            this.text = BuildConfig.FLAVOR;
        }
        this.rxb = (TextView) findViewById(2131827850);
        this.rxb.setText(this.text, BufferType.SPANNABLE);
        j.h(this.rxb, 2);
        this.rxb.setOnTouchListener(new m());
        new com.tencent.mm.ui.tools.j(this).a(this.rxb, this, this.jOb);
        this.rxi = (SnsTranslateResultView) findViewById(2131827715);
        this.rxi.setResultTextSize(this.rxb.getTextSize());
        if (this.qNM != null) {
            if (ctO()) {
                this.rxd = ap.ga(this.qNM.cqA(), this.rxc);
                this.rxe = 2;
            } else {
                this.rxd = this.qNM.cqA();
                this.rxe = 1;
            }
            if (ap.db(this.rxd, 8)) {
                b Ye = ap.Ye(this.rxd);
                if (Ye != null && Ye.foa) {
                    this.rxi.setVisibility(0);
                    this.rxi.a(null, this.rxe, Ye.result, Ye.fwM, false);
                    this.rxh = true;
                }
            }
        }
        a.xxA.c(this.rxj);
        a.xxA.c(this.rxk);
        a.xxA.c(this.rxl);
        AppMethodBeat.o(39307);
    }

    public void onDestroy() {
        AppMethodBeat.i(39308);
        super.onDestroy();
        a.xxA.d(this.rxj);
        a.xxA.d(this.rxk);
        a.xxA.d(this.rxl);
        AppMethodBeat.o(39308);
    }

    public final int getLayoutId() {
        return 2130970801;
    }

    public void onCreateContextMenu(ContextMenu contextMenu, View view, ContextMenuInfo contextMenuInfo) {
        boolean z = true;
        AppMethodBeat.i(39309);
        if (view instanceof TextView) {
            contextMenu.add(0, 0, 0, getString(2131296875));
            if (com.tencent.mm.bp.d.afj("favorite") && !ctO()) {
                contextMenu.add(0, 1, 0, getString(2131299589));
            }
            contextMenu.add(0, 6, 1, getString(2131296908));
            if (this.rxh) {
                if (ctO()) {
                    z = false;
                }
                ap.b(contextMenu, z);
            } else {
                if (ctO()) {
                    z = false;
                }
                ap.a(contextMenu, z);
                AppMethodBeat.o(39309);
                return;
            }
        }
        AppMethodBeat.o(39309);
    }

    private boolean ctO() {
        boolean z = false;
        AppMethodBeat.i(39310);
        if (!(this.rxg == null || ((this.rxg.wZG == 0 && this.rxg.wZJ == 0) || bo.isNullOrNil(this.rxg.ncM)))) {
            z = true;
        }
        AppMethodBeat.o(39310);
        return z;
    }
}
