- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
66 lines
3.3 KiB
Java
66 lines
3.3 KiB
Java
package com.helpshift.notification;
|
|
|
|
import com.helpshift.chat.HSEventProxy;
|
|
import com.helpshift.concurrency.HSThreadingService;
|
|
import com.helpshift.log.HSLogger;
|
|
import com.helpshift.poller.FetchNotificationUpdate;
|
|
import com.helpshift.storage.HSPersistentStorage;
|
|
import com.helpshift.user.UserManager;
|
|
import com.mbridge.msdk.newreward.function.common.MBridgeCommon;
|
|
import java.util.HashMap;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public class RequestUnreadMessageCountHandler {
|
|
public final HSEventProxy eventProxy;
|
|
public final FetchNotificationUpdate fetchNotificationUpdate;
|
|
public final HSPersistentStorage persistentStorage;
|
|
public final HSThreadingService threadingService;
|
|
public final UserManager userManager;
|
|
|
|
public RequestUnreadMessageCountHandler(HSPersistentStorage hSPersistentStorage, FetchNotificationUpdate fetchNotificationUpdate, UserManager userManager, HSEventProxy hSEventProxy, HSThreadingService hSThreadingService) {
|
|
this.persistentStorage = hSPersistentStorage;
|
|
this.fetchNotificationUpdate = fetchNotificationUpdate;
|
|
this.userManager = userManager;
|
|
this.eventProxy = hSEventProxy;
|
|
this.threadingService = hSThreadingService;
|
|
}
|
|
|
|
public void handleLocalCacheRequest() {
|
|
HSLogger.d("rqUnrdCntHdlr", "Serving count from local cache.");
|
|
HashMap hashMap = new HashMap();
|
|
hashMap.put("count", Integer.valueOf(Math.max(this.userManager.getUnreadNotificationCount(), this.userManager.getPushUnreadNotificationCount())));
|
|
hashMap.put("fromCache", Boolean.TRUE);
|
|
this.eventProxy.sendEvent("receivedUnreadMessageCount", hashMap);
|
|
}
|
|
|
|
public void handleRemoteRequest() {
|
|
long currentTimeMillis = System.currentTimeMillis();
|
|
long lastRequestUnreadCountApiAccess = this.persistentStorage.getLastRequestUnreadCountApiAccess();
|
|
int i = this.userManager.shouldPoll() ? MBridgeCommon.DEFAULT_LOAD_TIMEOUT : 300000;
|
|
if (lastRequestUnreadCountApiAccess != 0 && currentTimeMillis - lastRequestUnreadCountApiAccess < i) {
|
|
handleLocalCacheRequest();
|
|
return;
|
|
}
|
|
this.persistentStorage.setLastRequestUnreadCountApiAccess(currentTimeMillis);
|
|
HSLogger.d("rqUnrdCntHdlr", "Fetching unread count from remote.");
|
|
this.threadingService.getNetworkService().submit(new Runnable() { // from class: com.helpshift.notification.RequestUnreadMessageCountHandler.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
try {
|
|
int execute = RequestUnreadMessageCountHandler.this.fetchNotificationUpdate.execute();
|
|
boolean z = false;
|
|
if (execute >= 200 && execute < 300) {
|
|
z = true;
|
|
}
|
|
HashMap hashMap = new HashMap();
|
|
hashMap.put("count", Integer.valueOf(RequestUnreadMessageCountHandler.this.userManager.getUnreadNotificationCount()));
|
|
hashMap.put("fromCache", Boolean.valueOf(!z));
|
|
RequestUnreadMessageCountHandler.this.eventProxy.sendEvent("receivedUnreadMessageCount", hashMap);
|
|
} catch (Exception e) {
|
|
HSLogger.e("rqUnrdCntHdlr", "Error in fetching unread count from remote", e);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|