RecentStickersManager.java
2.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
package com.bitstrips.imoji.manager;
import com.bitstrips.imoji.models.Sticker;
import com.bitstrips.imoji.search.SearchIndex;
import com.bitstrips.imoji.search.SearchIndex.OnIndexCompleteListener;
import com.bitstrips.imoji.util.PreferenceUtils;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
@Singleton
public class RecentStickersManager
implements SearchIndex.OnIndexCompleteListener
{
private static final Type b = new TypeToken() {}.getType();
private Gson a;
private Map<String, List<Sticker>> c;
private final PreferenceUtils d;
private final SearchIndex e;
@Inject
public RecentStickersManager(PreferenceUtils paramPreferenceUtils, SearchIndex paramSearchIndex)
{
this.d = paramPreferenceUtils;
this.e = paramSearchIndex;
this.a = new GsonBuilder().enableComplexMapKeySerialization().create();
paramSearchIndex = (Map)this.a.fromJson(this.d.getString(2131231313, null), b);
paramPreferenceUtils = paramSearchIndex;
if (paramSearchIndex == null) {
paramPreferenceUtils = new HashMap();
}
this.c = paramPreferenceUtils;
this.e.addOnIndexCompleteListener(this);
}
private String a()
{
return this.d.getString(2131231176, "");
}
private void a(List<Sticker> paramList)
{
this.c.put(a(), paramList);
this.d.putString(2131231313, this.a.toJson(this.c, b));
}
public void addRecentSticker(Sticker paramSticker)
{
List localList = getRecentStickers();
localList.remove(paramSticker);
localList.add(0, paramSticker);
a(localList.subList(0, Math.min(localList.size(), 6)));
}
public List<Sticker> getRecentStickers()
{
if (!this.c.containsKey(a())) {
return new ArrayList();
}
return (List)this.c.get(a());
}
public void onIndexComplete(SearchIndex paramSearchIndex)
{
Object localObject = getRecentStickers();
if (((List)localObject).isEmpty()) {
return;
}
ArrayList localArrayList = new ArrayList(((List)localObject).size());
localObject = ((List)localObject).iterator();
while (((Iterator)localObject).hasNext())
{
Sticker localSticker = paramSearchIndex.getStickerForComicId(((Sticker)((Iterator)localObject).next()).getComicId());
if (localSticker != null) {
localArrayList.add(localSticker);
}
}
this.c.put(a(), localArrayList);
a(localArrayList);
}
public static abstract interface Callback
{
public abstract void success();
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/bitstrips/imoji/manager/RecentStickersManager.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/