package android.support.v7.widget;

import android.content.ComponentName;
import android.content.Intent;
import android.support.v7.widget.ActivityChooserView.a;
import android.support.v7.widget.e.c;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.PopupWindow.OnDismissListener;

class ActivityChooserView$b implements OnClickListener, OnLongClickListener, OnItemClickListener, OnDismissListener {
    final /* synthetic */ ActivityChooserView aeQ;

    ActivityChooserView$b(ActivityChooserView activityChooserView) {
        this.aeQ = activityChooserView;
    }

    public final void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
        switch (((a) adapterView.getAdapter()).getItemViewType(i)) {
            case 0:
                this.aeQ.hr();
                if (!this.aeQ.aeN) {
                    if (!this.aeQ.aeA.aeT) {
                        i++;
                    }
                    Intent bv = this.aeQ.aeA.aeR.bv(i);
                    if (bv != null) {
                        bv.addFlags(524288);
                        this.aeQ.getContext().startActivity(bv);
                        return;
                    }
                    return;
                } else if (i > 0) {
                    e eVar = this.aeQ.aeA.aeR;
                    synchronized (eVar.aen) {
                        float f;
                        eVar.hj();
                        e.a aVar = (e.a) eVar.aeo.get(i);
                        e.a aVar2 = (e.a) eVar.aeo.get(0);
                        if (aVar2 != null) {
                            f = (aVar2.weight - aVar.weight) + 5.0f;
                        } else {
                            f = 1.0f;
                        }
                        eVar.a(new c(new ComponentName(aVar.resolveInfo.activityInfo.packageName, aVar.resolveInfo.activityInfo.name), System.currentTimeMillis(), f));
                    }
                    return;
                } else {
                    return;
                }
            case 1:
                this.aeQ.bw(Integer.MAX_VALUE);
                return;
            default:
                throw new IllegalArgumentException();
        }
    }

    public final void onClick(View view) {
        if (view == this.aeQ.aeG) {
            this.aeQ.hr();
            Intent bv = this.aeQ.aeA.aeR.bv(this.aeQ.aeA.aeR.a(this.aeQ.aeA.aeR.hh()));
            if (bv != null) {
                bv.addFlags(524288);
                this.aeQ.getContext().startActivity(bv);
            }
        } else if (view == this.aeQ.aeE) {
            this.aeQ.aeN = false;
            this.aeQ.bw(this.aeQ.aeO);
        } else {
            throw new IllegalArgumentException();
        }
    }

    public final boolean onLongClick(View view) {
        if (view == this.aeQ.aeG) {
            if (this.aeQ.aeA.getCount() > 0) {
                this.aeQ.aeN = true;
                this.aeQ.bw(this.aeQ.aeO);
            }
            return true;
        }
        throw new IllegalArgumentException();
    }

    public final void onDismiss() {
        if (this.aeQ.aaN != null) {
            this.aeQ.aaN.onDismiss();
        }
        if (this.aeQ.aeJ != null) {
            this.aeQ.aeJ.E(false);
        }
    }
}
