diff --git a/README.md b/README.md index 86e25817..f41cff6b 100644 --- a/README.md +++ b/README.md @@ -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' } ``` diff --git a/chat-core/src/main/java/com/qiscus/sdk/chat/core/QiscusAppComponent.java b/chat-core/src/main/java/com/qiscus/sdk/chat/core/QiscusAppComponent.java index 548b3485..8fe726a9 100644 --- a/chat-core/src/main/java/com/qiscus/sdk/chat/core/QiscusAppComponent.java +++ b/chat-core/src/main/java/com/qiscus/sdk/chat/core/QiscusAppComponent.java @@ -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; @@ -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() { diff --git a/chat-core/src/main/java/com/qiscus/sdk/chat/core/QiscusCore.java b/chat-core/src/main/java/com/qiscus/sdk/chat/core/QiscusCore.java index 81346cbb..4f20b2ec 100644 --- a/chat-core/src/main/java/com/qiscus/sdk/chat/core/QiscusCore.java +++ b/chat-core/src/main/java/com/qiscus/sdk/chat/core/QiscusCore.java @@ -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; @@ -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)); } } diff --git a/chat-core/src/main/java/com/qiscus/sdk/chat/core/event/QiscusInitWithCustomServerEvent.java b/chat-core/src/main/java/com/qiscus/sdk/chat/core/event/QiscusInitWithCustomServerEvent.java new file mode 100644 index 00000000..960f8be2 --- /dev/null +++ b/chat-core/src/main/java/com/qiscus/sdk/chat/core/event/QiscusInitWithCustomServerEvent.java @@ -0,0 +1,5 @@ +package com.qiscus.sdk.chat.core.event; + +public enum QiscusInitWithCustomServerEvent { + notSetup, wasSetup +} diff --git a/chat-core/src/main/java/com/qiscus/sdk/chat/core/util/QiscusLogger.java b/chat-core/src/main/java/com/qiscus/sdk/chat/core/util/QiscusLogger.java index dbea750c..51dd014c 100644 --- a/chat-core/src/main/java/com/qiscus/sdk/chat/core/util/QiscusLogger.java +++ b/chat-core/src/main/java/com/qiscus/sdk/chat/core/util/QiscusLogger.java @@ -5,6 +5,8 @@ import com.qiscus.sdk.chat.core.QiscusCore; +import java.util.concurrent.Executors; + /** * Created on : November 02, 2017 * Author : adicatur @@ -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); } diff --git a/docs/index.md b/docs/index.md index 9a0e27c1..e7464935 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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' } ``` diff --git a/gradle.properties b/gradle.properties index ff689142..c92e4a9b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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/" @@ -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