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

import android.content.Intent;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.view.MenuItem.OnMenuItemClickListener;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.matrix.trace.e.b;
import com.tencent.mm.hardcoder.WXHardCoderJNI;
import com.tencent.mm.kernel.g;
import com.tencent.mm.model.r;
import com.tencent.mm.plugin.messenger.foundation.a.j;
import com.tencent.mm.plugin.sns.b.h.a;
import com.tencent.mm.plugin.sns.data.i;
import com.tencent.mm.plugin.sns.model.af;
import com.tencent.mm.plugin.sns.model.am;
import com.tencent.mm.pluginsdk.ui.tools.n;
import com.tencent.mm.sdk.b.c;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.storage.ac;
import com.tencent.mm.storage.ad;
import com.tencent.mm.storage.bd;
import com.tencent.mm.ui.MMActivity;
import com.tencent.mm.ui.base.h;
import com.tencent.mm.ui.statusbar.d;
import com.tencent.ttpic.baseutils.ApiHelper$VERSION_CODES;
import com.tencent.ttpic.util.ActUtil;
import com.tencent.ytcommon.BuildConfig;

public class SnsUserUI extends MMActivity implements a {
    private long eEO = 0;
    private int ehv;
    private long fAq = 0;
    private c hAA = new 10(this);
    private String igi;
    private b mnM = new 14(this);
    private View plv;
    private com.tencent.mm.ui.statusbar.c.a plx;
    private as rCS;
    private SnsUIAction rCT;
    private am.a rCU;
    private SnsUIAction.a rCV;
    private RelativeLayout rCW = null;
    private TextView rCX = null;
    private int rCY = 0;
    private Runnable rCZ = new 1(this);
    private boolean rjn;
    private String ryC;
    private boolean ryD;
    private int ryE;
    private boolean ryx = false;
    private OnMenuItemClickListener rzm = new 7(this);

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

    public SnsUserUI() {
        AppMethodBeat.i(39814);
        AppMethodBeat.o(39814);
    }

    static /* synthetic */ void o(SnsUserUI snsUserUI) {
        AppMethodBeat.i(39831);
        snsUserUI.cuG();
        AppMethodBeat.o(39831);
    }

    public void onCreate(Bundle bundle) {
        AppMethodBeat.i(39815);
        if (this.mController != null) {
            this.mController.aC(2, false);
        }
        this.ylm = true;
        super.onCreate(bundle);
        if (g.RN().QY()) {
            com.tencent.mm.n.a aoO;
            this.plv = findViewById(2131820940);
            if (this.plv != null && com.tencent.mm.ui.statusbar.c.zzP) {
                com.tencent.mm.ui.statusbar.c az = com.tencent.mm.ui.statusbar.c.az(this);
                4 4 = new 4(this);
                this.plx = 4;
                az.a(4);
                getWindow().getDecorView().requestApplyInsets();
                d.a(getWindow());
            }
            getWindow().getDecorView().setSystemUiVisibility(ActUtil.HEIGHT);
            xE(this.mController.ylL.getResources().getColor(2131690597));
            b(new 11(this), new 12(this));
            this.rCU = af.cnv();
            this.ryE = getIntent().getIntExtra("sns_source", 0);
            this.igi = getIntent().getStringExtra("sns_userName");
            if (this.igi == null) {
                this.igi = BuildConfig.FLAVOR;
            }
            g.RQ();
            this.ryD = ((j) g.K(j.class)).XM().aoJ(this.igi);
            this.ryC = r.Yz();
            this.rjn = this.ryC.equals(this.igi);
            bd cnt = af.cnt();
            String bc = bo.bc(getIntent().getStringExtra("sns_signature"), BuildConfig.FLAVOR);
            String bc2 = bo.bc(getIntent().getStringExtra("sns_nickName"), BuildConfig.FLAVOR);
            if (this.igi == null || this.igi.equals(BuildConfig.FLAVOR)) {
                aoO = cnt.aoO(this.ryC);
            } else {
                aoO = cnt.aoO(this.igi);
            }
            if (aoO != null && ((int) aoO.ewQ) > 0) {
                bc = aoO.signature;
                bc2 = aoO.Oi();
                ab.i("MicroMsg.SnsUserUI", "contact:user[%s] id[%d] nickname[%s]", new Object[]{aoO.field_username, Integer.valueOf((int) aoO.ewQ), bc2});
            }
            this.rCT = new SnsUIAction(this);
            this.rCT.a(this.ryC, this.igi, bc2, bc, this.ryD, this.rjn, this.ryE);
            SnsUIAction snsUIAction = this.rCT;
            13 13 = new 13(this);
            this.rCV = 13;
            snsUIAction.rBP = 13;
            this.rCT.onCreate();
            getIntent().setExtrasClassLoader(getClass().getClassLoader());
            initView();
            com.tencent.mm.sdk.b.a.xxA.c(this.hAA);
            AppMethodBeat.o(39815);
            return;
        }
        finish();
        AppMethodBeat.o(39815);
    }

