Skip to content

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
v4.13.1 Release

See merge request gamesanalytics/android-sdk!48
  • Loading branch information
unity-thull committed Aug 28, 2020
2 parents 821a46d + df297c3 commit 351e8b1
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 25 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Change Log

## [4.13.1](https://github.com/deltaDNA/android-sdk/releases/tag/4.13.1)

### Fixed
- Time consuming calls on engage response errors no longer block the UI thread

## [4.13.0](https://github.com/deltaDNA/android-sdk/releases/tag/4.13.0)

### Added
Expand Down
2 changes: 1 addition & 1 deletion README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ allprojects {
```
在你APP的构建脚本
```groovy
compile 'com.deltadna.android:deltadna-sdk:4.13.0'
compile 'com.deltadna.android:deltadna-sdk:4.13.1'
```

## 初始化
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ allprojects {
In your app's build script:
```groovy
dependencies {
implementation 'com.deltadna.android:deltadna-sdk:4.13.0'
implementation 'com.deltadna.android:deltadna-sdk:4.13.1'
}
```
The Java source and target compatibility needs to be set to 1.8 in you app's build script:
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GROUP=com.deltadna.android
VERSION_NAME=4.13.0
VERSION_NAME=4.13.1

POM_DESCRIPTION=deltaDNA SDK for Android
POM_URL=https://github.com/deltaDNA/android-sdk
Expand Down
4 changes: 2 additions & 2 deletions library-notifications/README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ allprojects {
```
在你APP的构建脚本
```groovy
compile 'com.deltadna.android:deltadna-sdk:4.13.0'
compile 'com.deltadna.android:deltadna-sdk-notifications:4.13.0'
compile 'com.deltadna.android:deltadna-sdk:4.13.1'
compile 'com.deltadna.android:deltadna-sdk-notifications:4.13.1'
```

## 整合
Expand Down
4 changes: 2 additions & 2 deletions library-notifications/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ allprojects {
In your app's build script:
```groovy
dependencies {
implementation 'com.deltadna.android:deltadna-sdk:4.13.0'
implementation 'com.deltadna.android:deltadna-sdk-notifications:4.13.0'
implementation 'com.deltadna.android:deltadna-sdk:4.13.1'
implementation 'com.deltadna.android:deltadna-sdk-notifications:4.13.1'
}
```

Expand Down
45 changes: 27 additions & 18 deletions library/src/main/java/com/deltadna/android/sdk/EventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

import android.os.AsyncTask;
import androidx.annotation.Nullable;

import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import com.deltadna.android.sdk.helpers.ClientInfo;
import com.deltadna.android.sdk.listeners.EngageListener;
Expand Down Expand Up @@ -48,6 +51,8 @@ final class EventHandler {
new ScheduledThreadPoolExecutor(1, r -> new Thread(
r,
EventHandler.class.getSimpleName()));

private final Handler mainThreadTaskHandler = new Handler(Looper.getMainLooper());

private final EventStore events;
private final EngageStore engagements;
Expand Down Expand Up @@ -218,25 +223,29 @@ public void onCompleted(Response<JSONObject> result) {

@Override
public void onError(Throwable t) {
final JSONObject cached = engagements.get(engagement);
if (cached != null) {
try {
engagement.setResponse(new Response<>(
200,
true,
null,
cached.put("isCachedResponse", true),
null));

Log.d(TAG, "Using cached response " + engagement.getJson());

listener.onCompleted(engagement);
} catch (JSONException e) {
listener.onError(e);
// This needs to be run off the main thread, as it involves blocking database
// operations that can cause ANRs.
executor.execute(() -> {
final JSONObject cached = engagements.get(engagement);
if (cached != null) {
try {
engagement.setResponse(new Response<>(
200,
true,
null,
cached.put("isCachedResponse", true),
null));

Log.d(TAG, "Using cached response " + engagement.getJson());

mainThreadTaskHandler.post(() -> listener.onCompleted(engagement));
} catch (JSONException e) {
mainThreadTaskHandler.post(() -> listener.onError(e));
}
} else {
mainThreadTaskHandler.post(() -> listener.onError(t));
}
} else {
listener.onError(t);
}
});
}
}, "config".equalsIgnoreCase(engagement.name) && "internal".equalsIgnoreCase(engagement.flavour));
return null;
Expand Down

0 comments on commit 351e8b1

Please sign in to comment.