SearchResultFragment.java 4.75 KB
package com.bitstrips.imoji.ui.fragments;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import com.bitstrips.imoji.analytics.Action;
import com.bitstrips.imoji.analytics.AnalyticsWrapper;
import com.bitstrips.imoji.analytics.Category;
import com.bitstrips.imoji.analytics.LegacyAnalyticsService;
import com.bitstrips.imoji.analytics.SearchSource;
import com.bitstrips.imoji.browser.BitmojiClickListener;
import com.bitstrips.imoji.browser.ImojiCategoriesViewController;
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.ArrayList;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Provider;

public class SearchResultFragment
  extends BitmojiBaseFragment
  implements StickerViewHolder.OnStickerSelectedListener
{
  public static final String KEY_FROM = "fragments.key.from";
  public static final String KEY_IS_RELOAD = "fragments.key.is.reload";
  public static final String KEY_QUERY = "fragments.key.query";
  public static final String KEY_TAGS = "fragments.key.tags";
  public static final String TAG_FRAGMENT_SEARCH = "fragments.SearchResultFragment";
  TextView a;
  @Inject
  SearchIndex b;
  @Inject
  MediaCache c;
  @Inject
  LegacyAnalyticsService d;
  @Inject
  @Named("avatarId")
  Provider<String> e;
  private BitmojiClickListener f;
  private SearchSource g;
  private String h;
  
  public static SearchResultFragment newInstance(String paramString, List<String> paramList, SearchSource paramSearchSource, boolean paramBoolean)
  {
    paramString = new Bundle();
    paramString.putStringArrayList("fragments.key.tags", new ArrayList(paramList));
    paramString.putSerializable("fragments.key.from", paramSearchSource);
    paramString.putBoolean("fragments.key.is.reload", paramBoolean);
    paramList = new SearchResultFragment();
    paramList.setArguments(paramString);
    return paramList;
  }
  
  public String getFragmentIdentity()
  {
    return "#search";
  }
  
  public String getFragmentSuperTag()
  {
    return null;
  }
  
  protected int getLayout()
  {
    return 2130903112;
  }
  
  protected void initSubViews(View paramView)
  {
    if (!isActivityValid()) {
      return;
    }
    String str = (String)this.e.get();
    if (TextUtils.isEmpty(str))
    {
      Crashlytics.logException(new IllegalStateException("Trying to show Imoji grid with null avatar id!"));
      return;
    }
    Object localObject = getArguments().getStringArrayList("fragments.key.tags");
    boolean bool = getArguments().getBoolean("fragments.key.is.reload");
    this.h = getArguments().getString("fragments.key.query");
    this.g = ((SearchSource)getArguments().getSerializable("fragments.key.from"));
    localObject = this.b.getStickersForTags((List)localObject);
    new ImojiCategoriesViewController((RecyclerView)paramView.findViewById(2131689731), new StickerCategory("#search", (List)localObject, null, StickerCategory.EmptyStateType.IGNORE), this, this.c, this.d).init(getContext(), str);
    this.a = ((TextView)paramView.findViewById(2131689732));
    paramView = this.a;
    if (((List)localObject).isEmpty()) {}
    for (int i = 0;; i = 8)
    {
      paramView.setVisibility(i);
      if (bool) {
        break;
      }
      paramView = this.h;
      i = ((List)localObject).size();
      if (this.g != SearchSource.SEARCH) {
        break;
      }
      this.d.sendEvent(Category.TEXT, Action.SEARCH, new AnalyticsWrapper().labelForSearchSubmit(paramView, i));
      return;
    }
  }
  
  public void onAttach(Activity paramActivity)
  {
    super.onAttach(paramActivity);
    if (!(paramActivity instanceof BitmojiClickListener)) {
      throw new RuntimeException("the activity must implement BitmojiClickListener");
    }
    this.f = ((BitmojiClickListener)paramActivity);
  }
  
  public void onDetach()
  {
    super.onDetach();
    this.f = null;
  }
  
  public void onStickerSelected(Sticker paramSticker, String paramString)
  {
    if (this.f != null)
    {
      paramString = new AnalyticsWrapper().labelForImojiShare(paramSticker, paramString).updateLabelForSearch(this.h, this.g);
      this.f.onClick(paramSticker, paramString);
    }
  }
}


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