ImojiCategoriesViewController.java 4.01 KB
package com.bitstrips.imoji.browser;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Rect;
import android.support.annotation.NonNull;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.GridLayoutManager.SpanSizeLookup;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ItemDecoration;
import android.support.v7.widget.RecyclerView.State;
import android.util.DisplayMetrics;
import android.view.View;
import com.bitstrips.imoji.analytics.LegacyAnalyticsService;
import com.bitstrips.imoji.browser.adapters.StickerCategoriesAdapter;
import com.bitstrips.imoji.browser.models.StickerCategory;
import com.bitstrips.imoji.browser.views.StickerViewHolder.OnStickerSelectedListener;
import com.bitstrips.imoji.persistence.MediaCache;
import java.util.Collections;
import java.util.List;

public class ImojiCategoriesViewController
{
  private final RecyclerView a;
  private final List<StickerCategory> b;
  private final StickerViewHolder.OnStickerSelectedListener c;
  private final MediaCache d;
  private final LegacyAnalyticsService e;
  private StickerCategoriesAdapter f;
  
  public ImojiCategoriesViewController(RecyclerView paramRecyclerView, StickerCategory paramStickerCategory, StickerViewHolder.OnStickerSelectedListener paramOnStickerSelectedListener, MediaCache paramMediaCache, LegacyAnalyticsService paramLegacyAnalyticsService)
  {
    this(paramRecyclerView, Collections.singletonList(paramStickerCategory), paramOnStickerSelectedListener, paramMediaCache, paramLegacyAnalyticsService);
  }
  
  public ImojiCategoriesViewController(RecyclerView paramRecyclerView, List<StickerCategory> paramList, StickerViewHolder.OnStickerSelectedListener paramOnStickerSelectedListener, MediaCache paramMediaCache, LegacyAnalyticsService paramLegacyAnalyticsService)
  {
    this.a = paramRecyclerView;
    this.b = paramList;
    this.c = paramOnStickerSelectedListener;
    this.d = paramMediaCache;
    this.e = paramLegacyAnalyticsService;
  }
  
  public void init(Context paramContext, @NonNull String paramString)
  {
    paramContext = new GridLayoutManager(paramContext, 3);
    final int i = (int)(8.0F * this.a.getResources().getDisplayMetrics().density);
    paramContext.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup()
    {
      public final int getSpanSize(int paramAnonymousInt)
      {
        return ImojiCategoriesViewController.a(ImojiCategoriesViewController.this).getSpanSize(paramAnonymousInt, 3);
      }
    });
    this.a.setHasFixedSize(true);
    this.a.setLayoutManager(paramContext);
    this.a.addItemDecoration(new RecyclerView.ItemDecoration()
    {
      public final void getItemOffsets(Rect paramAnonymousRect, View paramAnonymousView, RecyclerView paramAnonymousRecyclerView, RecyclerView.State paramAnonymousState)
      {
        int i = paramAnonymousRecyclerView.getChildAdapterPosition(paramAnonymousView);
        float f2 = paramAnonymousRecyclerView.getWidth();
        float f1 = f2 / 3.0F;
        f2 = (f2 - this.a) / 3.0F;
        paramAnonymousRect.bottom = i;
        if (ImojiCategoriesViewController.a(ImojiCategoriesViewController.this).isItemImoji(i))
        {
          i = ImojiCategoriesViewController.a(ImojiCategoriesViewController.this).getCategoryPosition(i) % 3;
          float f3 = i;
          float f4 = i;
          paramAnonymousRect.left = ((int)((f2 + i) * f4 + f3 - f1 * i));
          paramAnonymousRect.right = (i - paramAnonymousRect.left);
          if (i < 3) {
            paramAnonymousRect.top = i;
          }
        }
      }
    });
    reloadAdapter(paramString);
  }
  
  public void reloadAdapter(@NonNull String paramString)
  {
    this.f = new StickerCategoriesAdapter(paramString, this.b, this.c, this.d, this.e);
    this.f.init();
    this.a.setAdapter(this.f);
  }
}


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