Skip to content

Commit fe89bd0

Browse files
author
Arief Nur Putranto
committed
prevent crash when destroy in file qiscusNetworkChecker
1 parent 7308171 commit fe89bd0

File tree

4 files changed

+23
-11
lines changed

4 files changed

+23
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Second, you need to add SDK dependencies inside your app .gradle. Then, you need
5454
```
5555
dependencies {
5656
...
57-
implementation 'com.qiscus.sdk:chat-core:1.8.4'
57+
implementation 'com.qiscus.sdk:chat-core:1.8.5'
5858
}
5959
```
6060

chat-core/src/main/java/com/qiscus/sdk/chat/core/service/QiscusNetworkCheckerJobService.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.greenrobot.eventbus.EventBus;
3939
import org.greenrobot.eventbus.Subscribe;
4040

41+
import java.util.concurrent.Executors;
4142
import java.util.concurrent.TimeUnit;
4243

4344
import static android.net.ConnectivityManager.CONNECTIVITY_ACTION;
@@ -116,18 +117,21 @@ public void onCreate() {
116117

117118
@Override
118119
public void onDestroy() {
119-
QiscusAndroidUtil.runOnBackgroundThread(() -> {
120+
121+
Executors.newSingleThreadExecutor().execute(() -> {
120122
try {
121123
unregisterReceiver(networkStateReceiver);
122124
QiscusLogger.print(TAG, "onDestroy");
123125
EventBus.getDefault().unregister(this);
124126
}catch (IllegalArgumentException e) {
125127
// already unregistered
128+
}catch (RuntimeException r) {
129+
QiscusErrorLogger.print(r);
130+
} catch (Exception e) {
131+
QiscusErrorLogger.print(e);
126132
}
127-
128133
});
129134

130-
131135
super.onDestroy();
132136
}
133137

@@ -151,10 +155,18 @@ public void onUserEvent(QiscusUserEvent userEvent) {
151155
}
152156

153157
private void stopJob() {
154-
QiscusLogger.print(TAG, "stopJob");
155-
JobScheduler jobScheduler = (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE);
156-
if (jobScheduler != null) {
157-
jobScheduler.cancel(STATIC_JOB_ID);
158+
try {
159+
QiscusLogger.print(TAG, "stopJob");
160+
JobScheduler jobScheduler = (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE);
161+
if (jobScheduler != null) {
162+
jobScheduler.cancel(STATIC_JOB_ID);
163+
}
164+
}catch (IllegalArgumentException e) {
165+
// already unregistered
166+
}catch (RuntimeException r) {
167+
QiscusErrorLogger.print(r);
168+
} catch (Exception e) {
169+
QiscusErrorLogger.print(e);
158170
}
159171
}
160172
}

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Secondly, you need to add SDK dependencies inside your app .gradle. Then, you ne
8080
```
8181
dependencies {
8282
...
83-
implementation 'com.qiscus.sdk:chat-core:1.8.4'
83+
implementation 'com.qiscus.sdk:chat-core:1.8.5'
8484
}
8585
```
8686

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ chatVersionPatch=0
4343
# === qiscus chat-core library version ===
4444
chatCoreVersionMajor=1
4545
chatCoreVersionMinor=8
46-
chatCoreVersionPatch=4
46+
chatCoreVersionPatch=5
4747

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

6060
libraryGroupId=com.qiscus.sdk
6161
libraryArtifactId=chat-core
62-
libraryVersion=1.8.4
62+
libraryVersion=1.8.5
6363

6464
libraryGroupIdChat=com.qiscus.sdk
6565
libraryArtifactIdChat=chat

0 commit comments

Comments
 (0)