BitmojisView.java 5.77 KB
package com.bitstrips.imoji.keyboard;

import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.content.Context;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.ViewPropertyAnimator;
import com.bitstrips.imoji.InjectorApplication;
import com.bitstrips.imoji.analytics.AnalyticsWrapper;
import com.bitstrips.imoji.analytics.LegacyAnalyticsService;
import com.bitstrips.imoji.analytics.SearchSource;
import com.bitstrips.imoji.browser.BitmojiClickListener;
import com.bitstrips.imoji.browser.adapters.StickerCategoriesAdapter;
import com.bitstrips.imoji.browser.models.StickerCategory;
import com.bitstrips.imoji.browser.models.StickerCategory.EmptyStateType;
import com.bitstrips.imoji.browser.views.StickerViewHolder.OnStickerSelectedListener;
import com.bitstrips.imoji.models.Sticker;
import com.bitstrips.imoji.persistence.MediaCache;
import com.bitstrips.imoji.search.SearchIndex;
import com.crashlytics.android.Crashlytics;
import java.util.Collections;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Provider;

public class BitmojisView
  extends RecyclerView
{
  public static final int GRID_ROW_SIZE_LANDSCAPE = 5;
  public static final int GRID_ROW_SIZE_PORTRAIT = 4;
  @Inject
  SearchIndex M;
  @Inject
  MediaCache N;
  @Inject
  LegacyAnalyticsService O;
  @Inject
  @Named("avatarId")
  Provider<String> P;
  protected BitmojiClickListener mBitmojiClickListener;
  
  public BitmojisView(Context paramContext)
  {
    super(paramContext);
    setUp(paramContext);
  }
  
  public BitmojisView(Context paramContext, AttributeSet paramAttributeSet)
  {
    super(paramContext, paramAttributeSet);
    setUp(paramContext);
  }
  
  public BitmojisView(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
  {
    super(paramContext, paramAttributeSet, paramInt);
    setUp(paramContext);
  }
  
  protected int getImojiColumnCount()
  {
    if (BitmojiOrientation.a(getContext()) == 0) {
      return 4;
    }
    return 5;
  }
  
  @VisibleForTesting
  BitmojiClickListener getmBitmojiClickListener()
  {
    return this.mBitmojiClickListener;
  }
  
  public void hide()
  {
    final float f = getX();
    animate().translationX(getMeasuredWidth()).setListener(new Animator.AnimatorListener()
    {
      public final void onAnimationCancel(Animator paramAnonymousAnimator) {}
      
      public final void onAnimationEnd(Animator paramAnonymousAnimator)
      {
        BitmojisView.this.setVisibility(8);
        BitmojisView.this.setX(f);
      }
      
      public final void onAnimationRepeat(Animator paramAnonymousAnimator) {}
      
      public final void onAnimationStart(Animator paramAnonymousAnimator) {}
    });
  }
  
  public boolean isVisible()
  {
    return getVisibility() == 0;
  }
  
  protected void onAttachedToWindow()
  {
    super.onAttachedToWindow();
    setHasFixedSize(true);
  }
  
  protected void populate(List<Sticker> paramList, @Nullable final String paramString)
  {
    String str = (String)this.P.get();
    if (TextUtils.isEmpty(str))
    {
      Crashlytics.logException(new IllegalStateException("Trying to show Imoji grid with null avatar id!"));
      return;
    }
    setLayoutManager(new GridLayoutManager(getContext(), getImojiColumnCount()));
    paramList = new StickerCategoriesAdapter(str, Collections.singletonList(new StickerCategory(null, paramList, null, StickerCategory.EmptyStateType.IGNORE)), new StickerViewHolder.OnStickerSelectedListener()
    {
      public final void onStickerSelected(Sticker paramAnonymousSticker, String paramAnonymousString)
      {
        if (BitmojisView.this.mBitmojiClickListener != null)
        {
          paramAnonymousString = new AnalyticsWrapper().labelForImojiShare(paramAnonymousSticker, paramAnonymousString);
          if (paramString != null) {
            paramAnonymousString.updateLabelForSearch(paramString, SearchSource.TAG);
          }
          BitmojisView.this.mBitmojiClickListener.onClick(paramAnonymousSticker, paramAnonymousString);
        }
      }
    }, this.N, this.O);
    paramList.init();
    setAdapter(paramList);
  }
  
  public void setClickListener(BitmojiClickListener paramBitmojiClickListener)
  {
    this.mBitmojiClickListener = paramBitmojiClickListener;
  }
  
  protected void setUp(Context paramContext)
  {
    ((InjectorApplication)paramContext.getApplicationContext()).inject(this);
    setVisibility(8);
    setBackgroundColor(-1);
  }
  
  public void showFromSuperTag(String paramString)
  {
    populate(this.M.getStickersForSupertag(paramString), null);
    setVisibility(0);
  }
  
  public void showFromTag(String paramString, boolean paramBoolean)
  {
    populate(this.M.getStickersForTag(paramString), paramString);
    if (paramBoolean)
    {
      final float f = getX();
      setX(getMeasuredWidth());
      animate().translationX(f).setListener(new Animator.AnimatorListener()
      {
        public final void onAnimationCancel(Animator paramAnonymousAnimator) {}
        
        public final void onAnimationEnd(Animator paramAnonymousAnimator)
        {
          BitmojisView.this.setX(f);
        }
        
        public final void onAnimationRepeat(Animator paramAnonymousAnimator) {}
        
        public final void onAnimationStart(Animator paramAnonymousAnimator)
        {
          BitmojisView.this.setVisibility(0);
        }
      });
      return;
    }
    setVisibility(0);
  }
}


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