AvatarBottomBar.java 4.18 KB
package com.bitstrips.imoji.abv3.bottombar;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Point;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import hi;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class AvatarBottomBar
  extends FrameLayout
  implements hi
{
  private static final String a = AvatarBottomBar.class.getSimpleName();
  private List<AvatarBottomBarItem> b;
  private List<AvatarBottomBarViewHolder> c;
  private LinearLayout d;
  private HorizontalScrollView e;
  private AvatarBottomBarViewHolder f;
  private AvatarBuilderBottomBarListener g;
  private int h;
  
  public AvatarBottomBar(@NonNull Context paramContext)
  {
    super(paramContext);
    init();
  }
  
  public AvatarBottomBar(@NonNull Context paramContext, @Nullable AttributeSet paramAttributeSet)
  {
    super(paramContext, paramAttributeSet);
    init();
  }
  
  public void init()
  {
    View.inflate(getContext(), 2130903210, this);
    this.e = ((HorizontalScrollView)findViewById(2131689945));
    this.d = ((LinearLayout)findViewById(2131689946));
    Display localDisplay = ((WindowManager)getContext().getSystemService("window")).getDefaultDisplay();
    Point localPoint = new Point();
    localDisplay.getSize(localPoint);
    this.h = localPoint.x;
  }
  
  public void onSelected(AvatarBottomBarViewHolder paramAvatarBottomBarViewHolder, String paramString)
  {
    if (this.g != null) {
      this.g.onBottomBarItemSelected(paramString);
    }
  }
  
  public void setBottomBarItems(List<AvatarBottomBarItem> paramList)
  {
    this.d.removeAllViews();
    this.c = new ArrayList();
    this.b = paramList;
    this.f = null;
    int i = paramList.size();
    int j = getResources().getDimensionPixelSize(2131361900);
    int k = (int)(this.h / i);
    i = j;
    if (k > j) {
      i = k;
    }
    paramList = paramList.iterator();
    while (paramList.hasNext())
    {
      Object localObject = (AvatarBottomBarItem)paramList.next();
      View localView = View.inflate(getContext(), 2130903158, null);
      localObject = new AvatarBottomBarViewHolder(localView, (AvatarBottomBarItem)localObject, i);
      ((AvatarBottomBarViewHolder)localObject).setListener(this);
      ((AvatarBottomBarViewHolder)localObject).setAnimationsEnabled(true);
      this.d.addView(localView);
      this.c.add(localObject);
    }
  }
  
  public void setListener(AvatarBuilderBottomBarListener paramAvatarBuilderBottomBarListener)
  {
    this.g = paramAvatarBuilderBottomBarListener;
  }
  
  public void setSelectedCategory(String paramString)
  {
    Iterator localIterator = this.c.iterator();
    while (localIterator.hasNext())
    {
      Object localObject = (AvatarBottomBarViewHolder)localIterator.next();
      int i = ((AvatarBottomBarViewHolder)localObject).indexOf(paramString);
      if (i != -1)
      {
        if ((this.f != null) && (this.f != localObject)) {
          this.f.setUnselected();
        }
        ((AvatarBottomBarViewHolder)localObject).setSelected(i);
        this.f = ((AvatarBottomBarViewHolder)localObject);
        paramString = ((AvatarBottomBarViewHolder)localObject).getView();
        i = ((AvatarBottomBarViewHolder)localObject).getContainerWidth();
        localObject = new int[2];
        paramString.getLocationOnScreen((int[])localObject);
        float f1 = localObject[0];
        float f2 = paramString.getX();
        if ((f1 < 0.0F) || (i + f1 > this.h))
        {
          int j = (int)f2 - this.h / 2;
          i = j;
          if (j < 0) {
            i = 0;
          }
          j = i;
          if (i > this.d.getMeasuredWidth()) {
            j = this.d.getMeasuredWidth();
          }
          this.e.smoothScrollTo(j, 0);
        }
      }
    }
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/com/bitstrips/imoji/abv3/bottombar/AvatarBottomBar.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */