BottomNavigationMenuView.java 10.2 KB
package android.support.design.internal;

import a;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.os.Build.VERSION;
import android.support.annotation.Nullable;
import android.support.annotation.RestrictTo;
import android.support.design.R.dimen;
import android.support.v4.util.Pools.Pool;
import android.support.v4.util.Pools.SynchronizedPool;
import android.support.v4.view.ViewCompat;
import android.support.v7.view.menu.MenuBuilder;
import android.support.v7.view.menu.MenuItemImpl;
import android.support.v7.view.menu.MenuView;
import android.util.AttributeSet;
import android.view.MenuItem;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import b;

@RestrictTo({android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP})
public class BottomNavigationMenuView
  extends ViewGroup
  implements MenuView
{
  private static final Pools.Pool<BottomNavigationItemView> g = new Pools.SynchronizedPool(5);
  private final int a;
  private final int b;
  private final int c;
  private final int d;
  private final View.OnClickListener e;
  private final a f;
  private boolean h = true;
  private BottomNavigationItemView[] i;
  private int j = 0;
  private ColorStateList k;
  private ColorStateList l;
  private int m;
  private int[] n;
  private BottomNavigationPresenter o;
  private MenuBuilder p;
  
  public BottomNavigationMenuView(Context paramContext)
  {
    this(paramContext, null);
  }
  
  public BottomNavigationMenuView(Context paramContext, AttributeSet paramAttributeSet)
  {
    super(paramContext, paramAttributeSet);
    paramContext = getResources();
    this.a = paramContext.getDimensionPixelSize(R.dimen.design_bottom_navigation_item_max_width);
    this.b = paramContext.getDimensionPixelSize(R.dimen.design_bottom_navigation_item_min_width);
    this.c = paramContext.getDimensionPixelSize(R.dimen.design_bottom_navigation_active_item_max_width);
    this.d = paramContext.getDimensionPixelSize(R.dimen.design_bottom_navigation_height);
    if (Build.VERSION.SDK_INT >= 14) {}
    for (this.f = new b();; this.f = new a())
    {
      this.e = new View.OnClickListener()
      {
        public final void onClick(View paramAnonymousView)
        {
          paramAnonymousView = (BottomNavigationItemView)paramAnonymousView;
          int i = paramAnonymousView.getItemPosition();
          if (!BottomNavigationMenuView.b(BottomNavigationMenuView.this).performItemAction(paramAnonymousView.getItemData(), BottomNavigationMenuView.a(BottomNavigationMenuView.this), 0)) {
            BottomNavigationMenuView.a(BottomNavigationMenuView.this, i);
          }
        }
      };
      this.n = new int[5];
      return;
    }
  }
  
  private BottomNavigationItemView getNewItem()
  {
    BottomNavigationItemView localBottomNavigationItemView2 = (BottomNavigationItemView)g.acquire();
    BottomNavigationItemView localBottomNavigationItemView1 = localBottomNavigationItemView2;
    if (localBottomNavigationItemView2 == null) {
      localBottomNavigationItemView1 = new BottomNavigationItemView(getContext());
    }
    return localBottomNavigationItemView1;
  }
  
  public void buildMenuView()
  {
    Object localObject1;
    int i1;
    if (this.i != null)
    {
      localObject1 = this.i;
      int i2 = localObject1.length;
      i1 = 0;
      while (i1 < i2)
      {
        Object localObject2 = localObject1[i1];
        g.release(localObject2);
        i1 += 1;
      }
    }
    removeAllViews();
    if (this.p.size() == 0)
    {
      this.i = null;
      return;
    }
    this.i = new BottomNavigationItemView[this.p.size()];
    if (this.p.size() > 3) {}
    for (boolean bool = true;; bool = false)
    {
      this.h = bool;
      i1 = 0;
      while (i1 < this.p.size())
      {
        this.o.setUpdateSuspended(true);
        this.p.getItem(i1).setCheckable(true);
        this.o.setUpdateSuspended(false);
        localObject1 = getNewItem();
        this.i[i1] = localObject1;
        ((BottomNavigationItemView)localObject1).setIconTintList(this.k);
        ((BottomNavigationItemView)localObject1).setTextColor(this.l);
        ((BottomNavigationItemView)localObject1).setItemBackground(this.m);
        ((BottomNavigationItemView)localObject1).setShiftingMode(this.h);
        ((BottomNavigationItemView)localObject1).initialize((MenuItemImpl)this.p.getItem(i1), 0);
        ((BottomNavigationItemView)localObject1).setItemPosition(i1);
        ((BottomNavigationItemView)localObject1).setOnClickListener(this.e);
        addView((View)localObject1);
        i1 += 1;
      }
    }
    this.j = Math.min(this.p.size() - 1, this.j);
    this.p.getItem(this.j).setChecked(true);
  }
  
  @Nullable
  public ColorStateList getIconTintList()
  {
    return this.k;
  }
  
  public int getItemBackgroundRes()
  {
    return this.m;
  }
  
  public ColorStateList getItemTextColor()
  {
    return this.l;
  }
  
  public int getWindowAnimations()
  {
    return 0;
  }
  
  public void initialize(MenuBuilder paramMenuBuilder)
  {
    this.p = paramMenuBuilder;
  }
  
  protected void onLayout(boolean paramBoolean, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    int i1 = getChildCount();
    int i2 = paramInt3 - paramInt1;
    paramInt4 -= paramInt2;
    paramInt1 = 0;
    paramInt2 = 0;
    if (paramInt1 < i1)
    {
      View localView = getChildAt(paramInt1);
      paramInt3 = paramInt2;
      if (localView.getVisibility() != 8)
      {
        if (ViewCompat.getLayoutDirection(this) != 1) {
          break label97;
        }
        localView.layout(i2 - paramInt2 - localView.getMeasuredWidth(), 0, i2 - paramInt2, paramInt4);
      }
      for (;;)
      {
        paramInt3 = paramInt2 + localView.getMeasuredWidth();
        paramInt1 += 1;
        paramInt2 = paramInt3;
        break;
        label97:
        localView.layout(paramInt2, 0, localView.getMeasuredWidth() + paramInt2, paramInt4);
      }
    }
  }
  
  protected void onMeasure(int paramInt1, int paramInt2)
  {
    paramInt2 = View.MeasureSpec.getSize(paramInt1);
    int i2 = getChildCount();
    int i5 = View.MeasureSpec.makeMeasureSpec(this.d, 1073741824);
    int i3;
    int i4;
    Object localObject;
    int i1;
    if (this.h)
    {
      paramInt1 = i2 - 1;
      i3 = Math.min(paramInt2 - this.b * paramInt1, this.c);
      i4 = Math.min((paramInt2 - i3) / paramInt1, this.a);
      paramInt1 = paramInt2 - i3 - paramInt1 * i4;
      paramInt2 = 0;
      if (paramInt2 >= i2) {
        break label228;
      }
      localObject = this.n;
      if (paramInt2 == this.j)
      {
        i1 = i3;
        label102:
        localObject[paramInt2] = i1;
        if (paramInt1 <= 0) {
          break label333;
        }
        localObject = this.n;
        localObject[paramInt2] += 1;
        paramInt1 -= 1;
      }
    }
    label228:
    label333:
    for (;;)
    {
      paramInt2 += 1;
      break;
      i1 = i4;
      break label102;
      if (i2 == 0) {}
      for (paramInt1 = 1;; paramInt1 = i2)
      {
        i3 = Math.min(paramInt2 / paramInt1, this.c);
        paramInt2 -= i3 * i2;
        paramInt1 = 0;
        while (paramInt1 < i2)
        {
          this.n[paramInt1] = i3;
          i1 = paramInt2;
          if (paramInt2 > 0)
          {
            localObject = this.n;
            localObject[paramInt1] += 1;
            i1 = paramInt2 - 1;
          }
          paramInt1 += 1;
          paramInt2 = i1;
        }
      }
      paramInt1 = 0;
      for (paramInt2 = 0; paramInt1 < i2; paramInt2 = i1)
      {
        localObject = getChildAt(paramInt1);
        i1 = paramInt2;
        if (((View)localObject).getVisibility() != 8)
        {
          ((View)localObject).measure(View.MeasureSpec.makeMeasureSpec(this.n[paramInt1], 1073741824), i5);
          ((View)localObject).getLayoutParams().width = ((View)localObject).getMeasuredWidth();
          i1 = paramInt2 + ((View)localObject).getMeasuredWidth();
        }
        paramInt1 += 1;
      }
      setMeasuredDimension(ViewCompat.resolveSizeAndState(paramInt2, View.MeasureSpec.makeMeasureSpec(paramInt2, 1073741824), 0), ViewCompat.resolveSizeAndState(this.d, i5, 0));
      return;
    }
  }
  
  public void setIconTintList(ColorStateList paramColorStateList)
  {
    this.k = paramColorStateList;
    if (this.i == null) {}
    for (;;)
    {
      return;
      BottomNavigationItemView[] arrayOfBottomNavigationItemView = this.i;
      int i2 = arrayOfBottomNavigationItemView.length;
      int i1 = 0;
      while (i1 < i2)
      {
        arrayOfBottomNavigationItemView[i1].setIconTintList(paramColorStateList);
        i1 += 1;
      }
    }
  }
  
  public void setItemBackgroundRes(int paramInt)
  {
    this.m = paramInt;
    if (this.i == null) {}
    for (;;)
    {
      return;
      BottomNavigationItemView[] arrayOfBottomNavigationItemView = this.i;
      int i2 = arrayOfBottomNavigationItemView.length;
      int i1 = 0;
      while (i1 < i2)
      {
        arrayOfBottomNavigationItemView[i1].setItemBackground(paramInt);
        i1 += 1;
      }
    }
  }
  
  public void setItemTextColor(ColorStateList paramColorStateList)
  {
    this.l = paramColorStateList;
    if (this.i == null) {}
    for (;;)
    {
      return;
      BottomNavigationItemView[] arrayOfBottomNavigationItemView = this.i;
      int i2 = arrayOfBottomNavigationItemView.length;
      int i1 = 0;
      while (i1 < i2)
      {
        arrayOfBottomNavigationItemView[i1].setTextColor(paramColorStateList);
        i1 += 1;
      }
    }
  }
  
  public void setPresenter(BottomNavigationPresenter paramBottomNavigationPresenter)
  {
    this.o = paramBottomNavigationPresenter;
  }
  
  public void updateMenuView()
  {
    int i2 = this.p.size();
    if (i2 != this.i.length) {
      buildMenuView();
    }
    for (;;)
    {
      return;
      int i1 = 0;
      while (i1 < i2)
      {
        this.o.setUpdateSuspended(true);
        if (this.p.getItem(i1).isChecked()) {
          this.j = i1;
        }
        this.i[i1].initialize((MenuItemImpl)this.p.getItem(i1), 0);
        this.o.setUpdateSuspended(false);
        i1 += 1;
      }
    }
  }
}


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