AvatarOptionAdapter.java 6.58 KB
package com.bitstrips.imoji.abv3.option;

import android.graphics.Color;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView.Adapter;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import com.bitstrips.imoji.abv3.category.AvatarCategoryDetails;
import com.bitstrips.imoji.abv3.model.AvatarOption;
import com.bitstrips.imoji.persistence.MediaCache;
import java.util.List;

public class AvatarOptionAdapter
  extends RecyclerView.Adapter
{
  private AvatarOptionListener a;
  private final AvatarOptionProvider b;
  private final List<AvatarOption> c;
  private final AvatarCategoryDetails d;
  private final MediaCache e;
  
  public AvatarOptionAdapter(@NonNull AvatarOptionProvider paramAvatarOptionProvider, @NonNull AvatarCategoryDetails paramAvatarCategoryDetails, @NonNull List<AvatarOption> paramList, MediaCache paramMediaCache)
  {
    this.c = paramList;
    this.d = paramAvatarCategoryDetails;
    this.b = paramAvatarOptionProvider;
    this.e = paramMediaCache;
  }
  
  private static int a(AvatarOption paramAvatarOption)
  {
    int i = paramAvatarOption.getValue();
    if (i == -1) {
      return -1;
    }
    for (paramAvatarOption = Integer.toHexString(i); paramAvatarOption.length() < 6; paramAvatarOption = "0" + paramAvatarOption) {}
    return Color.parseColor("#" + paramAvatarOption);
  }
  
  public int getItemCount()
  {
    if (isHeaderPresent()) {
      return this.c.size() + 1;
    }
    return this.c.size();
  }
  
  public int getItemViewType(int paramInt)
  {
    if ((isHeaderPresent()) && (paramInt == 0)) {
      return 0;
    }
    return 1;
  }
  
  public AvatarOption getOptionAtViewHolderPosition(int paramInt)
  {
    int i = paramInt;
    if (isHeaderPresent()) {
      i = paramInt - 1;
    }
    if (i == -1) {
      return null;
    }
    return (AvatarOption)this.c.get(i);
  }
  
  public boolean isHeaderPresent()
  {
    Integer localInteger = this.b.getSelectedOptionValue("hat");
    return ("hair".equals(this.d.getCategoryKey())) && (!isOptionValueBlank(localInteger));
  }
  
  public boolean isOptionValueBlank(Integer paramInteger)
  {
    return (paramInteger == null) || (paramInteger.intValue() == -1);
  }
  
  public void onBindViewHolder(RecyclerView.ViewHolder paramViewHolder, int paramInt)
  {
    if (getItemViewType(paramInt) == 0)
    {
      paramViewHolder = (AvatarOptionHeaderViewHolder)paramViewHolder;
      if ("hair".equals(this.d.getCategoryKey())) {
        paramViewHolder.setText(2131230824);
      }
      return;
    }
    final AvatarOption localAvatarOption = getOptionAtViewHolderPosition(paramInt);
    String str = this.d.getDisplayType();
    paramInt = -1;
    switch (str.hashCode())
    {
    default: 
      switch (paramInt)
      {
      default: 
        ((AvatarOptionViewHolder)paramViewHolder).setOption(this.b.getUri(this.d, localAvatarOption));
      }
      break;
    }
    for (;;)
    {
      paramViewHolder.itemView.setOnClickListener(new View.OnClickListener()
      {
        public final void onClick(View paramAnonymousView)
        {
          if (AvatarOptionAdapter.a(AvatarOptionAdapter.this) != null) {
            AvatarOptionAdapter.a(AvatarOptionAdapter.this).onOptionSelected(AvatarOptionAdapter.b(AvatarOptionAdapter.this), localAvatarOption);
          }
        }
      });
      return;
      if (!str.equals("makeup")) {
        break;
      }
      paramInt = 0;
      break;
      if (!str.equals("color")) {
        break;
      }
      paramInt = 1;
      break;
      if (!str.equals("eye-color")) {
        break;
      }
      paramInt = 2;
      break;
      if (!str.equals("thumbnail")) {
        break;
      }
      paramInt = 3;
      break;
      ((AvatarMakeupViewHolder)paramViewHolder).setOption(this.d.getCategoryKey(), a(localAvatarOption));
      continue;
      ((AvatarOptionColorViewHolder)paramViewHolder).setOption(a(localAvatarOption));
      continue;
      ((AvatarOptionEyeViewHolder)paramViewHolder).setOption(a(localAvatarOption));
      continue;
      ((AvatarOptionThumbnailViewHolder)paramViewHolder).setOption(localAvatarOption.getDisplayContent());
    }
  }
  
  public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup paramViewGroup, int paramInt)
  {
    if (paramInt == 0) {
      return new AvatarOptionHeaderViewHolder(LayoutInflater.from(paramViewGroup.getContext()).inflate(2130903074, paramViewGroup, false));
    }
    if ("makeup".equals(this.d.getDisplayType())) {
      return new AvatarMakeupViewHolder(LayoutInflater.from(paramViewGroup.getContext()).inflate(2130903177, paramViewGroup, false), paramViewGroup.getContext());
    }
    if ("body-fixed".equals(this.d.getDisplayType())) {
      return new AvatarOptionViewHolder(LayoutInflater.from(paramViewGroup.getContext()).inflate(2130903162, paramViewGroup, false), this.e);
    }
    if ("color".equals(this.d.getDisplayType())) {
      return new AvatarOptionColorViewHolder(LayoutInflater.from(paramViewGroup.getContext()).inflate(2130903163, paramViewGroup, false));
    }
    if ("thumbnail".equals(this.d.getDisplayType())) {
      return new AvatarOptionThumbnailViewHolder(LayoutInflater.from(paramViewGroup.getContext()).inflate(2130903166, paramViewGroup, false));
    }
    if ("eye-color".equals(this.d.getDisplayType())) {
      return new AvatarOptionEyeViewHolder(LayoutInflater.from(paramViewGroup.getContext()).inflate(2130903164, paramViewGroup, false));
    }
    return new AvatarOptionViewHolder(LayoutInflater.from(paramViewGroup.getContext()).inflate(2130903161, paramViewGroup, false), this.e);
  }
  
  public void onViewAttachedToWindow(RecyclerView.ViewHolder paramViewHolder)
  {
    super.onViewAttachedToWindow(paramViewHolder);
    AvatarOption localAvatarOption = getOptionAtViewHolderPosition(paramViewHolder.getAdapterPosition());
    if (localAvatarOption == null) {
      return;
    }
    Integer localInteger = this.b.getSelectedOptionValue(this.d.getCategoryKey());
    paramViewHolder = (AvatarOptionBaseViewHolder)paramViewHolder;
    if ((localInteger != null) && (localAvatarOption.getValue() == localInteger.intValue())) {}
    for (boolean bool = true;; bool = false)
    {
      paramViewHolder.setSelected(bool);
      return;
    }
  }
  
  public void setListener(AvatarOptionListener paramAvatarOptionListener)
  {
    this.a = paramAvatarOptionListener;
  }
}


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