Skip to content

Commit

Permalink
fix: after close
Browse files Browse the repository at this point in the history
  • Loading branch information
arifBurakDemiray committed Jan 31, 2025
1 parent 37ec527 commit 82afc57
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 8 additions & 2 deletions sdk/src/main/java/ly/count/android/sdk/ModuleContent.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public class ModuleContent extends ModuleBase {
private boolean shouldFetchContents = false;
private final int zoneTimerInterval;
private final ContentCallback globalContentCallback;
static int waitForDelay = 0;
private int waitForDelay = 0;

ModuleContent(@NonNull Countly cly, @NonNull CountlyConfig config) {
super(cly, config);
L.v("[ModuleContent] Initialising");
L.v("[ModuleContent] Initialising, zoneTimerInterval: [" + config.content.zoneTimerInterval + "], globalContentCallback: [" + config.content.globalContentCallback + "]");
iRGenerator = config.immediateRequestGenerator;

contentInterface = new Content();
Expand Down Expand Up @@ -107,6 +107,12 @@ void registerForContentUpdates(@Nullable String[] categories) {
}, L);
}

void notifyAfterContentIsClosed() {
L.v("[ModuleContent] notifyAfterContentIsClosed, setting waitForDelay to 2 and shouldFetchContents to true");
waitForDelay = 2; // this is indicating that we will wait 1 min after closing the content and before fetching the next one
shouldFetchContents = true;
}

@NonNull
private String prepareContentFetchRequest(@NonNull DisplayMetrics displayMetrics, @NonNull String[] categories) {
Resources resources = _cly.context_.getResources();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,10 @@ private boolean contentUrlAction(String url, WebView view) {
if (globalContentCallback != null) { // TODO: verify this later
globalContentCallback.onContentCallback(ContentStatus.CLOSED, query);
}
ModuleContent.waitForDelay = 2; // this is indicating that we will wait 1 min after closing the content and before fetching the next one

if (Countly.sharedInstance().isInitialized()) {
Countly.sharedInstance().moduleContent.notifyAfterContentIsClosed();
}
finish();
}

Expand Down

0 comments on commit 82afc57

Please sign in to comment.