AppIndexablesFactory.java
7.73 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
package com.bitstrips.imoji.firebase;
import android.support.annotation.NonNull;
import android.support.annotation.VisibleForTesting;
import com.bitstrips.imoji.firebase.models.IndexableSticker;
import com.bitstrips.imoji.firebase.models.IndexableSticker.Builder;
import com.bitstrips.imoji.firebase.models.IndexableStickerPack;
import com.bitstrips.imoji.firebase.models.IndexableStickerPack.Builder;
import com.bitstrips.imoji.models.Sticker;
import com.bitstrips.imoji.models.StickerPack;
import com.google.firebase.appindexing.FirebaseAppIndexingException;
import com.google.firebase.appindexing.Indexable;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import javax.inject.Singleton;
@Singleton
public class AppIndexablesFactory
{
private static final String a = AppIndexablesFactory.class.getSimpleName();
private static String a(Sticker paramSticker)
{
return "http://bitmoji.com/browser/" + paramSticker.getTemplateId();
}
private static String a(Sticker paramSticker, @NonNull String paramString)
{
return String.format(paramSticker.getImageUrl(), new Object[] { paramString });
}
@VisibleForTesting
private static List<Sticker> a(StickerPack paramStickerPack)
{
ArrayList localArrayList = new ArrayList();
paramStickerPack = paramStickerPack.getStickers().iterator();
while (paramStickerPack.hasNext())
{
Sticker localSticker = (Sticker)paramStickerPack.next();
if (localSticker.isSolomoji()) {
localArrayList.add(localSticker);
}
}
return localArrayList;
}
@VisibleForTesting
private static Map<String, HashSet<String>> a(List<StickerPack> paramList)
{
LinkedHashMap localLinkedHashMap = new LinkedHashMap();
paramList = paramList.iterator();
while (paramList.hasNext())
{
StickerPack localStickerPack = (StickerPack)paramList.next();
String str1 = localStickerPack.getTitle();
Iterator localIterator = a(localStickerPack).iterator();
while (localIterator.hasNext())
{
String str2 = ((Sticker)localIterator.next()).getComicId();
if (!localLinkedHashMap.containsKey(str2)) {
localLinkedHashMap.put(str2, new HashSet());
}
if (b(localStickerPack)) {
((HashSet)localLinkedHashMap.get(str2)).add(str1);
}
}
}
return localLinkedHashMap;
}
@VisibleForTesting
private static List<String> b(List<String> paramList)
{
LinkedHashSet localLinkedHashSet = new LinkedHashSet(paramList.size());
Iterator localIterator = paramList.iterator();
while (localIterator.hasNext())
{
String str = (String)localIterator.next();
paramList = str;
if (str.endsWith("*")) {
paramList = str.substring(0, str.length() - 1);
}
localLinkedHashSet.add(paramList);
}
return new ArrayList(localLinkedHashSet);
}
private static boolean b(StickerPack paramStickerPack)
{
return (paramStickerPack.isVisible()) || ("popular".equals(paramStickerPack.getId()));
}
public static IndexablesDiff<IndexableStickerPack> generateIndexableStickerPacks(List<StickerPack> paramList, String paramString, Map<String, IndexableStickerPack> paramMap)
{
localArrayList1 = new ArrayList();
localArrayList2 = new ArrayList();
localHashSet = new HashSet(paramMap.keySet());
paramList = paramList.iterator();
int j;
for (int i = 1; paramList.hasNext(); i = j)
{
Object localObject = (StickerPack)paramList.next();
j = i;
if (b((StickerPack)localObject))
{
ArrayList localArrayList3 = new ArrayList();
Iterator localIterator = a((StickerPack)localObject).iterator();
while (localIterator.hasNext())
{
Sticker localSticker = (Sticker)localIterator.next();
localArrayList3.add(new IndexableSticker.Builder().fromSticker(localSticker).setGeneratedUrl(a(localSticker)).setImageUrl(a(localSticker, paramString)).build());
}
localObject = new IndexableStickerPack.Builder().fromStickerPack((StickerPack)localObject).setUrl(getStickerPackIndexableUrl(((StickerPack)localObject).getTitle())).setStickers(localArrayList3).build();
if (!((IndexableStickerPack)localObject).equals((IndexableStickerPack)paramMap.get(((IndexableStickerPack)localObject).getUrl()))) {
i = 0;
}
localArrayList1.add(localObject);
localHashSet.remove(((IndexableStickerPack)localObject).getUrl());
j = i;
}
}
if (i == 0) {
try
{
paramList = localArrayList1.iterator();
while (paramList.hasNext()) {
localArrayList2.add(((IndexableStickerPack)paramList.next()).toIndexable());
}
return new IndexablesDiff(localArrayList1, localArrayList2, new ArrayList(localHashSet));
}
catch (FirebaseAppIndexingException paramList)
{
throw new IllegalStateException("Failed to format sticker packs into indexables", paramList);
}
}
}
public static IndexablesDiff<IndexableSticker> generateIndexableStickers(List<StickerPack> paramList, String paramString, Map<String, IndexableSticker> paramMap)
{
localLinkedHashMap = new LinkedHashMap();
Map localMap = a(paramList);
localArrayList = new ArrayList();
localHashSet = new HashSet(paramMap.keySet());
try
{
paramList = paramList.iterator();
while (paramList.hasNext())
{
Iterator localIterator = a((StickerPack)paramList.next()).iterator();
while (localIterator.hasNext())
{
Sticker localSticker = (Sticker)localIterator.next();
if (!localLinkedHashMap.containsKey(localSticker.getComicId()))
{
IndexableSticker localIndexableSticker = new IndexableSticker.Builder().fromSticker(localSticker).setGeneratedUrl(a(localSticker)).setImageUrl(a(localSticker, paramString)).setTags(b(localSticker.getTags())).setStickerPackNames(new ArrayList((Collection)localMap.get(localSticker.getComicId()))).build();
localLinkedHashMap.put(localSticker.getComicId(), localIndexableSticker);
if (!localIndexableSticker.equals((IndexableSticker)paramMap.get(localIndexableSticker.getGeneratedUrl()))) {
localArrayList.add(localIndexableSticker.toIndexable());
}
localHashSet.remove(localIndexableSticker.getGeneratedUrl());
}
}
}
return new IndexablesDiff(new ArrayList(localLinkedHashMap.values()), localArrayList, new ArrayList(localHashSet));
}
catch (FirebaseAppIndexingException paramList)
{
throw new IllegalStateException("Failed to format stickers into indexables", paramList);
}
}
public static String getStickerPackIndexableUrl(String paramString)
{
return "http://bitmoji.com/browser/section/" + paramString;
}
public static class IndexablesDiff<T extends Serializable>
{
private final List<T> a;
private final List<Indexable> b;
private final List<String> c;
public IndexablesDiff(List<T> paramList, List<Indexable> paramList1, List<String> paramList2)
{
this.a = paramList;
this.b = paramList1;
this.c = paramList2;
}
public List<String> getIndexableUrlsToRemove()
{
return this.c;
}
public List<Indexable> getIndexablesToUpdate()
{
return this.b;
}
public List<T> getSerializables()
{
return this.a;
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/bitstrips/imoji/firebase/AppIndexablesFactory.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/