Skip to content

Commit

Permalink
Bug fix Crash race condition in file QiscusNetworkCheckerJobService (…
Browse files Browse the repository at this point in the history
…onCreate)
  • Loading branch information
Arief Nur Putranto committed Dec 10, 2024
1 parent ff09cd4 commit 7308171
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Second, you need to add SDK dependencies inside your app .gradle. Then, you need
```
dependencies {
...
implementation 'com.qiscus.sdk:chat-core:1.8.3'
implementation 'com.qiscus.sdk:chat-core:1.8.4'
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

import com.qiscus.sdk.chat.core.data.local.QiscusDataBaseHelper;
import com.qiscus.sdk.chat.core.data.local.QiscusDataStore;
import com.qiscus.sdk.chat.core.event.QiscusInitWithCustomServerEvent;
import com.qiscus.sdk.chat.core.util.QiscusTextUtil;

import org.greenrobot.eventbus.EventBus;
import org.json.JSONObject;

import java.util.concurrent.ScheduledThreadPoolExecutor;
Expand Down Expand Up @@ -68,6 +70,7 @@ public synchronized void setup(Application application, String qiscusAppId, Stri
//this.chatConfig = new QiscusCoreChatConfig();
this.dataStore = new QiscusDataBaseHelper(application);
QiscusTextUtil.createInstance(application);
EventBus.getDefault().post((QiscusInitWithCustomServerEvent.wasSetup));
}

public synchronized Application getApplication() {
Expand Down
10 changes: 8 additions & 2 deletions chat-core/src/main/java/com/qiscus/sdk/chat/core/QiscusCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
import com.qiscus.sdk.chat.core.data.model.QiscusRefreshToken;
import com.qiscus.sdk.chat.core.data.remote.QiscusApi;
import com.qiscus.sdk.chat.core.data.remote.QiscusPusherApi;
import com.qiscus.sdk.chat.core.event.QiscusInitWithCustomServerEvent;
import com.qiscus.sdk.chat.core.event.QiscusRefreshTokenEvent;
import com.qiscus.sdk.chat.core.event.QiscusSyncEvent;
import com.qiscus.sdk.chat.core.event.QiscusUserEvent;
import com.qiscus.sdk.chat.core.service.QiscusNetworkCheckerJobService;
import com.qiscus.sdk.chat.core.service.QiscusSyncJobService;
Expand Down Expand Up @@ -415,8 +417,12 @@ public static void stopSyncService() {
* start network checker job service if in oreo or higher
*/
private static void startNetworkCheckerService() {
if (BuildVersionUtil.isOreoOrHigher()) {
QiscusNetworkCheckerJobService.scheduleJob(getApps());
if (appComponent.getAppServer() != null) {
if (BuildVersionUtil.isOreoOrHigher()) {
QiscusNetworkCheckerJobService.scheduleJob(getApps());
}
}else{
EventBus.getDefault().post((QiscusInitWithCustomServerEvent.notSetup));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.qiscus.sdk.chat.core.event;

public enum QiscusInitWithCustomServerEvent {
notSetup, wasSetup
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import com.qiscus.sdk.chat.core.QiscusCore;

import java.util.concurrent.Executors;

/**
* Created on : November 02, 2017
* Author : adicatur
Expand All @@ -21,7 +23,7 @@ public static void print(String message) {
}

public static void print(String tag, String message) {
QiscusAndroidUtil.runOnBackgroundThread(() -> {
Executors.newSingleThreadExecutor().execute(() -> {
if (QiscusCore.getChatConfig().isEnableLog()) {
Log.d(tag, message);
}
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Secondly, you need to add SDK dependencies inside your app .gradle. Then, you ne
```
dependencies {
...
implementation 'com.qiscus.sdk:chat-core:1.8.3'
implementation 'com.qiscus.sdk:chat-core:1.8.4'
}
```

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ chatVersionPatch=0
# === qiscus chat-core library version ===
chatCoreVersionMajor=1
chatCoreVersionMinor=8
chatCoreVersionPatch=3
chatCoreVersionPatch=4

# === qiscus default base url
BASE_URL_SERVER="https://api.qiscus.com/"
Expand All @@ -59,7 +59,7 @@ android.useAndroidX=true

libraryGroupId=com.qiscus.sdk
libraryArtifactId=chat-core
libraryVersion=1.8.3
libraryVersion=1.8.4

libraryGroupIdChat=com.qiscus.sdk
libraryArtifactIdChat=chat
Expand Down

0 comments on commit 7308171

Please sign in to comment.