BottomNavigationItemView.java 7.93 KB
package android.support.design.internal;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable.ConstantState;
import android.support.annotation.NonNull;
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.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v4.view.PointerIconCompat;
import android.support.v4.view.ViewCompat;
import android.support.v7.view.menu.MenuItemImpl;
import android.support.v7.view.menu.MenuView.ItemView;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import android.widget.ImageView;
import android.widget.TextView;

@RestrictTo({android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP})
public class BottomNavigationItemView
  extends FrameLayout
  implements MenuView.ItemView
{
  public static final int INVALID_ITEM_POSITION = -1;
  private static final int[] a = { 16842912 };
  private final int b;
  private final int c;
  private final float d;
  private final float e;
  private boolean f;
  private ImageView g;
  private final TextView h;
  private final TextView i;
  private int j = -1;
  private MenuItemImpl k;
  private ColorStateList l;
  
  public BottomNavigationItemView(@NonNull Context paramContext)
  {
    this(paramContext, null);
  }
  
  public BottomNavigationItemView(@NonNull Context paramContext, AttributeSet paramAttributeSet)
  {
    this(paramContext, paramAttributeSet, 0);
  }
  
  public BottomNavigationItemView(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
  {
    super(paramContext, paramAttributeSet, paramInt);
    paramAttributeSet = getResources();
    paramInt = paramAttributeSet.getDimensionPixelSize(R.dimen.design_bottom_navigation_text_size);
    int m = paramAttributeSet.getDimensionPixelSize(R.dimen.design_bottom_navigation_active_text_size);
    this.b = paramAttributeSet.getDimensionPixelSize(R.dimen.design_bottom_navigation_margin);
    this.c = (paramInt - m);
    this.d = (m * 1.0F / paramInt);
    this.e = (paramInt * 1.0F / m);
    LayoutInflater.from(paramContext).inflate(R.layout.design_bottom_navigation_item, this, true);
    setBackgroundResource(R.drawable.design_bottom_navigation_item_background);
    this.g = ((ImageView)findViewById(R.id.icon));
    this.h = ((TextView)findViewById(R.id.smallLabel));
    this.i = ((TextView)findViewById(R.id.largeLabel));
  }
  
  public MenuItemImpl getItemData()
  {
    return this.k;
  }
  
  public int getItemPosition()
  {
    return this.j;
  }
  
  public void initialize(MenuItemImpl paramMenuItemImpl, int paramInt)
  {
    this.k = paramMenuItemImpl;
    setCheckable(paramMenuItemImpl.isCheckable());
    setChecked(paramMenuItemImpl.isChecked());
    setEnabled(paramMenuItemImpl.isEnabled());
    setIcon(paramMenuItemImpl.getIcon());
    setTitle(paramMenuItemImpl.getTitle());
    setId(paramMenuItemImpl.getItemId());
  }
  
  public int[] onCreateDrawableState(int paramInt)
  {
    int[] arrayOfInt = super.onCreateDrawableState(paramInt + 1);
    if ((this.k != null) && (this.k.isCheckable()) && (this.k.isChecked())) {
      mergeDrawableStates(arrayOfInt, a);
    }
    return arrayOfInt;
  }
  
  public boolean prefersCondensedTitle()
  {
    return false;
  }
  
  public void setCheckable(boolean paramBoolean)
  {
    refreshDrawableState();
  }
  
  public void setChecked(boolean paramBoolean)
  {
    ViewCompat.setPivotX(this.i, this.i.getWidth() / 2);
    ViewCompat.setPivotY(this.i, this.i.getBaseline());
    ViewCompat.setPivotX(this.h, this.h.getWidth() / 2);
    ViewCompat.setPivotY(this.h, this.h.getBaseline());
    FrameLayout.LayoutParams localLayoutParams;
    if (this.f) {
      if (paramBoolean)
      {
        localLayoutParams = (FrameLayout.LayoutParams)this.g.getLayoutParams();
        localLayoutParams.gravity = 49;
        localLayoutParams.topMargin = this.b;
        this.g.setLayoutParams(localLayoutParams);
        this.i.setVisibility(0);
        ViewCompat.setScaleX(this.i, 1.0F);
        ViewCompat.setScaleY(this.i, 1.0F);
        this.h.setVisibility(4);
      }
    }
    for (;;)
    {
      refreshDrawableState();
      return;
      localLayoutParams = (FrameLayout.LayoutParams)this.g.getLayoutParams();
      localLayoutParams.gravity = 17;
      localLayoutParams.topMargin = this.b;
      this.g.setLayoutParams(localLayoutParams);
      this.i.setVisibility(4);
      ViewCompat.setScaleX(this.i, 0.5F);
      ViewCompat.setScaleY(this.i, 0.5F);
      break;
      if (paramBoolean)
      {
        localLayoutParams = (FrameLayout.LayoutParams)this.g.getLayoutParams();
        localLayoutParams.gravity = 49;
        localLayoutParams.topMargin = (this.b + this.c);
        this.g.setLayoutParams(localLayoutParams);
        this.i.setVisibility(0);
        this.h.setVisibility(4);
        ViewCompat.setScaleX(this.i, 1.0F);
        ViewCompat.setScaleY(this.i, 1.0F);
        ViewCompat.setScaleX(this.h, this.d);
        ViewCompat.setScaleY(this.h, this.d);
      }
      else
      {
        localLayoutParams = (FrameLayout.LayoutParams)this.g.getLayoutParams();
        localLayoutParams.gravity = 49;
        localLayoutParams.topMargin = this.b;
        this.g.setLayoutParams(localLayoutParams);
        this.i.setVisibility(4);
        this.h.setVisibility(0);
        ViewCompat.setScaleX(this.i, this.e);
        ViewCompat.setScaleY(this.i, this.e);
        ViewCompat.setScaleX(this.h, 1.0F);
        ViewCompat.setScaleY(this.h, 1.0F);
      }
    }
  }
  
  public void setEnabled(boolean paramBoolean)
  {
    super.setEnabled(paramBoolean);
    this.h.setEnabled(paramBoolean);
    this.i.setEnabled(paramBoolean);
    this.g.setEnabled(paramBoolean);
    if (paramBoolean)
    {
      ViewCompat.setPointerIcon(this, PointerIconCompat.getSystemIcon(getContext(), 1002));
      return;
    }
    ViewCompat.setPointerIcon(this, null);
  }
  
  public void setIcon(Drawable paramDrawable)
  {
    Object localObject = paramDrawable;
    if (paramDrawable != null)
    {
      localObject = paramDrawable.getConstantState();
      if (localObject != null) {
        break label40;
      }
    }
    for (;;)
    {
      localObject = DrawableCompat.wrap(paramDrawable).mutate();
      DrawableCompat.setTintList((Drawable)localObject, this.l);
      this.g.setImageDrawable((Drawable)localObject);
      return;
      label40:
      paramDrawable = ((Drawable.ConstantState)localObject).newDrawable();
    }
  }
  
  public void setIconTintList(ColorStateList paramColorStateList)
  {
    this.l = paramColorStateList;
    if (this.k != null) {
      setIcon(this.k.getIcon());
    }
  }
  
  public void setItemBackground(int paramInt)
  {
    if (paramInt == 0) {}
    for (Drawable localDrawable = null;; localDrawable = ContextCompat.getDrawable(getContext(), paramInt))
    {
      ViewCompat.setBackground(this, localDrawable);
      return;
    }
  }
  
  public void setItemPosition(int paramInt)
  {
    this.j = paramInt;
  }
  
  public void setShiftingMode(boolean paramBoolean)
  {
    this.f = paramBoolean;
  }
  
  public void setShortcut(boolean paramBoolean, char paramChar) {}
  
  public void setTextColor(ColorStateList paramColorStateList)
  {
    this.h.setTextColor(paramColorStateList);
    this.i.setTextColor(paramColorStateList);
  }
  
  public void setTitle(CharSequence paramCharSequence)
  {
    this.h.setText(paramCharSequence);
    this.i.setText(paramCharSequence);
  }
  
  public boolean showsIcon()
  {
    return true;
  }
}


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