AvatarBottomBarViewHolder.java 7.77 KB
package com.bitstrips.imoji.abv3.bottombar;

import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.PorterDuff.Mode;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.FrameLayout.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import hi;
import java.util.Iterator;
import java.util.List;

public class AvatarBottomBarViewHolder
{
  private static final String a = AvatarBottomBarViewHolder.class.getSimpleName();
  private boolean b;
  private View c;
  private final ImageView d;
  private final LinearLayout e;
  private AvatarBottomBarItem f;
  private hi g;
  private int h;
  private int i;
  private int j;
  private int k;
  private int l;
  private boolean m;
  
  public AvatarBottomBarViewHolder(View paramView, AvatarBottomBarItem paramAvatarBottomBarItem, int paramInt)
  {
    this.c = paramView;
    this.d = ((ImageView)this.c.findViewById(2131689575));
    this.e = ((LinearLayout)this.c.findViewById(2131689871));
    a(paramAvatarBottomBarItem, paramInt);
  }
  
  private void a(AvatarBottomBarItem paramAvatarBottomBarItem, int paramInt)
  {
    this.f = paramAvatarBottomBarItem;
    this.e.removeAllViews();
    this.h = this.c.getContext().getResources().getColor(2131623948);
    this.i = this.c.getContext().getResources().getColor(2131623947);
    this.k = this.c.getResources().getDimensionPixelSize(2131361903);
    this.j = this.c.getResources().getDimensionPixelSize(2131361902);
    this.l = this.c.getResources().getDimensionPixelSize(2131361901);
    this.d.setImageResource(paramAvatarBottomBarItem.getIconResource());
    this.d.setLayoutParams(new FrameLayout.LayoutParams(paramInt, this.j));
    Context localContext = this.c.getContext();
    paramAvatarBottomBarItem = paramAvatarBottomBarItem.getSubCategories().iterator();
    while (paramAvatarBottomBarItem.hasNext())
    {
      final AvatarBottomBarSubCategory localAvatarBottomBarSubCategory = (AvatarBottomBarSubCategory)paramAvatarBottomBarItem.next();
      ImageView localImageView = new ImageView(localContext);
      localImageView.setImageResource(localAvatarBottomBarSubCategory.getIconResource());
      LinearLayout.LayoutParams localLayoutParams = new LinearLayout.LayoutParams(this.k, this.j);
      this.e.addView(localImageView, localLayoutParams);
      localImageView.setOnClickListener(new View.OnClickListener()
      {
        public final void onClick(View paramAnonymousView)
        {
          if (AvatarBottomBarViewHolder.a(AvatarBottomBarViewHolder.this) != null) {
            AvatarBottomBarViewHolder.a(AvatarBottomBarViewHolder.this).onSelected(AvatarBottomBarViewHolder.this, localAvatarBottomBarSubCategory.getCategoryKey());
          }
        }
      });
    }
    this.d.setOnClickListener(new View.OnClickListener()
    {
      public final void onClick(View paramAnonymousView)
      {
        if (AvatarBottomBarViewHolder.a(AvatarBottomBarViewHolder.this) != null) {
          AvatarBottomBarViewHolder.a(AvatarBottomBarViewHolder.this).onSelected(AvatarBottomBarViewHolder.this, ((AvatarBottomBarSubCategory)AvatarBottomBarViewHolder.b(AvatarBottomBarViewHolder.this).getSubCategories().get(0)).getCategoryKey());
        }
      }
    });
  }
  
  public int getContainerWidth()
  {
    return this.k * this.e.getChildCount() + this.l * 2;
  }
  
  public View getView()
  {
    return this.c;
  }
  
  public int indexOf(@NonNull String paramString)
  {
    int n = 0;
    while (n < this.f.getSubCategories().size())
    {
      if (paramString.equals(((AvatarBottomBarSubCategory)this.f.getSubCategories().get(n)).getCategoryKey())) {
        return n;
      }
      n += 1;
    }
    return -1;
  }
  
  public void setAnimationsEnabled(boolean paramBoolean)
  {
    this.m = paramBoolean;
  }
  
  public void setListener(hi paramhi)
  {
    this.g = paramhi;
  }
  
