StickerCategoriesAdapter.java
7.41 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
package com.bitstrips.imoji.browser.adapters;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.util.Pair;
import android.support.v7.widget.RecyclerView.Adapter;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
import android.view.ViewGroup;
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.browser.models.Header;
import com.bitstrips.imoji.browser.models.StickerCategory;
import com.bitstrips.imoji.browser.models.StickerCategory.EmptyStateType;
import com.bitstrips.imoji.browser.views.EmptyStateViewHolder;
import com.bitstrips.imoji.browser.views.HeaderViewHolder;
import com.bitstrips.imoji.browser.views.StickerViewHolder;
import com.bitstrips.imoji.browser.views.StickerViewHolder.OnStickerSelectedListener;
import com.bitstrips.imoji.models.Sticker;
import com.bitstrips.imoji.persistence.MediaCache;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
public class StickerCategoriesAdapter
extends RecyclerView.Adapter
{
private final String a;
private final List<StickerCategory> b;
private final StickerViewHolder.OnStickerSelectedListener c;
private final MediaCache d;
private final LegacyAnalyticsService e;
private int f = 0;
private boolean g = false;
private HashMap<StickerCategory, Integer> h = new HashMap();
public StickerCategoriesAdapter(@NonNull String paramString, List<StickerCategory> paramList, StickerViewHolder.OnStickerSelectedListener paramOnStickerSelectedListener, MediaCache paramMediaCache, LegacyAnalyticsService paramLegacyAnalyticsService)
{
this.a = paramString;
this.b = paramList;
this.c = paramOnStickerSelectedListener;
this.d = paramMediaCache;
this.e = paramLegacyAnalyticsService;
}
@Nullable
private Pair<StickerCategory, Integer> a(int paramInt)
{
Iterator localIterator = this.b.iterator();
int i = 0;
while (localIterator.hasNext())
{
StickerCategory localStickerCategory = (StickerCategory)localIterator.next();
int j = ((Integer)this.h.get(localStickerCategory)).intValue();
if (paramInt >= j)
{
i = j;
}
else
{
j = i;
if (localStickerCategory.hasHeader()) {
j = i + 1;
}
return new Pair(localStickerCategory, Integer.valueOf(paramInt - j));
}
}
return null;
}
public int getCategoryPosition(int paramInt)
{
Pair localPair = a(paramInt);
if (localPair == null) {
return 0;
}
return ((Integer)localPair.second).intValue();
}
public int getItemCount()
{
return this.f;
}
public long getItemId(int paramInt)
{
Pair localPair = a(paramInt);
if (localPair == null) {
return -1L;
}
StickerCategory localStickerCategory = (StickerCategory)localPair.first;
paramInt = ((Integer)localPair.second).intValue();
if (paramInt == -1) {
return localStickerCategory.getHeader().getTitle().hashCode();
}
if (localStickerCategory.isEmpty())
{
switch (2.a[localStickerCategory.getEmptyStateType().ordinal()])
{
default:
return -1L;
}
return 3L;
}
return (localStickerCategory.getName() + ((Sticker)localStickerCategory.getStickers().get(paramInt)).getTemplateId()).hashCode();
}
public int getItemViewType(int paramInt)
{
Pair localPair = a(paramInt);
if (localPair == null) {
return -1;
}
StickerCategory localStickerCategory = (StickerCategory)localPair.first;
if (((Integer)localPair.second).intValue() == -1) {
return 1;
}
if (localStickerCategory.isEmpty())
{
switch (2.a[localStickerCategory.getEmptyStateType().ordinal()])
{
default:
return -1;
}
return 3;
}
return 2;
}
public int getSpanSize(int paramInt1, int paramInt2)
{
switch (getItemViewType(paramInt1))
{
default:
paramInt2 = 0;
case 1:
case 3:
return paramInt2;
}
return 1;
}
public void init()
{
this.h = new HashMap(this.b.size());
this.f = 0;
Iterator localIterator = this.b.iterator();
while (localIterator.hasNext())
{
StickerCategory localStickerCategory = (StickerCategory)localIterator.next();
List localList = localStickerCategory.getStickers();
if (localStickerCategory.hasHeader()) {
this.f += 1;
}
if ((localList.isEmpty()) && (localStickerCategory.getEmptyStateType() != StickerCategory.EmptyStateType.IGNORE)) {
this.f += 1;
}
int i = this.f;
this.f = (localList.size() + i);
this.h.put(localStickerCategory, Integer.valueOf(this.f));
}
setHasStableIds(true);
}
public boolean isItemImoji(int paramInt)
{
return getItemViewType(paramInt) == 2;
}
public void onBindViewHolder(RecyclerView.ViewHolder paramViewHolder, int paramInt)
{
Object localObject = a(paramInt);
if (localObject == null) {}
StickerCategory localStickerCategory;
do
{
return;
localStickerCategory = (StickerCategory)((Pair)localObject).first;
paramInt = ((Integer)((Pair)localObject).second).intValue();
if (paramInt == -1)
{
((HeaderViewHolder)paramViewHolder).setHeader(localStickerCategory.getHeader());
return;
}
} while (localStickerCategory.isEmpty());
localObject = (Sticker)localStickerCategory.getStickers().get(paramInt);
if (!this.g)
{
this.g = true;
new Handler().postDelayed(new Runnable()
{
public final void run()
{
if (PerformanceTimer.stopTimer(TimedMetric.APP_START) == -1L) {
return;
}
HashMap localHashMap = new HashMap(1);
localHashMap.put(AnalyticsLabelKey.APP_STATE_KEY, "timeout");
StickerCategoriesAdapter.a(StickerCategoriesAdapter.this).sendEvent(Category.PERFORMANCE, Action.PERCEIVED_OPEN, localHashMap);
}
}, 55000L);
}
((StickerViewHolder)paramViewHolder).setSticker((Sticker)localObject, this.a).setCategoryName(localStickerCategory.getName());
}
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup paramViewGroup, int paramInt)
{
switch (paramInt)
{
default:
return null;
case 1:
return new HeaderViewHolder(LayoutInflater.from(paramViewGroup.getContext()).inflate(2130903121, paramViewGroup, false));
case 2:
return new StickerViewHolder(LayoutInflater.from(paramViewGroup.getContext()).inflate(2130903130, paramViewGroup, false), this.d, this.e, this.c);
}
return new EmptyStateViewHolder(LayoutInflater.from(paramViewGroup.getContext()).inflate(2130903083, paramViewGroup, false));
}
public void onViewRecycled(RecyclerView.ViewHolder paramViewHolder)
{
if ((paramViewHolder instanceof StickerViewHolder)) {
((StickerViewHolder)paramViewHolder).cancel();
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/bitstrips/imoji/browser/adapters/StickerCategoriesAdapter.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/