    public void onDestroy() {
        AppMethodBeat.i(39816);
        af.bCo().removeCallbacks(this.rCZ);
        this.ryx = true;
        com.tencent.mm.sdk.b.a.xxA.d(this.hAA);
        com.tencent.mm.modelsns.b u = com.tencent.mm.modelsns.b.u(getIntent());
        if (u != null) {
            u.update();
            u.ajK();
        }
        if (!(this.rCT == null || this.rCT.tipDialog == null)) {
            this.rCT.tipDialog.dismiss();
            this.rCT.tipDialog = null;
        }
        g.RQ();
        if (g.RN().QY() && this.rCU != null) {
            this.rCU.a(this, this.rCV.getType());
        }
        if (this.rCT != null) {
            this.rCT.onDestroy();
        }
        super.onDestroy();
        AppMethodBeat.o(39816);
    }

    public void onDrag() {
        AppMethodBeat.i(39817);
        super.onDrag();
        AppMethodBeat.o(39817);
    }

    public final int getLayoutId() {
        return 2130970795;
    }

    public void onResume() {
        AppMethodBeat.i(39818);
        this.fAq = bo.anT();
        if (com.tencent.matrix.a.isInstalled() && com.tencent.matrix.a.yK().F(com.tencent.matrix.trace.a.class) != null) {
            com.tencent.matrix.trace.f.c cVar = ((com.tencent.matrix.trace.a) com.tencent.matrix.a.yK().F(com.tencent.matrix.trace.a.class)).bYx;
            if (cVar != null) {
                cVar.a(this.mnM);
            }
        }
        if (this.rCS != null) {
            this.rCS.notifyDataSetChanged();
        }
        setRequestedOrientation(-1);
        if (this.rjn) {
            b(getString(2131303715), 2131230749, new 3(this));
        } else {
            enableOptionMenu(false);
        }
        setBackBtn(this.rzm, 2131230737);
        if (this.rjn) {
            setMMTitle(2131303740);
        } else {
            CharSequence Oj;
            ab.d("MicroMsg.SnsUserUI", "SnsUserUI, userName:%s, title:%s", new Object[]{this.igi, this.rCT.title});
            ad aoO = af.cnt().aoO(this.igi);
            if (aoO != null) {
                ab.d("MicroMsg.SnsUserUI", "SnsUserUI, contact is not null");
                Oj = aoO.Oj();
            } else {
                ab.d("MicroMsg.SnsUserUI", "SnsUserUI, contact is null, title:%s", new Object[]{this.rCT.title});
                Oj = this.rCT.title;
            }
            setMMTitle(i.K(Oj));
        }
        this.rCT.onResume();
        super.onResume();
        AppMethodBeat.o(39818);
    }

    public void onPause() {
        AppMethodBeat.i(39819);
        WXHardCoderJNI.stopPerformance(WXHardCoderJNI.hcSNSUserScrollEnable, this.ehv);
        this.ehv = 0;
        this.rCT.onPause();
        super.onPause();
        if (com.tencent.matrix.a.isInstalled() && com.tencent.matrix.a.yK().F(com.tencent.matrix.trace.a.class) != null) {
            com.tencent.matrix.trace.f.c cVar = ((com.tencent.matrix.trace.a) com.tencent.matrix.a.yK().F(com.tencent.matrix.trace.a.class)).bYx;
            if (cVar != null) {
                cVar.b(this.mnM);
            }
        }
        this.fAq = bo.anT() > this.fAq ? bo.anT() - this.fAq : 1;
        WXHardCoderJNI.reportFPS(704, WXHardCoderJNI.hcSNSUserScrollAction, 1, this.eEO, this.fAq);
        this.eEO = 0;
        this.fAq = 0;
        AppMethodBeat.o(39819);
    }

