Skip to content

Commit

Permalink
fix ANR issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Arief Nur Putranto committed Jul 30, 2024
1 parent 9b607de commit 11eb8e4
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 15 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.7.1'
implementation 'com.qiscus.sdk:chat-core:1.8.1'
}
```

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.0.0'
classpath 'com.google.gms:google-services:4.3.15'
classpath 'com.android.tools.build:gradle:8.5.0'
classpath 'com.google.gms:google-services:4.4.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
import android.os.Build;
import androidx.annotation.RequiresApi;

import com.google.firebase.annotations.concurrent.Background;
import com.qiscus.sdk.chat.core.QiscusCore;
import com.qiscus.sdk.chat.core.event.QiscusUserEvent;
import com.qiscus.sdk.chat.core.util.QiscusAndroidUtil;
import com.qiscus.sdk.chat.core.util.QiscusErrorLogger;
import com.qiscus.sdk.chat.core.util.QiscusLogger;

Expand Down Expand Up @@ -114,9 +116,18 @@ public void onCreate() {

@Override
public void onDestroy() {
unregisterReceiver(networkStateReceiver);
QiscusLogger.print(TAG, "onDestroy");
EventBus.getDefault().unregister(this);
QiscusAndroidUtil.runOnBackgroundThread(() -> {
try {
unregisterReceiver(networkStateReceiver);
QiscusLogger.print(TAG, "onDestroy");
EventBus.getDefault().unregister(this);
}catch (IllegalArgumentException e) {
// already unregistered
}

});


super.onDestroy();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ public static void print(String message) {
}

public static void print(String tag, String message) {
if (QiscusCore.getChatConfig().isEnableLog()) {
Log.d(tag, message);
}
QiscusAndroidUtil.runOnBackgroundThread(() -> {
if (QiscusCore.getChatConfig().isEnableLog()) {
Log.d(tag, message);
}
});
}
}
4 changes: 2 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ repositories {
ext {

minSDKVersion = 21
targetSDKVersion = 33
compileSDKVersion = 33
targetSDKVersion = 34
compileSDKVersion = 34

versions = [
support : "31.0.0",
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.7.1'
implementation 'com.qiscus.sdk:chat-core:1.8.1'
}
```

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=0
chatCoreVersionPatch=1

# === 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.0
libraryVersion=1.8.1

libraryGroupIdChat=com.qiscus.sdk
libraryArtifactIdChat=chat
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue May 02 22:11:28 WIB 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 11eb8e4

Please sign in to comment.