Skip to content

Commit

Permalink
Merge pull request #156 from premacck/develop
Browse files Browse the repository at this point in the history
Exposing forced argument from BatchController
  • Loading branch information
ananyachandra14 authored Jul 5, 2023
2 parents 03f5762 + 0c3e1b3 commit 69cfd22
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 10 deletions.
4 changes: 2 additions & 2 deletions batching-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ android {
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.3.11"
versionName "1.3.12"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand All @@ -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"
}
}
}
4 changes: 2 additions & 2 deletions batching-gson/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ android {
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.3.11"
versionName "1.3.12"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand All @@ -43,4 +43,4 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
}
4 changes: 2 additions & 2 deletions batching/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ android {
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.3.11"
versionName "1.3.12"
}

buildTypes {
Expand Down Expand Up @@ -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"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,17 @@ public interface BatchController<E extends Data, T extends Batch<E>> {
*
* @param dataCollection collection of {@link Data}
*/

void addToBatch(Collection<E> 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<E> dataCollection, boolean forced);

/**
* This method returns the initialized {@link Handler}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,18 @@ public void run() {

@Override
public void addToBatch(final Collection<E> dataCollection) {
addToBatch(dataCollection, false);
}

@Override
public void addToBatch(final Collection<E> 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");
}
Expand Down Expand Up @@ -202,4 +207,4 @@ public BatchManager<E, T> build(Context context) {
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,18 @@ void initialize(TagBatchManager<E, T> tagBatchManager, Context context, OnBatchR

@Override
public void addToBatch(final Collection<E> dataCollection) {
addToBatch(dataCollection, false);
}

@Override
public void addToBatch(final Collection<E> dataCollection, final boolean forced) {
handler.post(new Runnable() {
@Override
public void run() {
assignEventIds(dataCollection);
if (tagBatchingStrategy.isInitialized()) {
tagBatchingStrategy.onDataPushed((Collection<TagData>) dataCollection);
tagBatchingStrategy.flush(false);
tagBatchingStrategy.flush(forced);
} else {
throw new IllegalAccessError("BatchingStrategy is not initialized");
}
Expand Down

0 comments on commit 69cfd22

Please sign in to comment.