package com.ikea.kompis.recycler;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView.Adapter;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.ikea.kompis.products.ProductListViewHolder;
import com.ikea.kompis.util.UiUtil;
import com.ikea.shared.browse.model.CatalogElement;
import com.ikea.shared.products.model.RetailItemCommunication;
import com.ikea.shared.util.L;
import java.util.List;

public class ProductTopLevelTabAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
{
  public static final int PRODUCT_ITEM = 1;
  public static final int SUB_CATEGORY_ITEM;
  private final List<CatalogElement> mCatalogLists;
  private final Context mContext;
  private final String mFilterStr = "";
  private Fragment mFragment;
  private final LayoutInflater mInflater;
  private List<RetailItemCommunication> mRetailItemComm;

  public ProductTopLevelTabAdapter(Context paramContext, List<CatalogElement> paramList)
  {
    this.mInflater = ((LayoutInflater)paramContext.getSystemService("layout_inflater"));
    this.mContext = paramContext;
    this.mCatalogLists = paramList;
  }

  public ProductTopLevelTabAdapter(Context paramContext, List<CatalogElement> paramList, List<RetailItemCommunication> paramList1, Fragment paramFragment)
  {
    this.mInflater = ((LayoutInflater)paramContext.getSystemService("layout_inflater"));
    this.mContext = paramContext;
    this.mCatalogLists = paramList;
    this.mRetailItemComm = paramList1;
    this.mFragment = paramFragment;
  }

  private void getProductHolder(View paramView, ProductListViewHolder paramProductListViewHolder)
  {
    paramProductListViewHolder.initProductCardView(paramView);
  }

  private void getSubCategoryHolder(View paramView, SubCategoryViewHolder paramSubCategoryViewHolder)
  {
    paramSubCategoryViewHolder.catelogeName = ((TextView)paramView.findViewById(2131624049));
    paramSubCategoryViewHolder.topLevelHeaderLine = paramView.findViewById(2131624048);
  }

  public Object getItem(int paramInt)
  {
    if ((this.mCatalogLists != null) && (!this.mCatalogLists.isEmpty()))
    {
      if (paramInt < this.mCatalogLists.size())
        return this.mCatalogLists.get(paramInt);
      return this.mRetailItemComm.get(paramInt - this.mCatalogLists.size());
    }
    return this.mRetailItemComm.get(paramInt);
  }

  public int getItemCount()
  {
    List localList = this.mCatalogLists;
    int i = 0;
    if (localList != null)
    {
      boolean bool = this.mCatalogLists.isEmpty();
      i = 0;
      if (!bool)
        i = 0 + this.mCatalogLists.size();
    }
    if ((this.mRetailItemComm != null) && (!this.mRetailItemComm.isEmpty()))
      i += this.mRetailItemComm.size();
    return i;
  }

  public long getItemId(int paramInt)
  {
    return paramInt;
  }

  public int getItemViewType(int paramInt)
  {
    if ((this.mCatalogLists != null) && (!this.mCatalogLists.isEmpty()))
    {
      if (paramInt < this.mCatalogLists.size())
        return 0;
      return 1;
    }
    return 1;
  }

  public void onBindViewHolder(RecyclerView.ViewHolder paramViewHolder, int paramInt)
  {
    switch (getItemViewType(paramInt))
    {
    default:
      return;
    case 0:
      SubCategoryViewHolder localSubCategoryViewHolder = (SubCategoryViewHolder)paramViewHolder;
      if (this.mRetailItemComm == null)
      {
        if (paramInt != 0)
          break label102;
        localSubCategoryViewHolder.topLevelHeaderLine.setVisibility(0);
      }
      while (true)
      {
        try
        {
          String str = ((CatalogElement)getItem(paramInt)).getName().trim();
          localSubCategoryViewHolder.catelogeName.setText(Html.fromHtml(UiUtil.getSpannableString(this.mContext, str, "")));
          return;
        }
        catch (Exception localException)
        {
          localException.printStackTrace();
          return;
        }
        label102: localSubCategoryViewHolder.topLevelHeaderLine.setVisibility(8);
      }
    case 1:
    }
    ProductListViewHolder localProductListViewHolder = (ProductListViewHolder)paramViewHolder;
    localProductListViewHolder.initProductCardValue((RetailItemCommunication)getItem(paramInt), localProductListViewHolder, this.mFragment, this.mContext);
  }

  public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup paramViewGroup, int paramInt)
  {
    L.I(" viewType:  " + paramInt);
    switch (paramInt)
    {
    default:
      return null;
    case 0:
      View localView2 = this.mInflater.inflate(2130903159, paramViewGroup, false);
      SubCategoryViewHolder localSubCategoryViewHolder = new SubCategoryViewHolder(localView2);
      getSubCategoryHolder(localView2, localSubCategoryViewHolder);
      return localSubCategoryViewHolder;
    case 1:
    }
    View localView1 = this.mInflater.inflate(2130903113, paramViewGroup, false);
    ProductListViewHolder localProductListViewHolder = new ProductListViewHolder(localView1);
    getProductHolder(localView1, localProductListViewHolder);
    return localProductListViewHolder;
  }

  public void updateList(List<RetailItemCommunication> paramList)
  {
    this.mRetailItemComm = paramList;
    notifyDataSetChanged();
  }

  private static class SubCategoryViewHolder extends RecyclerView.ViewHolder
  {
    public TextView catelogeName;
    public View topLevelHeaderLine;

    public SubCategoryViewHolder(View paramView)
    {
      super();
    }
  }
}

/* Location:           C:\Documents and Settings\Cesar Cabello Cea\Mis documentos\Downloads\apk-downloader\com.ikea.kompis-6_dex2jar.jar
 * Qualified Name:     com.ikea.kompis.recycler.ProductTopLevelTabAdapter
 * JD-Core Version:    0.6.2
 */