SearchContainerFragment.java
7.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
package com.bitstrips.imoji.ui.fragments;
import android.app.SearchManager;
import android.content.Context;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.Adapter;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.SearchView.OnQueryTextListener;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.view.ViewGroup.LayoutParams;
import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView;
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.adapters.SearchTagsAdapter;
import com.bitstrips.imoji.browser.views.SearchTagViewHolder.OnSearchTagClickListener;
import com.bitstrips.imoji.manager.StickerPacksManager;
import com.bitstrips.imoji.models.SearchTagFactory;
import com.bitstrips.imoji.models.StickerPacks;
import com.bitstrips.imoji.search.PrefixSearchEngine;
import com.bitstrips.imoji.search.PrefixSearchEngine.Callback;
import com.bitstrips.imoji.search.SearchIndex;
import java.util.Collections;
import java.util.List;
import javax.inject.Inject;
public class SearchContainerFragment
extends BitmojiBaseFragment
implements SearchTagViewHolder.OnSearchTagClickListener
{
SearchView a;
View b;
RecyclerView c;
@Inject
SearchIndex d;
@Inject
StickerPacksManager e;
@Inject
LegacyAnalyticsService f;
private SearchSource g;
private ImageView h;
private PrefixSearchEngine i;
private View.OnClickListener j = new View.OnClickListener()
{
public final void onClick(View paramAnonymousView)
{
SearchContainerFragment.this.onBackPressed();
}
};
private void a()
{
this.a.post(new Runnable()
{
public final void run()
{
SearchContainerFragment.this.a.getRootView().clearFocus();
if ((SearchContainerFragment.this.isActivityValid()) && (SearchContainerFragment.this.getActivity().getCurrentFocus() != null)) {
SearchContainerFragment.this.getActivity().getCurrentFocus().clearFocus();
}
}
});
}
private void a(String paramString, List<String> paramList, SearchSource paramSearchSource, boolean paramBoolean)
{
if (!isActivityValid()) {
return;
}
try
{
getFragmentManager().popBackStack();
paramString = SearchResultFragment.newInstance(paramString, paramList, paramSearchSource, paramBoolean);
paramList = getFragmentManager().beginTransaction();
paramList.replace(2131689736, paramString, "fragments.SearchResultFragment").addToBackStack("fragments.SearchResultFragment");
paramList.commit();
return;
}
catch (Exception paramString) {}
}
private void a(boolean paramBoolean)
{
int k = 0;
Object localObject = this.h.getLayoutParams();
if (paramBoolean)
{
((ViewGroup.LayoutParams)localObject).width = -2;
((ViewGroup.LayoutParams)localObject).height = -2;
this.h.setImageResource(2130837724);
this.h.setLayoutParams((ViewGroup.LayoutParams)localObject);
localObject = this.b;
if (!paramBoolean) {
break label79;
}
}
for (;;)
{
((View)localObject).setVisibility(k);
return;
((ViewGroup.LayoutParams)localObject).width = 0;
((ViewGroup.LayoutParams)localObject).height = 0;
this.h.setImageBitmap(null);
break;
label79:
k = 8;
}
}
public static SearchContainerFragment newInstance()
{
return new SearchContainerFragment();
}
public String getFragmentIdentity()
{
return "#search";
}
public String getFragmentSuperTag()
{
return null;
}
protected int getLayout()
{
return 2130903113;
}
protected void initSubViews(View paramView)
{
this.a = ((SearchView)paramView.findViewById(2131689733));
this.b = paramView.findViewById(2131689734);
this.c = ((RecyclerView)paramView.findViewById(2131689735));
paramView = (SearchManager)getContext().getSystemService("search");
this.a.setSearchableInfo(paramView.getSearchableInfo(getActivity().getComponentName()));
a();
this.h = ((ImageView)this.a.findViewById(2131689612));
this.h.setOnClickListener(this.j);
this.h.setPadding(0, 0, 0, 0);
a(false);
this.b.setOnClickListener(this.j);
this.a.setInputType(65536);
this.a.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener()
{
public final void onFocusChange(View paramAnonymousView, boolean paramAnonymousBoolean)
{
if (!paramAnonymousBoolean) {
((InputMethodManager)SearchContainerFragment.this.getContext().getSystemService("input_method")).hideSoftInputFromWindow(paramAnonymousView.getWindowToken(), 0);
}
}
});
a();
this.c.setHasFixedSize(true);
}
public void onBackPressed()
{
this.a.setQuery("", false);
a();
getFragmentManager().popBackStack();
a(false);
}
public void onClick(String paramString)
{
if (isActivityValid())
{
int k = this.d.getStickersForTag(paramString).size();
this.f.sendEvent(Category.CLICK, Action.SEARCH, new AnalyticsWrapper().labelForSearchSubmit(paramString, k));
onQuerySubmit(paramString, SearchSource.TAG, false);
}
}
public void onPause()
{
super.onPause();
this.a.setOnQueryTextListener(null);
}
public void onQuerySubmit(final String paramString, SearchSource paramSearchSource, final boolean paramBoolean)
{
if (TextUtils.isEmpty(paramString)) {
return;
}
this.a.setQuery(paramString, false);
a(true);
a();
this.g = paramSearchSource;
if (paramSearchSource == SearchSource.TAG)
{
a(paramString, Collections.singletonList(paramString), paramSearchSource, paramBoolean);
return;
}
this.i.fetchMatchingTags(paramString, new PrefixSearchEngine.Callback()
{
public final void onComplete(List<String> paramAnonymousList)
{
SearchContainerFragment.a(SearchContainerFragment.this, paramString, paramAnonymousList, SearchSource.SEARCH, paramBoolean);
}
});
}
public void onResume()
{
super.onResume();
this.a.setOnQueryTextListener(new SearchView.OnQueryTextListener()
{
public final boolean onQueryTextChange(String paramAnonymousString)
{
SearchContainerFragment.a(SearchContainerFragment.this, paramAnonymousString.isEmpty());
return false;
}
public final boolean onQueryTextSubmit(String paramAnonymousString)
{
SearchContainerFragment.this.onQuerySubmit(paramAnonymousString, SearchSource.SEARCH, false);
return true;
}
});
}
public void onStart()
{
super.onStart();
this.i = new PrefixSearchEngine(this.d);
Object localObject = this.e.getStickerPacks();
if (localObject != null)
{
localObject = SearchTagFactory.fromStickerPacks(((StickerPacks)localObject).get());
if (isActivityValid())
{
localObject = new SearchTagsAdapter((List)localObject, this);
this.c.setAdapter((RecyclerView.Adapter)localObject);
this.c.setLayoutManager(new GridLayoutManager(getActivity(), 2));
}
}
if (!TextUtils.isEmpty(this.a.getQuery())) {
onQuerySubmit(String.valueOf(this.a.getQuery()), this.g, true);
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/bitstrips/imoji/ui/fragments/SearchContainerFragment.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/