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

import android.os.Bundle;
import android.view.KeyEvent;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.plugin.qqmail.b.ac;
import com.tencent.mm.plugin.qqmail.b.v.a;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.ui.MMActivity;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class CompressPreviewUI extends MMActivity {
    private ProgressBar juA;
    private TextView mKx;
    private String ptI = null;
    private String pux = null;
    private String pvZ;
    private c pwy = new c(this);
    private long pxn = 0;
    private List<a> pxo = new ArrayList();
    private String pxp;
    private ListView pxq;
    private b pxr;
    private a pxs = new 5(this);

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

    public CompressPreviewUI() {
        AppMethodBeat.i(68251);
        AppMethodBeat.o(68251);
    }

    static /* synthetic */ void a(CompressPreviewUI compressPreviewUI, String str) {
        AppMethodBeat.i(68259);
        compressPreviewUI.Vp(str);
        AppMethodBeat.o(68259);
    }

    static /* synthetic */ void i(CompressPreviewUI compressPreviewUI) {
        AppMethodBeat.i(68260);
        compressPreviewUI.ccW();
        AppMethodBeat.o(68260);
    }

    public final int getLayoutId() {
        return 2130970014;
    }

    public void onCreate(Bundle bundle) {
        AppMethodBeat.i(68252);
        super.onCreate(bundle);
        this.ptI = getIntent().getStringExtra("mail_id");
        this.pux = getIntent().getStringExtra("attach_id");
        this.pxn = getIntent().getLongExtra("attach_size", 0);
        this.pvZ = getIntent().getStringExtra("attach_name");
        initView();
        setMMTitle(this.pvZ);
        AppMethodBeat.o(68252);
    }

    public final void initView() {
        AppMethodBeat.i(68253);
        this.pxq = (ListView) findViewById(2131825698);
        this.mKx = (TextView) findViewById(2131825699);
        this.juA = (ProgressBar) findViewById(2131825700);
        if (this.ptI == null || this.pux == null) {
            this.juA.setVisibility(8);
            this.mKx.setText(2131301265);
            AppMethodBeat.o(68253);
            return;
        }
        this.pxr = new b(this, (byte) 0);
        this.pxq.setAdapter(this.pxr);
        this.pxq.setOnItemClickListener(new 1(this));
        setBackBtn(new 2(this));
        3 3 = new 3(this);
        addTextOptionMenu(0, getString(2131296887), new 4(this));
        ccW();
        AppMethodBeat.o(68253);
    }

    public void onDestroy() {
        AppMethodBeat.i(68254);
        super.onDestroy();
        this.pwy.release();
        AppMethodBeat.o(68254);
    }

    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        AppMethodBeat.i(68255);
        if (i == 4 && this.pxr.ccY() != null) {
            Vp(this.pxr.ccY());
            AppMethodBeat.o(68255);
            return true;
        } else if (keyEvent == null) {
            finish();
            AppMethodBeat.o(68255);
            return true;
        } else {
            boolean onKeyDown = super.onKeyDown(i, keyEvent);
            AppMethodBeat.o(68255);
            return onKeyDown;
        }
    }

    private void Vp(String str) {
        AppMethodBeat.i(68256);
        ab.i("MicroMsg.CompressPreviewUI", "curPath=".concat(String.valueOf(str)));
        this.juA.setVisibility(8);
        this.mKx.setVisibility(8);
        this.pxq.setVisibility(0);
        a Vq = Vq(str);
        ArrayList arrayList = new ArrayList();
        if (Vq != null) {
            arrayList.add(Vq);
        }
        for (int i = 0; i < this.pxo.size(); i++) {
            a aVar = (a) this.pxo.get(i);
            if ((str.endsWith(aVar.pxv) && aVar.pxv.length() > 0) || aVar.pxv.equals(str)) {
                arrayList.add(aVar);
            }
        }
        this.pxr.a(Vq, arrayList);
        this.pxr.notifyDataSetChanged();
        this.pxq.setSelection(0);
        AppMethodBeat.o(68256);
    }

    private a Vq(String str) {
        AppMethodBeat.i(68257);
        for (a aVar : this.pxo) {
            if (aVar.id.equals(str)) {
                AppMethodBeat.o(68257);
                return aVar;
            }
        }
        AppMethodBeat.o(68257);
        return null;
    }

    private void ccW() {
        AppMethodBeat.i(68258);
        HashMap hashMap = new HashMap();
        hashMap.put("mailid", this.ptI);
        hashMap.put("attachid", this.pux);
        hashMap.put("fun", "list");
        ac.ccC().a("/cgi-bin/viewcompress", hashMap, this.pxs);
        AppMethodBeat.o(68258);
    }
}
