From 5ade1b44ebbe9f6fc87239dac73de5d28c71cfab Mon Sep 17 00:00:00 2001 From: Prem Suman Date: Tue, 4 Jul 2023 17:15:55 +0530 Subject: [PATCH 1/2] Exposing forced argument from BatchController Exposing `forced` from BatchController.addToBatch so that it is configurable from callers. --- .../java/com/flipkart/batching/BatchController.java | 10 +++++++++- .../main/java/com/flipkart/batching/BatchManager.java | 9 +++++++-- .../java/com/flipkart/batching/TagBatchManager.java | 7 ++++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/batching/src/main/java/com/flipkart/batching/BatchController.java b/batching/src/main/java/com/flipkart/batching/BatchController.java index 9b0df70..b0c5595 100644 --- a/batching/src/main/java/com/flipkart/batching/BatchController.java +++ b/batching/src/main/java/com/flipkart/batching/BatchController.java @@ -44,9 +44,17 @@ public interface BatchController> { * * @param dataCollection collection of {@link Data} */ - void addToBatch(Collection dataCollection); + /** + * This method takes {@link Data} type {@link Collection} and a boolean as parameter and notifies the provided + * {@link BatchingStrategy} about the added data. + * + * @param dataCollection collection of {@link Data} + * @param forced whether to forcefully trigger the event call + */ + void addToBatch(Collection dataCollection, boolean forced); + /** * This method returns the initialized {@link Handler}. * diff --git a/batching/src/main/java/com/flipkart/batching/BatchManager.java b/batching/src/main/java/com/flipkart/batching/BatchManager.java index 31576a7..d918d16 100644 --- a/batching/src/main/java/com/flipkart/batching/BatchManager.java +++ b/batching/src/main/java/com/flipkart/batching/BatchManager.java @@ -80,13 +80,18 @@ public void run() { @Override public void addToBatch(final Collection dataCollection) { + addToBatch(dataCollection, false); + } + + @Override + public void addToBatch(final Collection dataCollection, final boolean forced) { handler.post(new Runnable() { @Override public void run() { assignEventIds(dataCollection); if (batchingStrategy.isInitialized()) { batchingStrategy.onDataPushed(dataCollection); - batchingStrategy.flush(false); + batchingStrategy.flush(forced); } else { throw new IllegalAccessError("BatchingStrategy is not initialized"); } @@ -202,4 +207,4 @@ public BatchManager build(Context context) { } } -} \ No newline at end of file +} diff --git a/batching/src/main/java/com/flipkart/batching/TagBatchManager.java b/batching/src/main/java/com/flipkart/batching/TagBatchManager.java index 2fd5c37..779ac81 100644 --- a/batching/src/main/java/com/flipkart/batching/TagBatchManager.java +++ b/batching/src/main/java/com/flipkart/batching/TagBatchManager.java @@ -87,13 +87,18 @@ void initialize(TagBatchManager tagBatchManager, Context context, OnBatchR @Override public void addToBatch(final Collection dataCollection) { + addToBatch(dataCollection, false); + } + + @Override + public void addToBatch(final Collection dataCollection, final boolean forced) { handler.post(new Runnable() { @Override public void run() { assignEventIds(dataCollection); if (tagBatchingStrategy.isInitialized()) { tagBatchingStrategy.onDataPushed((Collection) dataCollection); - tagBatchingStrategy.flush(false); + tagBatchingStrategy.flush(forced); } else { throw new IllegalAccessError("BatchingStrategy is not initialized"); } From 0c3e1b300e5d9fc98a87c479bb1e8c8d1518b158 Mon Sep 17 00:00:00 2001 From: Prem Suman Date: Tue, 4 Jul 2023 17:31:44 +0530 Subject: [PATCH 2/2] version bump to 1.3.12 --- batching-core/build.gradle | 4 ++-- batching-gson/build.gradle | 4 ++-- batching/build.gradle | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/batching-core/build.gradle b/batching-core/build.gradle index f11ac7b..ab4d671 100644 --- a/batching-core/build.gradle +++ b/batching-core/build.gradle @@ -14,7 +14,7 @@ android { minSdkVersion 14 targetSdkVersion 28 versionCode 1 - versionName "1.3.11" + versionName "1.3.12" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -39,4 +39,4 @@ buildscript { classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.12" } -} \ No newline at end of file +} diff --git a/batching-gson/build.gradle b/batching-gson/build.gradle index e7acd88..607ce68 100644 --- a/batching-gson/build.gradle +++ b/batching-gson/build.gradle @@ -32,7 +32,7 @@ android { minSdkVersion 14 targetSdkVersion 28 versionCode 1 - versionName "1.3.11" + versionName "1.3.12" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -43,4 +43,4 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } -} \ No newline at end of file +} diff --git a/batching/build.gradle b/batching/build.gradle index d7af73e..d6b4c4a 100644 --- a/batching/build.gradle +++ b/batching/build.gradle @@ -38,7 +38,7 @@ android { minSdkVersion 14 targetSdkVersion 28 versionCode 1 - versionName "1.3.11" + versionName "1.3.12" } buildTypes { @@ -78,4 +78,4 @@ buildscript { classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.12" } -} \ No newline at end of file +}