BottomNavigationView.java 7.37 KB
package android.support.design.widget;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.os.Build.VERSION;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.R.color;
import android.support.design.R.dimen;
import android.support.design.R.style;
import android.support.design.R.styleable;
import android.support.design.internal.BottomNavigationMenu;
import android.support.design.internal.BottomNavigationMenuView;
import android.support.design.internal.BottomNavigationPresenter;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewCompat;
import android.support.v7.appcompat.R.attr;
import android.support.v7.content.res.AppCompatResources;
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.widget.TintTypedArray;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import r;

public class BottomNavigationView
  extends FrameLayout
{
  private static final int[] a = { 16842912 };
  private static final int[] b = { -16842910 };
  private final MenuBuilder c;
  private final BottomNavigationMenuView d;
  private final BottomNavigationPresenter e = new BottomNavigationPresenter();
  private MenuInflater f;
  private OnNavigationItemSelectedListener g;
  
  public BottomNavigationView(Context paramContext)
  {
    this(paramContext, null);
  }
  
  public BottomNavigationView(Context paramContext, AttributeSet paramAttributeSet)
  {
    this(paramContext, paramAttributeSet, 0);
  }
  
  public BottomNavigationView(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
  {
    super(paramContext, paramAttributeSet, paramInt);
    r.a(paramContext);
    this.c = new BottomNavigationMenu(paramContext);
    this.d = new BottomNavigationMenuView(paramContext);
    FrameLayout.LayoutParams localLayoutParams = new FrameLayout.LayoutParams(-2, -2);
    localLayoutParams.gravity = 17;
    this.d.setLayoutParams(localLayoutParams);
    this.e.setBottomNavigationMenuView(this.d);
    this.d.setPresenter(this.e);
    this.c.addMenuPresenter(this.e);
    this.e.initForMenu(getContext(), this.c);
    paramAttributeSet = TintTypedArray.obtainStyledAttributes(paramContext, paramAttributeSet, R.styleable.BottomNavigationView, paramInt, R.style.Widget_Design_BottomNavigationView);
    if (paramAttributeSet.hasValue(R.styleable.BottomNavigationView_itemIconTint))
    {
      this.d.setIconTintList(paramAttributeSet.getColorStateList(R.styleable.BottomNavigationView_itemIconTint));
      if (!paramAttributeSet.hasValue(R.styleable.BottomNavigationView_itemTextColor)) {
        break label345;
      }
      this.d.setItemTextColor(paramAttributeSet.getColorStateList(R.styleable.BottomNavigationView_itemTextColor));
    }
    for (;;)
    {
      if (paramAttributeSet.hasValue(R.styleable.BottomNavigationView_elevation)) {
        ViewCompat.setElevation(this, paramAttributeSet.getDimensionPixelSize(R.styleable.BottomNavigationView_elevation, 0));
      }
      paramInt = paramAttributeSet.getResourceId(R.styleable.BottomNavigationView_itemBackground, 0);
      this.d.setItemBackgroundRes(paramInt);
      if (paramAttributeSet.hasValue(R.styleable.BottomNavigationView_menu)) {
        inflateMenu(paramAttributeSet.getResourceId(R.styleable.BottomNavigationView_menu, 0));
      }
      paramAttributeSet.recycle();
      addView(this.d, localLayoutParams);
      if (Build.VERSION.SDK_INT < 21)
      {
        paramAttributeSet = new View(paramContext);
        paramAttributeSet.setBackgroundColor(ContextCompat.getColor(paramContext, R.color.design_bottom_navigation_shadow_color));
        paramAttributeSet.setLayoutParams(new FrameLayout.LayoutParams(-1, getResources().getDimensionPixelSize(R.dimen.design_bottom_navigation_shadow_height)));
        addView(paramAttributeSet);
      }
      this.c.setCallback(new MenuBuilder.Callback()
      {
        public final boolean onMenuItemSelected(MenuBuilder paramAnonymousMenuBuilder, MenuItem paramAnonymousMenuItem)
        {
          return (BottomNavigationView.a(BottomNavigationView.this) != null) && (!BottomNavigationView.a(BottomNavigationView.this).onNavigationItemSelected(paramAnonymousMenuItem));
        }
        
        public final void onMenuModeChange(MenuBuilder paramAnonymousMenuBuilder) {}
      });
      return;
      this.d.setIconTintList(a());
      break;
      label345:
      this.d.setItemTextColor(a());
    }
  }
  
  private ColorStateList a()
  {
    Object localObject = new TypedValue();
    if (!getContext().getTheme().resolveAttribute(16842808, (TypedValue)localObject, true)) {}
    ColorStateList localColorStateList;
    do
    {
      return null;
      localColorStateList = AppCompatResources.getColorStateList(getContext(), ((TypedValue)localObject).resourceId);
    } while (!getContext().getTheme().resolveAttribute(R.attr.colorPrimary, (TypedValue)localObject, true));
    int i = ((TypedValue)localObject).data;
    int j = localColorStateList.getDefaultColor();
    localObject = b;
    int[] arrayOfInt1 = a;
    int[] arrayOfInt2 = EMPTY_STATE_SET;
    int k = localColorStateList.getColorForState(b, j);
    return new ColorStateList(new int[][] { localObject, arrayOfInt1, arrayOfInt2 }, new int[] { k, i, j });
  }
  
  private MenuInflater getMenuInflater()
  {
    if (this.f == null) {
      this.f = new SupportMenuInflater(getContext());
    }
    return this.f;
  }
  
  @DrawableRes
  public int getItemBackgroundResource()
  {
    return this.d.getItemBackgroundRes();
  }
  
  @Nullable
  public ColorStateList getItemIconTintList()
  {
    return this.d.getIconTintList();
  }
  
  @Nullable
  public ColorStateList getItemTextColor()
  {
    return this.d.getItemTextColor();
  }
  
  public int getMaxItemCount()
  {
    return 5;
  }
  
  @NonNull
  public Menu getMenu()
  {
    return this.c;
  }
  
  public void inflateMenu(int paramInt)
  {
    this.e.setUpdateSuspended(true);
    getMenuInflater().inflate(paramInt, this.c);
    this.e.setUpdateSuspended(false);
    this.e.updateMenuView(true);
  }
  
  public void setItemBackgroundResource(@DrawableRes int paramInt)
  {
    this.d.setItemBackgroundRes(paramInt);
  }
  
  public void setItemIconTintList(@Nullable ColorStateList paramColorStateList)
  {
    this.d.setIconTintList(paramColorStateList);
  }
  
  public void setItemTextColor(@Nullable ColorStateList paramColorStateList)
  {
    this.d.setItemTextColor(paramColorStateList);
  }
  
  public void setOnNavigationItemSelectedListener(@Nullable OnNavigationItemSelectedListener paramOnNavigationItemSelectedListener)
  {
    this.g = paramOnNavigationItemSelectedListener;
  }
  
  public static abstract interface OnNavigationItemSelectedListener
  {
    public abstract boolean onNavigationItemSelected(@NonNull MenuItem paramMenuItem);
  }
}


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