  public void setSelected(int paramInt)
  {
    if (this.f.isSingleCategory())
    {
      new StringBuilder("Selected: ").append(((AvatarBottomBarSubCategory)this.f.getSubCategories().get(0)).getCategoryKey());
      this.d.setColorFilter(this.c.getContext().getResources().getColor(2131623948), PorterDuff.Mode.SRC_IN);
      return;
    }
    new StringBuilder("Selected group ").append(this.b);
    Object localObject;
    long l1;
    label124:
    int n;
    if (!this.b)
    {
      this.b = true;
      localObject = ValueAnimator.ofFloat(new float[] { 0.0F, 1.0F });
      if (this.m)
      {
        l1 = 250L;
        ((ValueAnimator)localObject).setDuration(l1);
        ((ValueAnimator)localObject).addUpdateListener(new ValueAnimator.AnimatorUpdateListener()
        {
          public final void onAnimationUpdate(ValueAnimator paramAnonymousValueAnimator)
          {
            float f = ((Float)paramAnonymousValueAnimator.getAnimatedValue()).floatValue();
            paramAnonymousValueAnimator = new FrameLayout.LayoutParams((int)(AvatarBottomBarViewHolder.this.getContainerWidth() * f), -1);
            AvatarBottomBarViewHolder.c(AvatarBottomBarViewHolder.this).setLayoutParams(paramAnonymousValueAnimator);
            AvatarBottomBarViewHolder.c(AvatarBottomBarViewHolder.this).setAlpha(f);
            AvatarBottomBarViewHolder.d(AvatarBottomBarViewHolder.this).setAlpha(1.0F - f);
          }
        });
        ((ValueAnimator)localObject).start();
      }
    }
    else
    {
      n = 0;
      label151:
      if (n < this.e.getChildCount())
      {
        localObject = (ImageView)this.e.getChildAt(n);
        if (n != paramInt) {
          break label204;
        }
        ((ImageView)localObject).setColorFilter(this.h, PorterDuff.Mode.SRC_IN);
      }
    }
    for (;;)
    {
      n += 1;
      break label151;
      break;
      l1 = 0L;
      break label124;
      label204:
      ((ImageView)localObject).setColorFilter(this.i, PorterDuff.Mode.SRC_IN);
    }
  }
  
  public void setUnselected()
  {
    if (this.f.isSingleCategory())
    {
      new StringBuilder("Unselected: ").append(((AvatarBottomBarSubCategory)this.f.getSubCategories().get(0)).getCategoryKey());
      this.d.setColorFilter(this.i, PorterDuff.Mode.SRC_IN);
      return;
    }
    new StringBuilder("Unselected group ").append(this.b);
    final int n;
    ValueAnimator localValueAnimator;
    if (this.b)
    {
      this.b = false;
      n = getContainerWidth();
      localValueAnimator = ValueAnimator.ofFloat(new float[] { 1.0F, 0.0F });
      if (!this.m) {
        break label187;
      }
    }
    label187:
    for (long l1 = 250L;; l1 = 0L)
    {
      localValueAnimator.setDuration(l1);
      localValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener()
      {
        public final void onAnimationUpdate(ValueAnimator paramAnonymousValueAnimator)
        {
          float f = ((Float)paramAnonymousValueAnimator.getAnimatedValue()).floatValue();
          paramAnonymousValueAnimator = new FrameLayout.LayoutParams((int)(n * f), -1);
          AvatarBottomBarViewHolder.c(AvatarBottomBarViewHolder.this).setLayoutParams(paramAnonymousValueAnimator);
          AvatarBottomBarViewHolder.c(AvatarBottomBarViewHolder.this).setAlpha(f);
          AvatarBottomBarViewHolder.d(AvatarBottomBarViewHolder.this).setAlpha(1.0F - f);
        }
      });
      localValueAnimator.start();
      n = 0;
      while (n < this.e.getChildCount())
      {
        ((ImageView)this.e.getChildAt(n)).setColorFilter(this.i, PorterDuff.Mode.SRC_IN);
        n += 1;
      }
      break;
    }
  }
}


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