NavigationMenuItemView.java 8.31 KB
package android.support.design.internal;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable.ConstantState;
import android.graphics.drawable.StateListDrawable;
import android.support.annotation.RestrictTo;
import android.support.design.R.dimen;
import android.support.design.R.drawable;
import android.support.design.R.id;
import android.support.design.R.layout;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v4.view.AccessibilityDelegateCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
import android.support.v4.widget.TextViewCompat;
import android.support.v7.appcompat.R.attr;
import android.support.v7.view.menu.MenuItemImpl;
import android.support.v7.view.menu.MenuView.ItemView;
import android.support.v7.widget.LinearLayoutCompat.LayoutParams;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewStub;
import android.widget.CheckedTextView;
import android.widget.FrameLayout;

@RestrictTo({android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP})
public class NavigationMenuItemView
  extends ForegroundLinearLayout
  implements MenuView.ItemView
{
  private static final int[] c = { 16842912 };
  boolean b;
  private final int d;
  private boolean e;
  private final CheckedTextView f;
  private FrameLayout g;
  private MenuItemImpl h;
  private ColorStateList i;
  private boolean j;
  private Drawable k;
  private final AccessibilityDelegateCompat l = new AccessibilityDelegateCompat()
  {
    public final void onInitializeAccessibilityNodeInfo(View paramAnonymousView, AccessibilityNodeInfoCompat paramAnonymousAccessibilityNodeInfoCompat)
    {
      super.onInitializeAccessibilityNodeInfo(paramAnonymousView, paramAnonymousAccessibilityNodeInfoCompat);
      paramAnonymousAccessibilityNodeInfoCompat.setCheckable(NavigationMenuItemView.this.b);
    }
  };
  
  public NavigationMenuItemView(Context paramContext)
  {
    this(paramContext, null);
  }
  
  public NavigationMenuItemView(Context paramContext, AttributeSet paramAttributeSet)
  {
    this(paramContext, paramAttributeSet, 0);
  }
  
  public NavigationMenuItemView(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
  {
    super(paramContext, paramAttributeSet, paramInt);
    setOrientation(0);
    LayoutInflater.from(paramContext).inflate(R.layout.design_navigation_menu_item, this, true);
    this.d = paramContext.getResources().getDimensionPixelSize(R.dimen.design_navigation_icon_size);
    this.f = ((CheckedTextView)findViewById(R.id.design_menu_item_text));
    this.f.setDuplicateParentStateEnabled(true);
    ViewCompat.setAccessibilityDelegate(this.f, this.l);
  }
  
  private void setActionView(View paramView)
  {
    if (paramView != null)
    {
      if (this.g == null) {
        this.g = ((FrameLayout)((ViewStub)findViewById(R.id.design_menu_item_action_area_stub)).inflate());
      }
      this.g.removeAllViews();
      this.g.addView(paramView);
    }
  }
  
  public MenuItemImpl getItemData()
  {
    return this.h;
  }
  
  public void initialize(MenuItemImpl paramMenuItemImpl, int paramInt)
  {
    this.h = paramMenuItemImpl;
    StateListDrawable localStateListDrawable;
    if (paramMenuItemImpl.isVisible())
    {
      paramInt = 0;
      setVisibility(paramInt);
      if (getBackground() == null)
      {
        TypedValue localTypedValue = new TypedValue();
        if (!getContext().getTheme().resolveAttribute(R.attr.colorControlHighlight, localTypedValue, true)) {
          break label232;
        }
        localStateListDrawable = new StateListDrawable();
        localStateListDrawable.addState(c, new ColorDrawable(localTypedValue.data));
        localStateListDrawable.addState(EMPTY_STATE_SET, new ColorDrawable(0));
        label96:
        ViewCompat.setBackground(this, localStateListDrawable);
      }
      setCheckable(paramMenuItemImpl.isCheckable());
      setChecked(paramMenuItemImpl.isChecked());
      setEnabled(paramMenuItemImpl.isEnabled());
      setTitle(paramMenuItemImpl.getTitle());
      setIcon(paramMenuItemImpl.getIcon());
      setActionView(paramMenuItemImpl.getActionView());
      if ((this.h.getTitle() != null) || (this.h.getIcon() != null) || (this.h.getActionView() == null)) {
        break label237;
      }
      paramInt = 1;
      label181:
      if (paramInt == 0) {
        break label242;
      }
      this.f.setVisibility(8);
      if (this.g != null)
      {
        paramMenuItemImpl = (LinearLayoutCompat.LayoutParams)this.g.getLayoutParams();
        paramMenuItemImpl.width = -1;
        this.g.setLayoutParams(paramMenuItemImpl);
      }
    }
    label232:
    label237:
    label242:
    do
    {
      return;
      paramInt = 8;
      break;
      localStateListDrawable = null;
      break label96;
      paramInt = 0;
      break label181;
      this.f.setVisibility(0);
    } while (this.g == null);
    paramMenuItemImpl = (LinearLayoutCompat.LayoutParams)this.g.getLayoutParams();
    paramMenuItemImpl.width = -2;
    this.g.setLayoutParams(paramMenuItemImpl);
  }
  
  protected int[] onCreateDrawableState(int paramInt)
  {
    int[] arrayOfInt = super.onCreateDrawableState(paramInt + 1);
    if ((this.h != null) && (this.h.isCheckable()) && (this.h.isChecked())) {
      mergeDrawableStates(arrayOfInt, c);
    }
    return arrayOfInt;
  }
  
  public boolean prefersCondensedTitle()
  {
    return false;
  }
  
  public void recycle()
  {
    if (this.g != null) {
      this.g.removeAllViews();
    }
    this.f.setCompoundDrawables(null, null, null, null);
  }
  
  public void setCheckable(boolean paramBoolean)
  {
    refreshDrawableState();
    if (this.b != paramBoolean)
    {
      this.b = paramBoolean;
      this.l.sendAccessibilityEvent(this.f, 2048);
    }
  }
  
  public void setChecked(boolean paramBoolean)
  {
    refreshDrawableState();
    this.f.setChecked(paramBoolean);
  }
  
  public void setIcon(Drawable paramDrawable)
  {
    Object localObject;
    if (paramDrawable != null)
    {
      localObject = paramDrawable;
      if (this.j)
      {
        localObject = paramDrawable.getConstantState();
        if (localObject == null)
        {
          localObject = DrawableCompat.wrap(paramDrawable).mutate();
          DrawableCompat.setTintList((Drawable)localObject, this.i);
        }
      }
      else
      {
        ((Drawable)localObject).setBounds(0, 0, this.d, this.d);
        paramDrawable = (Drawable)localObject;
      }
    }
    for (;;)
    {
      TextViewCompat.setCompoundDrawablesRelative(this.f, paramDrawable, null, null, null);
      return;
      paramDrawable = ((Drawable.ConstantState)localObject).newDrawable();
      break;
      if (this.e)
      {
        if (this.k == null)
        {
          this.k = ResourcesCompat.getDrawable(getResources(), R.drawable.navigation_empty_icon, getContext().getTheme());
          if (this.k != null) {
            this.k.setBounds(0, 0, this.d, this.d);
          }
        }
        paramDrawable = this.k;
      }
    }
  }
  
  void setIconTintList(ColorStateList paramColorStateList)
  {
    this.i = paramColorStateList;
    if (this.i != null) {}
    for (boolean bool = true;; bool = false)
    {
      this.j = bool;
      if (this.h != null) {
        setIcon(this.h.getIcon());
      }
      return;
    }
  }
  
  public void setNeedsEmptyIcon(boolean paramBoolean)
  {
    this.e = paramBoolean;
  }
  
  public void setShortcut(boolean paramBoolean, char paramChar) {}
  
  public void setTextAppearance(int paramInt)
  {
    TextViewCompat.setTextAppearance(this.f, paramInt);
  }
  
  public void setTextColor(ColorStateList paramColorStateList)
  {
    this.f.setTextColor(paramColorStateList);
  }
  
  public void setTitle(CharSequence paramCharSequence)
  {
    this.f.setText(paramCharSequence);
  }
  
  public boolean showsIcon()
  {
    return true;
  }
}


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