PopupMenu.java 4.14 KB
package android.support.v7.widget;

import android.content.Context;
import android.support.annotation.AttrRes;
import android.support.annotation.MenuRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StyleRes;
import android.support.v7.appcompat.R.attr;
import android.support.v7.view.SupportMenuInflater;
import android.support.v7.view.menu.MenuBuilder;
import android.support.v7.view.menu.MenuBuilder.Callback;
import android.support.v7.view.menu.MenuPopupHelper;
import android.support.v7.view.menu.ShowableListMenu;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.PopupWindow.OnDismissListener;

public class PopupMenu
{
  final MenuPopupHelper a;
  OnMenuItemClickListener b;
  OnDismissListener c;
  private final Context d;
  private final MenuBuilder e;
  private final View f;
  private View.OnTouchListener g;
  
  public PopupMenu(@NonNull Context paramContext, @NonNull View paramView)
  {
    this(paramContext, paramView, 0);
  }
  
  public PopupMenu(@NonNull Context paramContext, @NonNull View paramView, int paramInt)
  {
    this(paramContext, paramView, paramInt, R.attr.popupMenuStyle, 0);
  }
  
  public PopupMenu(@NonNull Context paramContext, @NonNull View paramView, int paramInt1, @AttrRes int paramInt2, @StyleRes int paramInt3)
  {
    this.d = paramContext;
    this.f = paramView;
    this.e = new MenuBuilder(paramContext);
    this.e.setCallback(new MenuBuilder.Callback()
    {
      public final boolean onMenuItemSelected(MenuBuilder paramAnonymousMenuBuilder, MenuItem paramAnonymousMenuItem)
      {
        if (PopupMenu.this.b != null) {
          return PopupMenu.this.b.onMenuItemClick(paramAnonymousMenuItem);
        }
        return false;
      }
      
      public final void onMenuModeChange(MenuBuilder paramAnonymousMenuBuilder) {}
    });
    this.a = new MenuPopupHelper(paramContext, this.e, paramView, false, paramInt2, paramInt3);
    this.a.setGravity(paramInt1);
    this.a.setOnDismissListener(new PopupWindow.OnDismissListener()
    {
      public final void onDismiss()
      {
        if (PopupMenu.this.c != null) {
          PopupMenu.this.c.onDismiss(PopupMenu.this);
        }
      }
    });
  }
  
  public void dismiss()
  {
    this.a.dismiss();
  }
  
  @NonNull
  public View.OnTouchListener getDragToOpenListener()
  {
    if (this.g == null) {
      this.g = new ForwardingListener(this.f)
      {
        public final ShowableListMenu getPopup()
        {
          return PopupMenu.this.a.getPopup();
        }
        
        protected final boolean onForwardingStarted()
        {
          PopupMenu.this.show();
          return true;
        }
        
        protected final boolean onForwardingStopped()
        {
          PopupMenu.this.dismiss();
          return true;
        }
      };
    }
    return this.g;
  }
  
  public int getGravity()
  {
    return this.a.getGravity();
  }
  
  @NonNull
  public Menu getMenu()
  {
    return this.e;
  }
  
  @NonNull
  public MenuInflater getMenuInflater()
  {
    return new SupportMenuInflater(this.d);
  }
  
  public void inflate(@MenuRes int paramInt)
  {
    getMenuInflater().inflate(paramInt, this.e);
  }
  
  public void setGravity(int paramInt)
  {
    this.a.setGravity(paramInt);
  }
  
  public void setOnDismissListener(@Nullable OnDismissListener paramOnDismissListener)
  {
    this.c = paramOnDismissListener;
  }
  
  public void setOnMenuItemClickListener(@Nullable OnMenuItemClickListener paramOnMenuItemClickListener)
  {
    this.b = paramOnMenuItemClickListener;
  }
  
  public void show()
  {
    this.a.show();
  }
  
  public static abstract interface OnDismissListener
  {
    public abstract void onDismiss(PopupMenu paramPopupMenu);
  }
  
  public static abstract interface OnMenuItemClickListener
  {
    public abstract boolean onMenuItemClick(MenuItem paramMenuItem);
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/android/support/v7/widget/PopupMenu.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */