-
Notifications
You must be signed in to change notification settings - Fork 38
[SDK-705] IterablePushRegistrationTask as Runnable instead of AsyncTask #1093
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
franco-zalamena-iterable
wants to merge
8
commits into
master
from
feature/sdk-705-push-registration-executor
+744
−98
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7af4d8b
IterablePushRegistrationTask as Runnable instead of AsyncTask
franco-zalamena-iterable 2410af8
[SDK-705] Preserve push registration request ordering
franco-zalamena-iterable 3b07d4b
[SDK-705] Isolate push execution lane
franco-zalamena-iterable 1e3be8c
[SDK-705] Keep push request retries on SDK executor
franco-zalamena-iterable 086667c
[SDK-705] Handle malformed push request timestamps
franco-zalamena-iterable 04328b2
[Tests] Make notification image test deterministic
franco-zalamena-iterable 50030e0
[SDK-705] Keep changelog entry under unreleased
franco-zalamena-iterable fc4b5d7
[SDK-705] Order manual token registration with push disable
franco-zalamena-iterable File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
iterableapi/src/main/java/com/iterable/iterableapi/IterableExecutors.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package com.iterable.iterableapi; | ||
|
|
||
| import android.os.Handler; | ||
| import android.os.Looper; | ||
|
|
||
| import java.util.concurrent.Executor; | ||
| import java.util.concurrent.Executors; | ||
|
|
||
| final class IterableExecutors { | ||
| private static final Executor PUSH_EXECUTOR = Executors.newSingleThreadExecutor(runnable -> { | ||
| Thread thread = new Thread(runnable, "IterablePushExecutor"); | ||
| thread.setDaemon(true); | ||
| thread.setPriority(Thread.NORM_PRIORITY); | ||
| return thread; | ||
| }); | ||
| private static final Executor MAIN_EXECUTOR = | ||
| runnable -> new Handler(Looper.getMainLooper()).post(runnable); | ||
|
|
||
| private IterableExecutors() { | ||
| } | ||
|
|
||
| static Executor push() { | ||
| return PUSH_EXECUTOR; | ||
| } | ||
|
|
||
| static Executor main() { | ||
| return MAIN_EXECUTOR; | ||
| } | ||
| } |
20 changes: 10 additions & 10 deletions
20
iterableapi/src/main/java/com/iterable/iterableapi/IterablePushRegistration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,19 @@ | ||
| package com.iterable.iterableapi; | ||
|
|
||
| import androidx.annotation.VisibleForTesting; | ||
| import java.util.concurrent.Executor; | ||
|
|
||
| class IterablePushRegistration { | ||
| final class IterablePushRegistration { | ||
| private final Executor executor; | ||
|
|
||
| @VisibleForTesting | ||
| static IterablePushRegistrationImpl instance = new IterablePushRegistrationImpl(); | ||
| IterablePushRegistration() { | ||
| this(IterableExecutors.push()); | ||
| } | ||
|
|
||
| static void executePushRegistrationTask(IterablePushRegistrationData data) { | ||
| instance.executePushRegistrationTask(data); | ||
| IterablePushRegistration(Executor executor) { | ||
| this.executor = executor; | ||
| } | ||
|
|
||
| static class IterablePushRegistrationImpl { | ||
| void executePushRegistrationTask(IterablePushRegistrationData data) { | ||
| new IterablePushRegistrationTask().execute(data); | ||
| } | ||
| void executePushRegistrationTask(IterablePushRegistrationData data) { | ||
| executor.execute(new IterablePushRegistrationTask(data)); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.