AppIndexingManager.java
4.92 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
package com.bitstrips.imoji.manager;
import android.content.Context;
import android.content.Intent;
import android.os.Build.VERSION;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import com.bitstrips.imoji.behaviour.BehaviourHelper;
import com.bitstrips.imoji.firebase.AppIndexingLegacyScheduler;
import com.bitstrips.imoji.firebase.AppIndexingParams;
import com.bitstrips.imoji.firebase.AppIndexingParams.Builder;
import com.bitstrips.imoji.firebase.AppIndexingService;
import com.bitstrips.imoji.injection.ForApplication;
import com.bitstrips.imoji.models.StickerPacks;
import com.bitstrips.imoji.util.PreferenceUtils;
import com.google.firebase.appindexing.FirebaseAppIndex;
import java.util.WeakHashMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.inject.Inject;
import javax.inject.Singleton;
@Singleton
public class AppIndexingManager
implements StickerPacksManager.OnStickerPacksChangedListener
{
private static final long a = TimeUnit.MINUTES.toMillis(5L);
private static final long b = TimeUnit.MINUTES.toMillis(5L);
private final Context c;
private final PreferenceUtils d;
private final AppIndexingLegacyScheduler e;
private final BehaviourHelper f;
private boolean g = false;
private AtomicBoolean h = new AtomicBoolean(false);
private WeakHashMap<OnFirebaseIndexCompleteListener, Void> i = new WeakHashMap();
@Inject
public AppIndexingManager(@ForApplication Context paramContext, PreferenceUtils paramPreferenceUtils, AppIndexingLegacyScheduler paramAppIndexingLegacyScheduler, BehaviourHelper paramBehaviourHelper, StickerPacksManager paramStickerPacksManager)
{
this.c = paramContext;
this.d = paramPreferenceUtils;
this.e = paramAppIndexingLegacyScheduler;
this.f = paramBehaviourHelper;
paramStickerPacksManager.addOnStickerPacksChangedListener(this);
}
public void addOnFirebaseIndexCompleteListener(OnFirebaseIndexCompleteListener paramOnFirebaseIndexCompleteListener)
{
this.i.put(paramOnFirebaseIndexCompleteListener, null);
}
public void clearIndex()
{
this.g = false;
FirebaseAppIndex.getInstance().removeAll();
}
public boolean hasCompletedIndex()
{
return (this.g) || (this.d.getLong(2131231266, 0L).longValue() != 0L);
}
public void notifyFirebaseIndexCompleteOnMainThread()
{
this.g = true;
Runnable local1 = new Runnable()
{
public final void run()
{
AppIndexingManager.a(AppIndexingManager.this);
}
};
new Handler(Looper.getMainLooper()).post(local1);
}
public void onStickerPacksChanged(StickerPacks paramStickerPacks)
{
if (paramStickerPacks == null)
{
clearIndex();
return;
}
Log.i("AppIndexingManager", "Updating Firebase index due to avatar change..");
updateIndex(new AppIndexingParams.Builder().setIndexingReason("stickers_changed").build());
}
public void removeOnFirebaseIndexCompleteListener(OnFirebaseIndexCompleteListener paramOnFirebaseIndexCompleteListener)
{
this.i.remove(paramOnFirebaseIndexCompleteListener);
}
public void setIsUpdatingIndex(boolean paramBoolean)
{
this.h.set(paramBoolean);
}
public void updateIndex(AppIndexingParams paramAppIndexingParams)
{
int k = 1;
Object localObject = paramAppIndexingParams.getIndexingReason();
int j = k;
if (this.h.getAndSet(true))
{
j = k;
if (!"stickers_changed".equals(localObject)) {
if (!"locale_changed".equals(localObject)) {
break label58;
}
}
}
label58:
for (j = k; j == 0; j = 0)
{
Log.v("AppIndexingManager", "Ignoring app indexing request: already indexing");
return;
}
localObject = new Intent(this.c, AppIndexingService.class);
((Intent)localObject).putExtra("forceRequestAvatarInfo", paramAppIndexingParams.isForceRequestAvatarInfo());
((Intent)localObject).putExtra("forceRequestStickerPacks", paramAppIndexingParams.isForceRequestStickerPacks());
((Intent)localObject).putExtra("forceFlushFirebase", paramAppIndexingParams.isForceFlushFirebase());
((Intent)localObject).putExtra("reason", paramAppIndexingParams.getIndexingReason());
if ((Build.VERSION.SDK_INT >= 21) && (paramAppIndexingParams.getMessenger() != null) && (paramAppIndexingParams.getJobParameters() != null))
{
((Intent)localObject).putExtra("messenger", paramAppIndexingParams.getMessenger());
((Intent)localObject).putExtra("jobParams", paramAppIndexingParams.getJobParameters());
}
this.c.startService((Intent)localObject);
}
public static abstract interface OnFirebaseIndexCompleteListener
{
public abstract void onFirebaseIndexComplete(AppIndexingManager paramAppIndexingManager);
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/bitstrips/imoji/manager/AppIndexingManager.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/