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

import android.content.Intent;
import android.view.MenuItem;
import android.view.MenuItem.OnMenuItemClickListener;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.plugin.gallery.model.GalleryItem.MediaItem;
import com.tencent.mm.plugin.gallery.model.e;
import com.tencent.mm.plugin.gallery.model.g;
import java.util.ArrayList;

class ImagePreviewUI$27 implements OnMenuItemClickListener {
    final /* synthetic */ ImagePreviewUI mRu;

    ImagePreviewUI$27(ImagePreviewUI imagePreviewUI) {
        this.mRu = imagePreviewUI;
    }

    public final boolean onMenuItemClick(MenuItem menuItem) {
        int i;
        boolean z;
        int i2 = 0;
        AppMethodBeat.i(21528);
        if (ImagePreviewUI.k(this.mRu) == 6) {
            this.mRu.setResult(1);
            this.mRu.finish();
        }
        Intent intent = new Intent();
        intent.putExtra("isPreviewPhoto", this.mRu.getIntent().getBooleanExtra("isPreviewPhoto", false));
        ArrayList l = ImagePreviewUI.l(this.mRu);
        if (l == null || l.size() != 0) {
            i = 0;
        } else {
            MediaItem wz = ImagePreviewUI.h(this.mRu).wz(ImagePreviewUI.g(this.mRu).intValue());
            if (!ImagePreviewUI.m(this.mRu) || ImagePreviewUI.h(this.mRu) == null || wz == null || wz.getType() != 2) {
                ImagePreviewUI.e(this.mRu).performClick();
                i = 300;
            } else {
                ImagePreviewUI.a(this.mRu, wz.fPT);
                i = 0;
            }
        }
        if (ImagePreviewUI.b(this.mRu)) {
            z = false;
        } else {
            z = true;
        }
        boolean m = ImagePreviewUI.m(this.mRu);
        if (i == 0) {
            ImagePreviewUI.a(this.mRu, intent, m, z);
            AppMethodBeat.o(21528);
        } else {
            g bCa = e.bCa();
            1 1 = new 1(this, intent, m, z);
            if (i >= 0) {
                i2 = i;
            }
            bCa.bCo().postDelayed(1, (long) i2);
            AppMethodBeat.o(21528);
        }
        return true;
    }
}
