StickerViewHolder.java 3.95 KB
package com.bitstrips.imoji.browser.views;

import android.content.res.Resources;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import com.bitstrips.imoji.analytics.Action;
import com.bitstrips.imoji.analytics.Category;
import com.bitstrips.imoji.analytics.LegacyAnalyticsService;
import com.bitstrips.imoji.analytics.performance.AnalyticsLabelKey;
import com.bitstrips.imoji.analytics.performance.PerformanceTimer;
import com.bitstrips.imoji.analytics.performance.TimedMetric;
import com.bitstrips.imoji.models.Sticker;
import com.bitstrips.imoji.persistence.MediaCache;
import com.squareup.picasso.Callback;
import com.squareup.picasso.RequestCreator;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;

public class StickerViewHolder
  extends RecyclerView.ViewHolder
  implements View.OnClickListener
{
  private final MediaCache n;
  private final LegacyAnalyticsService o;
  private final OnStickerSelectedListener p;
  private final ImageView q;
  private final View r;
  private Sticker s;
  private String t;
  
  public StickerViewHolder(View paramView, MediaCache paramMediaCache, LegacyAnalyticsService paramLegacyAnalyticsService, OnStickerSelectedListener paramOnStickerSelectedListener)
  {
    super(paramView);
    this.n = paramMediaCache;
    this.o = paramLegacyAnalyticsService;
    this.r = paramView.findViewById(2131689791);
    this.q = ((ImageView)paramView.findViewById(2131689792));
    this.p = paramOnStickerSelectedListener;
    this.q.setOnClickListener(this);
  }
  
  public void cancel()
  {
    this.n.cancelRequest(this.q);
  }
  
  public void onClick(View paramView)
  {
    if (this.s != null) {
      this.p.onStickerSelected(this.s, this.t);
    }
  }
  
  public StickerViewHolder setCategoryName(String paramString)
  {
    this.t = paramString;
    return this;
  }
  
  public StickerViewHolder setSticker(final Sticker paramSticker, final String paramString)
  {
    this.s = null;
    this.r.setBackground(this.q.getResources().getDrawable(2130837884));
    this.q.setVisibility(4);
    this.r.setVisibility(0);
    this.q.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    this.n.load(paramSticker.getImageUrl()).fit().into(this.q, new Callback()
    {
      public final void onError()
      {
        StickerViewHolder.b(StickerViewHolder.this).setBackground(StickerViewHolder.a(StickerViewHolder.this).getResources().getDrawable(2130837918));
        StickerViewHolder.b(StickerViewHolder.this).setOnClickListener(new View.OnClickListener()
        {
          public final void onClick(View paramAnonymous2View)
          {
            StickerViewHolder.this.setSticker(StickerViewHolder.1.this.a, StickerViewHolder.1.this.b);
          }
        });
      }
      
      public final void onSuccess()
      {
        StickerViewHolder.a(StickerViewHolder.this, paramSticker);
        StickerViewHolder.a(StickerViewHolder.this).setVisibility(0);
        StickerViewHolder.b(StickerViewHolder.this).setVisibility(8);
        long l = PerformanceTimer.stopTimer(TimedMetric.APP_START);
        if (l != -1L)
        {
          float f = (float)(l / TimeUnit.SECONDS.toMillis(1L));
          HashMap localHashMap = new HashMap(2);
          localHashMap.put(AnalyticsLabelKey.PERFORMANCE_DURATION, Float.valueOf(f));
          localHashMap.put(AnalyticsLabelKey.APP_STATE_KEY, "cold");
          StickerViewHolder.c(StickerViewHolder.this).sendEvent(Category.PERFORMANCE, Action.PERCEIVED_OPEN, localHashMap);
        }
      }
    });
    return this;
  }
  
  public static abstract interface OnStickerSelectedListener
  {
    public abstract void onStickerSelected(Sticker paramSticker, String paramString);
  }
}


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