├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── strings.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── drawables.xml │ │ │ │ └── styles.xml │ │ │ ├── drawable │ │ │ │ └── side_nav_bar.xml │ │ │ ├── drawable-v21 │ │ │ │ ├── ic_menu_send.xml │ │ │ │ ├── ic_menu_slideshow.xml │ │ │ │ ├── ic_menu_gallery.xml │ │ │ │ ├── ic_menu_manage.xml │ │ │ │ ├── ic_menu_camera.xml │ │ │ │ └── ic_menu_share.xml │ │ │ ├── values-v21 │ │ │ │ └── styles.xml │ │ │ ├── menu │ │ │ │ ├── main.xml │ │ │ │ └── activity_main_drawer.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ └── layout │ │ │ │ ├── content_main.xml │ │ │ │ ├── activity_main.xml │ │ │ │ ├── nav_header_main.xml │ │ │ │ └── app_bar_main.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── flipkart │ │ │ │ └── batchdemo │ │ │ │ ├── EventTag.java │ │ │ │ ├── CustomTagData.java │ │ │ │ └── TrackingHelper.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── flipkart │ │ │ └── batchdemo │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── flipkart │ │ └── batchdemo │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── batching ├── .gitignore ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── flipkart │ │ │ │ └── batching │ │ │ │ ├── toolbox │ │ │ │ ├── LogUtil.java │ │ │ │ └── LenientFileObjectQueue.java │ │ │ │ ├── tape │ │ │ │ ├── FileException.java │ │ │ │ ├── ObjectQueue.java │ │ │ │ └── InMemoryObjectQueue.java │ │ │ │ ├── listener │ │ │ │ ├── TrimmedBatchCallback.java │ │ │ │ ├── PersistedBatchCallback.java │ │ │ │ ├── TagBatchReadyListener.java │ │ │ │ └── TrimPersistedBatchReadyListener.java │ │ │ │ ├── OnBatchReadyListener.java │ │ │ │ ├── persistence │ │ │ │ ├── BatchObjectConverter.java │ │ │ │ ├── DataObjectConverter.java │ │ │ │ ├── PersistenceStrategy.java │ │ │ │ ├── InMemoryPersistenceStrategy.java │ │ │ │ ├── TagBasedPersistenceStrategy.java │ │ │ │ └── SQLPersistenceStrategy.java │ │ │ │ ├── BatchController.java │ │ │ │ ├── BatchingStrategy.java │ │ │ │ └── strategy │ │ │ │ ├── SizeBatchingStrategy.java │ │ │ │ └── BaseBatchingStrategy.java │ │ └── AndroidManifest.xml │ └── test │ │ └── java │ │ ├── com │ │ └── flipkart │ │ │ ├── batching │ │ │ ├── tape │ │ │ │ └── InMemoryObjectQueueTest.java │ │ │ ├── BaseTestClass.java │ │ │ ├── persistence │ │ │ │ └── InMemoryPersistenceTest.java │ │ │ └── listener │ │ │ │ └── TagBatchReadyTest.java │ │ │ └── Utils.java │ │ └── android │ │ └── net │ │ └── http │ │ └── AndroidHttpClient.java ├── proguard-rules.pro ├── gradle.properties └── build.gradle ├── batching-core ├── .gitignore ├── src │ ├── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── flipkart │ │ │ └── batching │ │ │ └── core │ │ │ ├── batch │ │ │ ├── TimeBatch.java │ │ │ ├── SizeBatch.java │ │ │ ├── TagBatch.java │ │ │ └── SizeTimeBatch.java │ │ │ ├── Batch.java │ │ │ ├── data │ │ │ ├── EventData.java │ │ │ ├── TagData.java │ │ │ └── Tag.java │ │ │ ├── DataCollection.java │ │ │ ├── BatchImpl.java │ │ │ ├── SerializationStrategy.java │ │ │ └── Data.java │ └── test │ │ └── java │ │ └── com │ │ └── flipkart │ │ └── batching_core │ │ ├── batch │ │ ├── SizeBatchTest.java │ │ ├── TimeBatchTest.java │ │ ├── TagBatchTest.java │ │ └── SizeTimeBatchTest.java │ │ ├── data │ │ ├── TagTest.java │ │ ├── DataTest.java │ │ └── BatchTest.java │ │ └── Utils.java ├── proguard-rules.pro └── build.gradle ├── batching-gson ├── .gitignore ├── src │ ├── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── flipkart │ │ │ └── batching │ │ │ └── gson │ │ │ └── adapters │ │ │ ├── BatchingTypeAdapterFactory.java │ │ │ ├── data │ │ │ ├── EventDataTypeAdapter.java │ │ │ ├── TagTypeAdapter.java │ │ │ └── TagDataTypeAdapter.java │ │ │ ├── BatchImplTypeAdapter.java │ │ │ ├── DataCollectionTypeAdapter.java │ │ │ └── batch │ │ │ ├── TimeBatchTypeAdapter.java │ │ │ └── SizeBatchTypeAdapter.java │ └── test │ │ └── java │ │ └── com │ │ └── flipkart │ │ └── batching │ │ └── gson │ │ └── adapters │ │ └── BatchingTypeAdaptersTest.java ├── proguard-rules.pro └── build.gradle ├── Batchman.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── .travis.yml ├── PULL_REQUEST_TEMPLATE.md ├── settings.gradle ├── gradle.properties └── gradlew.bat /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /batching/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /batching-core/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /batching-gson/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /Batchman.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flipkart-incubator/batchman/HEAD/Batchman.png -------------------------------------------------------------------------------- /batching-core/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /batching-gson/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flipkart-incubator/batchman/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flipkart-incubator/batchman/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flipkart-incubator/batchman/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flipkart-incubator/batchman/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flipkart-incubator/batchman/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flipkart-incubator/batchman/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | /.idea/misc.xml 7 | .DS_Store 8 | /build 9 | /captures 10 | /.idea -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Jun 03 23:28:38 IST 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: true 2 | language: android 3 | jdk: 4 | - oraclejdk8 5 | android: 6 | components: 7 | - tools 8 | - platform-tools 9 | - build-tools-28.0.3 10 | - android-28 11 | - extra-android-x 12 | - extra-android-m2repository 13 | - extra-google-m2repository 14 | script: 15 | - ./gradlew test -------------------------------------------------------------------------------- /PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | #### Issue Reference 2 | Refer the issue for this change 3 | 4 | #### Change Summary 5 | A brief description of the change. 6 | 7 | #### Implementation Summary 8 | A brief but thorough description of the changes put in place to address the issue. 9 | 10 | #### How to Test 11 | Detailed *list* of what to test and how to test it. Including all edge cases. 12 | -------------------------------------------------------------------------------- /batching/src/main/java/com/flipkart/batching/toolbox/LogUtil.java: -------------------------------------------------------------------------------- 1 | package com.flipkart.batching.toolbox; 2 | 3 | import android.util.Log; 4 | 5 | public class LogUtil { 6 | public static boolean isLoggingEnabled = false; 7 | 8 | public static void log(String tag, String message) { 9 | if (isLoggingEnabled) { 10 | Log.d(tag, message); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/kushal.sharma/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} -------------------------------------------------------------------------------- /batching-core/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/anirudh.r/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /batching-gson/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/anirudh.r/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /batching/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/kushal.sharma/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /batching/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 10 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 11 | # When configured, Gradle will run in incubating parallel mode. 12 | # This option should only be used with decoupled projects. More details, visit 13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 14 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /batching-core/src/main/java/com/flipkart/batching/core/batch/TimeBatch.java: -------------------------------------------------------------------------------- 1 | package com.flipkart.batching.core.batch; 2 | 3 | import androidx.annotation.Keep; 4 | 5 | import com.flipkart.batching.core.BatchImpl; 6 | import com.flipkart.batching.core.Data; 7 | 8 | import java.util.Collection; 9 | 10 | @Keep 11 | public class TimeBatch extends BatchImpl { 12 | private long timeOut; 13 | 14 | public TimeBatch(Collection dataCollection, long timeOut) { 15 | super(dataCollection); 16 | this.timeOut = timeOut; 17 | } 18 | 19 | public long getTimeOut() { 20 | return timeOut; 21 | } 22 | 23 | @Override 24 | public boolean equals(Object o) { 25 | if (o instanceof TimeBatch) { 26 | return ((TimeBatch) o).getTimeOut() == timeOut && super.equals(o); 27 | } 28 | return super.equals(o); 29 | } 30 | 31 | @Override 32 | public int hashCode() { 33 | return 31 * super.hashCode() + Long.valueOf(timeOut).hashCode(); 34 | } 35 | } -------------------------------------------------------------------------------- /batching-core/src/main/java/com/flipkart/batching/core/batch/SizeBatch.java: -------------------------------------------------------------------------------- 1 | package com.flipkart.batching.core.batch; 2 | 3 | import androidx.annotation.Keep; 4 | 5 | import com.flipkart.batching.core.BatchImpl; 6 | import com.flipkart.batching.core.Data; 7 | 8 | import java.util.Collection; 9 | 10 | @Keep 11 | public class SizeBatch extends BatchImpl { 12 | private int maxBatchSize; 13 | 14 | public SizeBatch(Collection dataCollection, int maxBatchSize) { 15 | super(dataCollection); 16 | this.maxBatchSize = maxBatchSize; 17 | } 18 | 19 | public int getMaxBatchSize() { 20 | return maxBatchSize; 21 | } 22 | 23 | @Override 24 | public boolean equals(Object o) { 25 | if (o instanceof SizeBatch) { 26 | return ((SizeBatch) o).getMaxBatchSize() == maxBatchSize && super.equals(o); 27 | } 28 | return super.equals(o); 29 | } 30 | 31 | @Override 32 | public int hashCode() { 33 | return 31 * super.hashCode() + maxBatchSize; 34 | } 35 | } -------------------------------------------------------------------------------- /batching-core/src/main/java/com/flipkart/batching/core/batch/TagBatch.java: -------------------------------------------------------------------------------- 1 | package com.flipkart.batching.core.batch; 2 | 3 | import androidx.annotation.Keep; 4 | 5 | import com.flipkart.batching.core.Batch; 6 | import com.flipkart.batching.core.BatchImpl; 7 | import com.flipkart.batching.core.data.Tag; 8 | import com.flipkart.batching.core.data.TagData; 9 | 10 | @Keep 11 | public class TagBatch extends BatchImpl { 12 | private Tag tag; 13 | 14 | public TagBatch(Tag tag, Batch batch) { 15 | super(batch.getDataCollection()); 16 | this.tag = tag; 17 | } 18 | 19 | public Tag getTag() { 20 | return tag; 21 | } 22 | 23 | @Override 24 | public boolean equals(Object o) { 25 | if (o instanceof TagBatch) { 26 | return ((TagBatch) o).getTag().equals(tag) && super.equals(o); 27 | } 28 | return super.equals(o); 29 | } 30 | 31 | @Override 32 | public int hashCode() { 33 | return 31 * super.hashCode() + (getTag() == null ? 0 : getTag().hashCode()); 34 | } 35 | } -------------------------------------------------------------------------------- /batching/src/main/java/com/flipkart/batching/tape/FileException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Square, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.flipkart.batching.tape; 18 | 19 | import java.io.File; 20 | import java.io.IOException; 21 | 22 | /** 23 | * Encapsulates an {@link IOException} in an extension of {@link RuntimeException}. 24 | */ 25 | public class FileException extends RuntimeException { 26 | private final File file; 27 | 28 | public FileException(String message, IOException e, File file) { 29 | super(message, e); 30 | this.file = file; 31 | } 32 | 33 | public File getFile() { 34 | return file; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /batching-core/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | 4 | dependencies { 5 | implementation 'androidx.annotation:annotation:1.0.2' 6 | testImplementation 'junit:junit:4.12' 7 | } 8 | 9 | android { 10 | compileSdkVersion 28 11 | buildToolsVersion '28.0.3' 12 | 13 | defaultConfig { 14 | minSdkVersion 14 15 | targetSdkVersion 28 16 | versionCode 1 17 | versionName "1.3.12" 18 | 19 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 20 | 21 | } 22 | buildTypes { 23 | release { 24 | minifyEnabled false 25 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 26 | } 27 | } 28 | } 29 | 30 | buildscript { 31 | repositories { 32 | maven { url 'https://repo1.maven.org/maven2' } 33 | maven { url "https://plugins.gradle.org/m2/" } 34 | google() 35 | } 36 | dependencies { 37 | classpath 'com.android.tools.build:gradle:3.4.1' 38 | classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.7.5' 39 | classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' 40 | classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.12" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2017 Flipkart Internet Pvt. Ltd. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | include ':app', ':batching', ':batching-core', ':batching-gson' 26 | -------------------------------------------------------------------------------- /batching/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /batching/src/test/java/com/flipkart/batching/tape/InMemoryObjectQueueTest.java: -------------------------------------------------------------------------------- 1 | package com.flipkart.batching.tape; 2 | 3 | import com.flipkart.batching.BuildConfig; 4 | 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.robolectric.RobolectricTestRunner; 8 | import org.robolectric.annotation.Config; 9 | 10 | import java.util.ArrayList; 11 | 12 | /** 13 | * Test for {@link InMemoryObjectQueue} 14 | */ 15 | 16 | @RunWith(RobolectricTestRunner.class) 17 | @Config(constants = BuildConfig.class, sdk = 21) 18 | public class InMemoryObjectQueueTest { 19 | 20 | /** 21 | * Test for {@link InMemoryObjectQueue#remove()} ) 22 | */ 23 | @Test 24 | public void testRemove() { 25 | InMemoryObjectQueue inMemoryObjectQueue = new InMemoryObjectQueue<>(); 26 | 27 | ArrayList arrayList = new ArrayList<>(4); 28 | arrayList.add("test1"); 29 | arrayList.add("test2"); 30 | arrayList.add("test3"); 31 | arrayList.add("test4"); 32 | 33 | for (String sample : arrayList) { 34 | inMemoryObjectQueue.add(sample); 35 | } 36 | 37 | //remove all the 4 elements added to the queue 38 | inMemoryObjectQueue.remove(arrayList.size()); 39 | 40 | //try removing another element from the queue. 41 | inMemoryObjectQueue.remove(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /batching-core/src/test/java/com/flipkart/batching_core/batch/SizeBatchTest.java: -------------------------------------------------------------------------------- 1 | package com.flipkart.batching.core.batch; 2 | 3 | import junit.framework.Assert; 4 | 5 | import org.junit.Test; 6 | 7 | import java.util.Collections; 8 | 9 | /** 10 | * Created by anirudh.r on 11/08/16. 11 | * Test for {@link SizeBatch} 12 | */ 13 | public class SizeBatchTest { 14 | 15 | /** 16 | * Test to verify the max batch size getters 17 | * 18 | * @throws Exception 19 | */ 20 | @Test 21 | public void testMaxSize() throws Exception { 22 | SizeBatch sizeBatch = new SizeBatch(Collections.EMPTY_LIST, 10); 23 | int maxBatchSize = sizeBatch.getMaxBatchSize(); 24 | Assert.assertTrue(maxBatchSize == 10); 25 | } 26 | 27 | @Test 28 | public void testSizeBatchEqualsMethod() throws Exception { 29 | SizeBatch sizeBatch = new SizeBatch(Collections.EMPTY_LIST, 10); 30 | SizeBatch sizeBatch1 = new SizeBatch(Collections.EMPTY_LIST, 10); 31 | 32 | //assert that both are equal since the sizes are same 33 | Assert.assertTrue(sizeBatch.equals(sizeBatch1)); 34 | 35 | sizeBatch = new SizeBatch(Collections.EMPTY_LIST, 10); 36 | sizeBatch1 = new SizeBatch(Collections.EMPTY_LIST, 11); 37 | 38 | //assert that both are not equal since the sizes are not same 39 | Assert.assertTrue(!sizeBatch.equals(sizeBatch1)); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /batching/src/test/java/android/net/http/AndroidHttpClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2017 Flipkart Internet Pvt. Ltd. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | package android.net.http; 26 | 27 | /** 28 | * Created by kushal.sharma on 05/05/16. 29 | */ 30 | public class AndroidHttpClient { 31 | } 32 | -------------------------------------------------------------------------------- /batching-core/src/main/java/com/flipkart/batching/core/batch/SizeTimeBatch.java: -------------------------------------------------------------------------------- 1 | package com.flipkart.batching.core.batch; 2 | 3 | import androidx.annotation.Keep; 4 | 5 | import com.flipkart.batching.core.BatchImpl; 6 | import com.flipkart.batching.core.Data; 7 | 8 | import java.util.Collection; 9 | 10 | @Keep 11 | public class SizeTimeBatch extends BatchImpl { 12 | private int maxBatchSize; 13 | private long timeOut; 14 | 15 | public SizeTimeBatch(Collection dataCollection, int maxBatchSize, long timeOut) { 16 | super(dataCollection); 17 | this.maxBatchSize = maxBatchSize; 18 | this.timeOut = timeOut; 19 | } 20 | 21 | public int getMaxBatchSize() { 22 | return maxBatchSize; 23 | } 24 | 25 | public long getTimeOut() { 26 | return timeOut; 27 | } 28 | 29 | @Override 30 | public boolean equals(Object o) { 31 | if (o instanceof SizeTimeBatch) { 32 | return (((SizeTimeBatch) o).getMaxBatchSize() == maxBatchSize 33 | && ((SizeTimeBatch) o).getTimeOut() == timeOut 34 | && super.equals(o)); 35 | 36 | } 37 | return super.equals(o); 38 | } 39 | 40 | @Override 41 | public int hashCode() { 42 | int result = super.hashCode(); 43 | result = 31 * result + maxBatchSize; 44 | result = 31 * result + Long.valueOf(timeOut).hashCode(); 45 | return result; 46 | } 47 | } -------------------------------------------------------------------------------- /batching-gson/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | 4 | buildscript { 5 | repositories { 6 | maven { url 'https://repo1.maven.org/maven2' } 7 | maven { url "https://plugins.gradle.org/m2/" } 8 | google() 9 | } 10 | dependencies { 11 | classpath 'com.android.tools.build:gradle:3.4.1' 12 | classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.7.5' 13 | classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' 14 | } 15 | } 16 | 17 | dependencies { 18 | api fileTree(include: ['*.jar'], dir: 'libs') 19 | implementation 'com.google.code.gson:gson:2.8.5' 20 | implementation 'androidx.annotation:annotation:1.0.2' 21 | implementation 'com.github.flipkart-incubator.batchman:batching-core:1.3.9' 22 | 23 | testImplementation 'junit:junit:4.12' 24 | testImplementation 'org.robolectric:robolectric:3.3.2' 25 | } 26 | 27 | android { 28 | compileSdkVersion 28 29 | buildToolsVersion '28.0.3' 30 | 31 | defaultConfig { 32 | minSdkVersion 14 33 | targetSdkVersion 28 34 | versionCode 1 35 | versionName "1.3.12" 36 | 37 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 38 | 39 | } 40 | buildTypes { 41 | release { 42 | minifyEnabled false 43 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /batching-core/src/test/java/com/flipkart/batching_core/batch/TimeBatchTest.java: -------------------------------------------------------------------------------- 1 | package com.flipkart.batching.core.batch; 2 | 3 | import junit.framework.Assert; 4 | 5 | import org.junit.Test; 6 | 7 | import java.util.Collections; 8 | 9 | /** 10 | * Created by anirudh.r on 11/08/16. 11 | * Test for {@link TimeBatch} 12 | */ 13 | public class TimeBatchTest { 14 | 15 | /** 16 | * Test for time out getters 17 | * 18 | * @throws Exception 19 | */ 20 | @Test 21 | public void testTimeOut() throws Exception { 22 | TimeBatch timeBatch = new TimeBatch(Collections.EMPTY_LIST, 1000); 23 | long timeOut = timeBatch.getTimeOut(); 24 | 25 | //assert that time out is equal to 1000 26 | Assert.assertTrue(timeOut == 1000); 27 | } 28 | 29 | /** 30 | * Test for equals method in TimeBatch 31 | * 32 | * @throws Exception 33 | */ 34 | @Test 35 | public void testEqualsMethod() throws Exception { 36 | TimeBatch timeBatch = new TimeBatch(Collections.EMPTY_LIST, 1000); 37 | TimeBatch timeBatch1 = new TimeBatch(Collections.EMPTY_LIST, 1000); 38 | 39 | //assert that both the batches are same 40 | Assert.assertTrue(timeBatch.equals(timeBatch1)); 41 | 42 | timeBatch = new TimeBatch(Collections.EMPTY_LIST, 2000); 43 | timeBatch1 = new TimeBatch(Collections.EMPTY_LIST, 1000); 44 | 45 | //assert that both the batches are not same 46 | Assert.assertTrue(!timeBatch.equals(timeBatch1)); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /batching/src/main/java/com/flipkart/batching/listener/TrimmedBatchCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2017 Flipkart Internet Pvt. Ltd. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | package com.flipkart.batching.listener; 26 | 27 | /** 28 | * Interface for TrimmedBatchCallback 29 | */ 30 | public interface TrimmedBatchCallback { 31 | void onTrimmed(int oldSize, int newSize); 32 | } -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 25 | 26 | 27 | #3F51B5 28 | #303F9F 29 | #FF4081 30 | 31 | -------------------------------------------------------------------------------- /batching-core/src/main/java/com/flipkart/batching/core/Batch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2017 Flipkart Internet Pvt. Ltd. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | package com.flipkart.batching.core; 26 | 27 | import androidx.annotation.Keep; 28 | 29 | import java.util.Collection; 30 | 31 | @Keep 32 | public interface Batch { 33 | Collection getDataCollection(); 34 | } -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | BatchDemo 27 | 28 | Open navigation drawer 29 | Close navigation drawer 30 | 31 | Settings 32 | 33 | -------------------------------------------------------------------------------- /batching/src/main/java/com/flipkart/batching/OnBatchReadyListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2017 Flipkart Internet Pvt. Ltd. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | package com.flipkart.batching; 26 | 27 | 28 | import com.flipkart.batching.core.Batch; 29 | import com.flipkart.batching.core.Data; 30 | 31 | public interface OnBatchReadyListener> { 32 | void onReady(BatchingStrategy causingStrategy, T batch); 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/side_nav_bar.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 27 | 33 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_send.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 30 | 33 | 34 | -------------------------------------------------------------------------------- /batching/src/main/java/com/flipkart/batching/listener/PersistedBatchCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2017 Flipkart Internet Pvt. Ltd. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | package com.flipkart.batching.listener; 26 | 27 | import com.flipkart.batching.core.Batch; 28 | 29 | /** 30 | * Persisted Batch Callback 31 | */ 32 | public interface PersistedBatchCallback { 33 | void onPersistFailure(T batch, Exception e); 34 | 35 | void onPersistSuccess(T batch); 36 | 37 | void onFinish(); 38 | } -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | > 26 | 27 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 25 | 26 | 28 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/test/java/com/flipkart/batchdemo/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2017 Flipkart Internet Pvt. Ltd. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | package com.flipkart.batchdemo; 26 | 27 | import org.junit.Test; 28 | 29 | import static org.junit.Assert.*; 30 | 31 | /** 32 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 33 | */ 34 | public class ExampleUnitTest { 35 | @Test 36 | public void addition_isCorrect() throws Exception { 37 | assertEquals(4, 2 + 2); 38 | } 39 | } -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 29 | 64dp 30 | 31 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/flipkart/batchdemo/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2017 Flipkart Internet Pvt. Ltd. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | package com.flipkart.batchdemo; 26 | 27 | import android.app.Application; 28 | import android.test.ApplicationTestCase; 29 | 30 | /** 31 | * Testing Fundamentals 32 | */ 33 | public class ApplicationTest extends ApplicationTestCase { 34 | public ApplicationTest() { 35 | super(Application.class); 36 | } 37 | } -------------------------------------------------------------------------------- /batching-core/src/test/java/com/flipkart/batching_core/batch/TagBatchTest.java: -------------------------------------------------------------------------------- 1 | package com.flipkart.batching.core.batch; 2 | 3 | import com.flipkart.batching.core.data.Tag; 4 | 5 | import junit.framework.Assert; 6 | 7 | import org.junit.Test; 8 | 9 | import java.util.Collections; 10 | 11 | /** 12 | * Created by anirudh.r on 11/08/16. 13 | * Test for {@link TagBatch} 14 | */ 15 | public class TagBatchTest { 16 | 17 | /** 18 | * Test for get tag 19 | * 20 | * @throws Exception 21 | */ 22 | @Test 23 | public void testGetTag() throws Exception { 24 | TagBatch tagBatch = new TagBatch(new Tag("test"), new SizeBatch(Collections.EMPTY_LIST, 10)); 25 | Tag tag = tagBatch.getTag(); 26 | String id = tag.getId(); 27 | 28 | //assert that the id are same 29 | Assert.assertTrue(id.equals("test")); 30 | } 31 | 32 | /** 33 | * Test for equals method 34 | * 35 | * @throws Exception 36 | */ 37 | @Test 38 | public void testEqualsMethod() throws Exception { 39 | TagBatch tagBatch = new TagBatch(new Tag("test"), new SizeBatch(Collections.EMPTY_LIST, 10)); 40 | TagBatch tagBatch1 = new TagBatch(new Tag("test"), new SizeBatch(Collections.EMPTY_LIST, 10)); 41 | 42 | //assert that both tag batch are same 43 | Assert.assertTrue(tagBatch.equals(tagBatch1)); 44 | 45 | tagBatch = new TagBatch(new Tag("test"), new SizeBatch(Collections.EMPTY_LIST, 10)); 46 | tagBatch1 = new TagBatch(new Tag("test1"), new SizeBatch(Collections.EMPTY_LIST, 10)); 47 | 48 | //assert that both tag batch are not same since they have diff tag 49 | Assert.assertTrue(!tagBatch.equals(tagBatch1)); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/com/flipkart/batchdemo/EventTag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2017 Flipkart Internet Pvt. Ltd. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | package com.flipkart.batchdemo; 26 | 27 | import com.flipkart.batching.core.data.Tag; 28 | import com.google.gson.annotations.SerializedName; 29 | 30 | public class EventTag extends Tag { 31 | 32 | @SerializedName("url") 33 | public String url; 34 | 35 | public EventTag(String id, String url) { 36 | super(id); 37 | this.url = url; 38 | } 39 | 40 | public String getUrl() { 41 | return url; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 27 | 16dp 28 | 160dp 29 | 30 | 16dp 31 | 16dp 32 | 16dp 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_slideshow.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 30 | 33 | 34 | -------------------------------------------------------------------------------- /batching-core/src/main/java/com/flipkart/batching/core/data/EventData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2017 Flipkart Internet Pvt. Ltd. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | package com.flipkart.batching.core.data; 26 | 27 | import androidx.annotation.Keep; 28 | 29 | import com.flipkart.batching.core.Data; 30 | 31 | /** 32 | * EventData class that extends {@link Data}. 33 | */ 34 | @Keep 35 | public class EventData extends Data { 36 | public EventData() { 37 | super(); 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return super.toString() + ":" + getEventId(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_gallery.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 30 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_manage.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 30 | 33 | -------------------------------------------------------------------------------- /batching/src/main/java/com/flipkart/batching/toolbox/LenientFileObjectQueue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2017 Flipkart Internet Pvt. Ltd. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | package com.flipkart.batching.toolbox; 26 | 27 | import com.flipkart.batching.tape.FileObjectQueue; 28 | 29 | import java.io.File; 30 | import java.io.IOException; 31 | 32 | /** 33 | * A wrapper over {@link LenientFileObjectQueue} 34 | */ 35 | 36 | public class LenientFileObjectQueue extends FileObjectQueue { 37 | public LenientFileObjectQueue(File file, Converter converter, LenientQueueFile.QueueFileErrorCallback errorCallback) throws IOException { 38 | super(file, new LenientQueueFile(file, errorCallback), converter); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_camera.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 30 | 33 | 36 | 37 | -------------------------------------------------------------------------------- /app/src/main/res/values/drawables.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | @android:drawable/ic_menu_camera 27 | @android:drawable/ic_menu_gallery 28 | @android:drawable/ic_menu_slideshow 29 | @android:drawable/ic_menu_manage 30 | @android:drawable/ic_menu_share 31 | @android:drawable/ic_menu_send 32 | 33 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_share.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 30 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/flipkart/batchdemo/CustomTagData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2017 Flipkart Internet Pvt. Ltd. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | package com.flipkart.batchdemo; 26 | 27 | import androidx.annotation.Keep; 28 | 29 | import com.flipkart.batching.core.data.Tag; 30 | import com.flipkart.batching.core.data.TagData; 31 | import com.google.gson.annotations.SerializedName; 32 | 33 | import org.json.JSONObject; 34 | 35 | @Keep 36 | public class CustomTagData extends TagData { 37 | @SerializedName("event") 38 | public JSONObject event; 39 | 40 | public CustomTagData(Tag tag, JSONObject event) { 41 | super(tag); 42 | this.event = event; 43 | } 44 | 45 | public JSONObject getEvent() { 46 | return event; 47 | } 48 | 49 | @Override 50 | public String toString() { 51 | return super.toString() + ":" + getEventId(); 52 | } 53 | } -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 27 | 28 | 34 | 35 | 39 | 40 |