    public final void initView() {
        AppMethodBeat.i(39820);
        this.rCW = (RelativeLayout) findViewById(2131827839);
        this.rCX = (TextView) findViewById(2131827840);
        this.rCW.post(new 15(this));
        this.rCS = new as(this, new 16(this), this.igi, new 17(this));
        this.rCT.nDp.setAdapter(this.rCS);
        this.rCT.nDp.setOnItemClickListener(new OnItemClickListener() {
            public final void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
            }
        });
        this.rCT.nDp.postDelayed(new 2(this), 500);
        setBackBtn(this.rzm, 2131230737);
        AppMethodBeat.o(39820);
    }

    public final void a(boolean z, boolean z2, String str, boolean z3, boolean z4, int i, long j, String str2) {
        AppMethodBeat.i(39821);
        if (this.rCS != null) {
            this.rCS.rmL = str;
            if (str.compareTo(this.rCS.lQD) < 0) {
                ab.i("MicroMsg.SnsUserUI", "onFpSetSize addsize %s %s isNeedNP %s", new Object[]{str, this.rCS.lQD, Boolean.valueOf(z)});
                this.rCS.ctK();
            } else {
                ab.i("MicroMsg.SnsUserUI", "onFpSetSize addsize passed %s %s isNeedNP %s", new Object[]{str, this.rCS.lQD, Boolean.valueOf(z)});
            }
            this.rCS.crP();
        }
        if ((z4 || !bo.isNullOrNil(str2)) && !this.ryC.equals(this.igi)) {
            this.rCT.koC = true;
            this.rCT.bf(i, str2);
        } else {
            if (this.ryC.equals(this.igi) && j != 0) {
                g.RQ();
                g.RP().Ry().set(ac.a.xQk, Long.valueOf(j));
                this.rCS.kI(j);
            }
            this.rCT.koC = z2;
            if (z2) {
                this.rCT.lc(false);
            } else if (z) {
                this.rCU.b(this.rCV.getType(), this.igi, this.rjn, this.ryE);
            }
        }
        if (z3) {
            this.rCT.qQt.cti();
        }
        AppMethodBeat.o(39821);
    }

    public final void a(boolean z, String str, boolean z2, boolean z3, int i, long j, String str2) {
        AppMethodBeat.i(39822);
        af.bCo().removeCallbacks(this.rCZ);
        if (this.rCS != null) {
            this.rCS.rvv = z2;
            this.rCS.rmL = str;
            if (str.compareTo(this.rCS.lQD) < 0) {
                ab.i("MicroMsg.SnsUserUI", "onNpAddSize addsize %s %s", new Object[]{str, this.rCS.lQD});
                this.rCS.ctK();
            } else {
                ab.i("MicroMsg.SnsUserUI", "onNpAddSize addsize passed %s %s", new Object[]{str, this.rCS.lQD});
            }
            this.rCS.crP();
        }
        if (!z3 || this.ryC.equals(this.igi)) {
            if (this.ryC.equals(this.igi) && j != 0) {
                g.RQ();
                g.RP().Ry().set(ac.a.xQk, Long.valueOf(j));
                this.rCS.kI(j);
            }
            this.rCT.koC = z;
            if (z) {
                this.rCT.lc(false);
            }
            AppMethodBeat.o(39822);
            return;
        }
        this.rCT.koC = true;
        this.rCT.bf(i, str2);
        AppMethodBeat.o(39822);
    }

    public final void xE(int i) {
        AppMethodBeat.i(39823);
        super.xE(i);
        if (VERSION.SDK_INT >= 21 && this.plv != null) {
            this.plv.setBackgroundColor(getWindow().getStatusBarColor());
            d.a(getWindow());
        }
        AppMethodBeat.o(39823);
    }

    private void cuG() {
        AppMethodBeat.i(39824);
        if (com.tencent.mm.r.a.bH(this)) {
            AppMethodBeat.o(39824);
            return;
        }
        ab.d("MicroMsg.SnsUserUI", "summerper checkPermission checkCamera[%b], stack[%s], activity[%s]", new Object[]{Boolean.valueOf(com.tencent.mm.pluginsdk.permission.b.a(this, "android.permission.CAMERA", 18, BuildConfig.FLAVOR, BuildConfig.FLAVOR)), bo.dpG(), this});
        if (com.tencent.mm.pluginsdk.permission.b.a(this, "android.permission.CAMERA", 18, BuildConfig.FLAVOR, BuildConfig.FLAVOR)) {
            ab.d("MicroMsg.SnsUserUI", "summerper checkPermission checkmicrophone[%b], stack[%s], activity[%s]", new Object[]{Boolean.valueOf(com.tencent.mm.pluginsdk.permission.b.a(this, "android.permission.RECORD_AUDIO", 18, BuildConfig.FLAVOR, BuildConfig.FLAVOR)), bo.dpG(), this});
            if (com.tencent.mm.pluginsdk.permission.b.a(this, "android.permission.RECORD_AUDIO", 18, BuildConfig.FLAVOR, BuildConfig.FLAVOR)) {
                n.G(this.mController.ylL, new Intent());
                AppMethodBeat.o(39824);
                return;
            }
            AppMethodBeat.o(39824);
            return;
        }
        AppMethodBeat.o(39824);
    }

    public void onBackPressed() {
        AppMethodBeat.i(39825);
        finish();
        AppMethodBeat.o(39825);
    }

    public boolean supportNavigationSwipeBack() {
        AppMethodBeat.i(39826);
        boolean supportNavigationSwipeBack = super.supportNavigationSwipeBack();
        AppMethodBeat.o(39826);
        return supportNavigationSwipeBack;
    }

    public void onActivityResult(int i, int i2, Intent intent) {
        AppMethodBeat.i(39827);
        ab.i("MicroMsg.SnsUserUI", "on activity result, %d %d", new Object[]{Integer.valueOf(i), Integer.valueOf(i2)});
        if (5985 == i && i2 == -1) {
            finish();
            AppMethodBeat.o(39827);
            return;
        }
        super.onActivityResult(i, i2, intent);
        this.rCT.onActivityResult(i, i2, intent);
        AppMethodBeat.o(39827);
    }

    public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
        AppMethodBeat.i(39828);
        if (iArr == null || iArr.length <= 0) {
            ab.i("MicroMsg.SnsUserUI", "onRequestPermissionsResult grantResults length 0. requestCode[%d], tid[%d]", new Object[]{Integer.valueOf(i), Long.valueOf(Thread.currentThread().getId())});
            AppMethodBeat.o(39828);
            return;
        }
        ab.i("MicroMsg.SnsUserUI", "onRequestPermissionsResult requestCode[%d],grantResults[%d] tid[%d]", new Object[]{Integer.valueOf(i), Integer.valueOf(iArr[0]), Long.valueOf(Thread.currentThread().getId())});
        switch (i) {
            case ApiHelper$VERSION_CODES.JELLY_BEAN_MR2 /*18*/:
                if (iArr[0] != 0) {
                    int i2 = "android.permission.CAMERA".equals(strArr[0]) ? 2131301920 : 2131301928;
                    if (iArr[0] != 0) {
                        h.a(this, getString(i2), getString(2131301936), getString(2131300878), getString(2131296868), false, new 8(this), new 9(this));
                        break;
                    }
                }
                cuG();
                AppMethodBeat.o(39828);
                return;
                break;
        }
        AppMethodBeat.o(39828);
    }

    static /* synthetic */ void i(SnsUserUI snsUserUI) {
        AppMethodBeat.i(39829);
        snsUserUI.rCW.setVisibility(8);
        AppMethodBeat.o(39829);
    }

    static /* synthetic */ void a(SnsUserUI snsUserUI, int i, int i2) {
        int i3;
        AppMethodBeat.i(39830);
        as asVar = snsUserUI.rCS;
        if (asVar.rgf.get(Integer.valueOf(i)) == null) {
            i3 = -1;
        } else {
            i3 = ((Integer) asVar.rgf.get(Integer.valueOf(i))).intValue();
        }
        ab.d("MicroMsg.SnsUserUI", "displayYearTip position:%d alpha:%d realPos:%d", new Object[]{Integer.valueOf(i), Integer.valueOf(i2), Integer.valueOf(i3)});
        if (i3 != -1) {
            Object item = snsUserUI.rCS.getItem(i3);
            if (item != null && (item instanceof com.tencent.mm.plugin.sns.storage.n)) {
                float f = ((float) i2) / 100.0f;
                if (f != snsUserUI.rCW.getAlpha()) {
                    snsUserUI.rCW.setAlpha(f);
                }
                snsUserUI.rCW.setVisibility(0);
                com.tencent.mm.plugin.sns.storage.n nVar = (com.tencent.mm.plugin.sns.storage.n) item;
                if (snsUserUI.rCY != nVar.field_head / 10000) {
                    snsUserUI.rCY = nVar.field_head / 10000;
                    snsUserUI.rCX.setText(String.format(snsUserUI.getResources().getString(2131303851), new Object[]{Integer.valueOf(snsUserUI.rCY)}));
                }
            }
        }
        AppMethodBeat.o(39830);
    }

    static /* synthetic */ void b(SnsUserUI snsUserUI, int i) {
        AppMethodBeat.i(39832);
        h.a(snsUserUI, 2131296882, 2131297061, 2131296994, 2131296868, new 5(snsUserUI, i), new 6(snsUserUI));
        AppMethodBeat.o(39832);
    }
}
