├── 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
│ │ │ ├── drawable
│ │ │ │ ├── ic_toys_black_24dp.png
│ │ │ │ ├── ic_error_outline_black_24dp.png
│ │ │ │ └── photogrid_list_selector.xml
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── styles.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ ├── activity_web_socket.xml
│ │ │ │ └── image_grid_fragment.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── networking
│ │ │ │ ├── model
│ │ │ │ └── User.java
│ │ │ │ ├── ApiEndPoint.java
│ │ │ │ ├── ImageGridActivity.java
│ │ │ │ ├── MyApplication.java
│ │ │ │ └── utils
│ │ │ │ └── Utils.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── androidnetworking
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── androidnetworking
│ │ └── ApplicationTest.java
├── proguard-rules.pro
└── build.gradle
├── rxsampleapp
├── .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
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── styles.xml
│ │ │ └── layout
│ │ │ │ └── activity_subscription.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── rxsampleapp
│ │ │ │ ├── model
│ │ │ │ ├── ApiUser.java
│ │ │ │ ├── UserDetail.java
│ │ │ │ └── User.java
│ │ │ │ ├── ApiEndPoint.java
│ │ │ │ ├── RxMyApplication.java
│ │ │ │ ├── utils
│ │ │ │ └── Utils.java
│ │ │ │ └── SubscriptionActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── rxsampleapp
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── rxsampleapp
│ │ └── ApplicationTest.java
├── proguard-rules.pro
└── build.gradle
├── rx2sampleapp
├── .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
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── styles.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ └── activity_subscription.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── rx2sampleapp
│ │ │ │ ├── model
│ │ │ │ ├── ApiUser.java
│ │ │ │ ├── UserDetail.java
│ │ │ │ └── User.java
│ │ │ │ ├── ApiEndPoint.java
│ │ │ │ ├── Rx2MyApplication.java
│ │ │ │ ├── utils
│ │ │ │ └── Utils.java
│ │ │ │ └── SubscriptionActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── rx2sampleapp
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── rx2sampleapp
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── android-networking
├── .gitignore
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── androidnetworking
│ │ │ │ ├── model
│ │ │ │ ├── MultipartStringBody.java
│ │ │ │ ├── MultipartFileBody.java
│ │ │ │ └── Progress.java
│ │ │ │ ├── common
│ │ │ │ ├── RequestType.java
│ │ │ │ ├── ResponseType.java
│ │ │ │ ├── Method.java
│ │ │ │ ├── ConnectionQuality.java
│ │ │ │ ├── Priority.java
│ │ │ │ ├── ANConstants.java
│ │ │ │ ├── ANResponse.java
│ │ │ │ └── RequestBuilder.java
│ │ │ │ ├── interfaces
│ │ │ │ ├── UploadProgressListener.java
│ │ │ │ ├── DownloadProgressListener.java
│ │ │ │ ├── AnalyticsListener.java
│ │ │ │ ├── DownloadListener.java
│ │ │ │ ├── StringRequestListener.java
│ │ │ │ ├── ConnectionQualityChangeListener.java
│ │ │ │ ├── BitmapRequestListener.java
│ │ │ │ ├── JSONArrayRequestListener.java
│ │ │ │ ├── JSONObjectRequestListener.java
│ │ │ │ ├── ParsedRequestListener.java
│ │ │ │ ├── OkHttpResponseListener.java
│ │ │ │ ├── OkHttpResponseAndParsedRequestListener.java
│ │ │ │ ├── OkHttpResponseAndStringRequestListener.java
│ │ │ │ ├── OkHttpResponseAndBitmapRequestListener.java
│ │ │ │ ├── OkHttpResponseAndJSONArrayRequestListener.java
│ │ │ │ ├── OkHttpResponseAndJSONObjectRequestListener.java
│ │ │ │ └── Parser.java
│ │ │ │ ├── core
│ │ │ │ ├── ExecutorSupplier.java
│ │ │ │ ├── MainThreadExecutor.java
│ │ │ │ ├── Core.java
│ │ │ │ ├── PriorityThreadFactory.java
│ │ │ │ └── DefaultExecutorSupplier.java
│ │ │ │ ├── utils
│ │ │ │ ├── SourceCloseUtil.java
│ │ │ │ └── ParseUtil.java
│ │ │ │ ├── cache
│ │ │ │ └── LruBitmapCache.java
│ │ │ │ ├── gsonparserfactory
│ │ │ │ ├── GsonResponseBodyParser.java
│ │ │ │ ├── GsonRequestBodyParser.java
│ │ │ │ └── GsonParserFactory.java
│ │ │ │ ├── internal
│ │ │ │ ├── UploadProgressHandler.java
│ │ │ │ ├── DownloadProgressHandler.java
│ │ │ │ ├── RequestProgressBody.java
│ │ │ │ └── ResponseProgressBody.java
│ │ │ │ ├── interceptors
│ │ │ │ └── GzipRequestInterceptor.java
│ │ │ │ └── error
│ │ │ │ └── ANError.java
│ │ ├── res
│ │ │ └── values
│ │ │ │ └── strings.xml
│ │ └── AndroidManifest.xml
│ ├── androidTest
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── androidnetworking
│ │ │ │ └── model
│ │ │ │ └── User.java
│ │ └── AndroidManifest.xml
│ └── test
│ │ └── java
│ │ └── com
│ │ └── androidnetworking
│ │ └── ExampleUnitTest.java
├── proguard-rules.pro
├── build.gradle
└── upload.gradle
├── rx-android-networking
├── .gitignore
├── proguard-rules.pro
├── src
│ ├── main
│ │ ├── res
│ │ │ └── values
│ │ │ │ └── strings.xml
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── rxandroidnetworking
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── rxandroidnetworking
│ │ └── ApplicationTest.java
├── build.gradle
└── rx-upload.gradle
├── jackson-android-networking
├── .gitignore
├── proguard-rules.pro
├── src
│ ├── main
│ │ ├── res
│ │ │ └── values
│ │ │ │ └── strings.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── jacksonandroidnetworking
│ │ │ ├── JacksonResponseBodyParser.java
│ │ │ └── JacksonRequestBodyParser.java
│ ├── androidTest
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── jacksonandroidnetworking
│ │ │ │ └── model
│ │ │ │ └── User.java
│ │ └── AndroidManifest.xml
│ └── test
│ │ └── java
│ │ └── com
│ │ └── jacksonandroidnetworking
│ │ └── ExampleUnitTest.java
└── build.gradle
├── rx2-android-networking
├── .gitignore
├── proguard-rules.pro
├── src
│ ├── main
│ │ ├── res
│ │ │ └── values
│ │ │ │ └── strings.xml
│ │ └── AndroidManifest.xml
│ ├── androidTest
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── rx2androidnetworking
│ │ │ │ └── model
│ │ │ │ └── User.java
│ │ └── AndroidManifest.xml
│ └── test
│ │ └── java
│ │ └── com
│ │ └── rx2androidnetworking
│ │ └── ExampleUnitTest.java
└── build.gradle
├── assets
├── get_started.png
├── rxjavacomponent.png
└── androidnetworking.png
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── CONTRIBUTING.md
├── settings.gradle
├── .travis.yml
├── gradle.properties
├── gradlew.bat
└── CHANGELOG.md
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/rxsampleapp/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/rx2sampleapp/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/android-networking/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/rx-android-networking/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/jackson-android-networking/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/rx2-android-networking/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/assets/get_started.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wutongke/Fast-Android-Networking/master/assets/get_started.png
--------------------------------------------------------------------------------
/assets/rxjavacomponent.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wutongke/Fast-Android-Networking/master/assets/rxjavacomponent.png
--------------------------------------------------------------------------------
/assets/androidnetworking.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wutongke/Fast-Android-Networking/master/assets/androidnetworking.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wutongke/Fast-Android-Networking/master/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wutongke/Fast-Android-Networking/master/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wutongke/Fast-Android-Networking/master/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | /.idea
10 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wutongke/Fast-Android-Networking/master/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wutongke/Fast-Android-Networking/master/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_toys_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wutongke/Fast-Android-Networking/master/app/src/main/res/drawable/ic_toys_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wutongke/Fast-Android-Networking/master/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/rx2sampleapp/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wutongke/Fast-Android-Networking/master/rx2sampleapp/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/rx2sampleapp/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wutongke/Fast-Android-Networking/master/rx2sampleapp/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/rx2sampleapp/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wutongke/Fast-Android-Networking/master/rx2sampleapp/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/rxsampleapp/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wutongke/Fast-Android-Networking/master/rxsampleapp/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/rxsampleapp/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wutongke/Fast-Android-Networking/master/rxsampleapp/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/rxsampleapp/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wutongke/Fast-Android-Networking/master/rxsampleapp/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/rxsampleapp/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wutongke/Fast-Android-Networking/master/rxsampleapp/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/rx2sampleapp/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wutongke/Fast-Android-Networking/master/rx2sampleapp/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/rx2sampleapp/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wutongke/Fast-Android-Networking/master/rx2sampleapp/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/rxsampleapp/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wutongke/Fast-Android-Networking/master/rxsampleapp/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_error_outline_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wutongke/Fast-Android-Networking/master/app/src/main/res/drawable/ic_error_outline_black_24dp.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Apr 12 21:48:48 IST 2018
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-4.4-all.zip
7 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | 1. Fork it!
4 | 2. Checkout the development branch: `git checkout development`
5 | 3. Create your feature branch: `git checkout -b my-new-feature`
6 | 4. Add your changes to the index: `git add .`
7 | 5. Commit your changes: `git commit -m 'Add some feature'`
8 | 6. Push to the branch: `git push origin my-new-feature`
9 | 7. Submit a pull request against the `development` branch
10 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/model/MultipartStringBody.java:
--------------------------------------------------------------------------------
1 | package com.androidnetworking.model;
2 |
3 | public class MultipartStringBody {
4 |
5 | public final String value;
6 | public final String contentType;
7 |
8 | public MultipartStringBody(String value, String contentType) {
9 | this.value = value;
10 | this.contentType = contentType;
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/model/MultipartFileBody.java:
--------------------------------------------------------------------------------
1 | package com.androidnetworking.model;
2 |
3 | import java.io.File;
4 |
5 | public class MultipartFileBody {
6 |
7 | public final File file;
8 | public final String contentType;
9 |
10 | public MultipartFileBody(File file, String contentType) {
11 | this.file = file;
12 | this.contentType = contentType;
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/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/amitshekhar/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 |
--------------------------------------------------------------------------------
/rx2sampleapp/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/amitshekhar/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 |
--------------------------------------------------------------------------------
/rxsampleapp/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 C:\Users\Psych Inc\AppData\Local\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 |
--------------------------------------------------------------------------------
/rx-android-networking/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/amitshekhar/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 |
--------------------------------------------------------------------------------
/rx2-android-networking/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/amitshekhar/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 |
--------------------------------------------------------------------------------
/jackson-android-networking/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/amitshekhar/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 |
--------------------------------------------------------------------------------
/android-networking/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/amitshekhar/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 |
19 | # For OkHttp
20 | -dontwarn okio.**
21 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 | AndroidNetworking
20 |
21 |
--------------------------------------------------------------------------------
/rxsampleapp/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 | RxSampleApp
20 |
21 |
--------------------------------------------------------------------------------
/android-networking/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 | Android Networking
20 |
21 |
--------------------------------------------------------------------------------
/rx-android-networking/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 | rxandroidnetworking
20 |
21 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | include ':app', ':android-networking', ':rx-android-networking', ':rxsampleapp', ':jackson-android-networking', ':rx2-android-networking', ':rx2sampleapp'
19 |
--------------------------------------------------------------------------------
/android-networking/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
20 |
21 |
--------------------------------------------------------------------------------
/rx-android-networking/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
20 |
21 |
--------------------------------------------------------------------------------
/rx2sampleapp/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
19 |
20 |
21 | Rx2SampleApp
22 |
23 |
--------------------------------------------------------------------------------
/rx2-android-networking/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
19 |
20 |
21 | Rx2AndroidNetworking
22 |
23 |
--------------------------------------------------------------------------------
/jackson-android-networking/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
19 |
20 |
21 | JacksonAndroidNetworking
22 |
23 |
--------------------------------------------------------------------------------
/rx2-android-networking/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
19 |
20 |
22 |
23 |
--------------------------------------------------------------------------------
/jackson-android-networking/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
19 |
20 |
22 |
23 |
--------------------------------------------------------------------------------
/rxsampleapp/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 |
20 | #3F51B5
21 | #303F9F
22 | #FF4081
23 |
24 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/common/RequestType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.common;
19 |
20 | /**
21 | * Created by amitshekhar on 04/04/16.
22 | */
23 | public interface RequestType {
24 | int SIMPLE = 0;
25 | int DOWNLOAD = 1;
26 | int MULTIPART = 2;
27 | }
28 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/interfaces/UploadProgressListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.interfaces;
19 |
20 | /**
21 | * Created by amitshekhar on 21/04/16.
22 | */
23 | public interface UploadProgressListener {
24 | void onProgress(long bytesUploaded, long totalBytes);
25 | }
26 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/interfaces/DownloadProgressListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.interfaces;
19 |
20 | /**
21 | * Created by amitshekhar on 30/03/16.
22 | */
23 | public interface DownloadProgressListener {
24 | void onProgress(long bytesDownloaded, long totalBytes);
25 | }
26 |
--------------------------------------------------------------------------------
/rx2sampleapp/src/main/java/com/rx2sampleapp/model/ApiUser.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.rx2sampleapp.model;
21 |
22 | /**
23 | * Created by amitshekhar on 02/08/16.
24 | */
25 | public class ApiUser {
26 | public long id;
27 | public String firstname;
28 | public String lastname;
29 | }
30 |
--------------------------------------------------------------------------------
/rxsampleapp/src/main/java/com/rxsampleapp/model/ApiUser.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.rxsampleapp.model;
21 |
22 | /**
23 | * Created by amitshekhar on 02/08/16.
24 | */
25 | public class ApiUser {
26 | public long id;
27 | public String firstname;
28 | public String lastname;
29 | }
30 |
--------------------------------------------------------------------------------
/android-networking/src/androidTest/java/com/androidnetworking/model/User.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.androidnetworking.model;
21 |
22 | /**
23 | * Created by amitshekhar on 10/04/17.
24 | */
25 |
26 | public class User {
27 |
28 | public String firstName;
29 | public String lastName;
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/common/ResponseType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.common;
19 |
20 | /**
21 | * Created by amitshekhar on 26/03/16.
22 | */
23 | public enum ResponseType {
24 | STRING,
25 | JSON_OBJECT,
26 | JSON_ARRAY,
27 | OK_HTTP_RESPONSE,
28 | BITMAP,
29 | PREFETCH,
30 | PARSED
31 | }
32 |
--------------------------------------------------------------------------------
/rx2sampleapp/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
22 | #3F51B5
23 | #303F9F
24 | #FF4081
25 |
26 |
--------------------------------------------------------------------------------
/rx2sampleapp/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
19 |
20 |
21 |
22 | 16dp
23 | 16dp
24 |
25 |
--------------------------------------------------------------------------------
/rxsampleapp/src/main/java/com/rxsampleapp/model/UserDetail.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.rxsampleapp.model;
21 |
22 | /**
23 | * Created by amitshekhar on 02/08/16.
24 | */
25 | public class UserDetail {
26 |
27 | public long id;
28 | public String firstname;
29 | public String lastname;
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/interfaces/AnalyticsListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.interfaces;
19 |
20 | /**
21 | * Created by amitshekhar on 31/05/16.
22 | */
23 | public interface AnalyticsListener {
24 |
25 | void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache);
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/rx2-android-networking/src/androidTest/java/com/rx2androidnetworking/model/User.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.rx2androidnetworking.model;
21 |
22 | /**
23 | * Created by amitshekhar on 26/04/17.
24 | */
25 |
26 | public class User {
27 |
28 | public String firstName;
29 | public String lastName;
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/rx2sampleapp/src/main/java/com/rx2sampleapp/model/UserDetail.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.rx2sampleapp.model;
21 |
22 | /**
23 | * Created by amitshekhar on 02/08/16.
24 | */
25 | public class UserDetail {
26 |
27 | public long id;
28 | public String firstname;
29 | public String lastname;
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/networking/model/User.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.networking.model;
21 |
22 | /**
23 | * Created by amitshekhar on 31/07/16.
24 | */
25 | public class User {
26 |
27 | public long id;
28 | public String firstname;
29 | public String lastname;
30 | public boolean isFollowing;
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/common/Method.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.common;
19 |
20 | /**
21 | * Created by amitshekhar on 26/03/16.
22 | */
23 | public interface Method {
24 | int GET = 0;
25 | int POST = 1;
26 | int PUT = 2;
27 | int DELETE = 3;
28 | int HEAD = 4;
29 | int PATCH = 5;
30 | int OPTIONS = 6;
31 | }
32 |
--------------------------------------------------------------------------------
/jackson-android-networking/src/androidTest/java/com/jacksonandroidnetworking/model/User.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.jacksonandroidnetworking.model;
21 |
22 | /**
23 | * Created by amitshekhar on 05/05/17.
24 | */
25 |
26 | public class User {
27 |
28 | public String firstName;
29 | public String lastName;
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/android-networking/src/androidTest/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/interfaces/DownloadListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.interfaces;
19 |
20 | import com.androidnetworking.error.ANError;
21 |
22 | /**
23 | * Created by amitshekhar on 29/04/16.
24 | */
25 | public interface DownloadListener {
26 |
27 | void onDownloadComplete();
28 |
29 | void onError(ANError anError);
30 | }
31 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: android
2 |
3 | env:
4 | global:
5 | - ADB_INSTALL_TIMEOUT=30
6 | # Using the new Container-Based Infrastructure
7 | - sudo: false
8 | # Turning off caching to avoid caching Issues
9 | - cache: false
10 | # Initiating clean Gradle output
11 | - TERM=dumb
12 | # Giving even more memory to Gradle JVM
13 | - GRADLE_OPTS="-Xmx2048m -XX:MaxPermSize=1024m"
14 |
15 | android:
16 | components:
17 | - tools
18 | - platform-tools
19 | - build-tools-27.0.3
20 | - android-27
21 | - android-24
22 | - android-23
23 | - android-22
24 | - extra-google-google_play_services
25 | - extra-google-m2repository
26 | - extra-android-m2repository
27 | - sys-img-armeabi-v7a-android-22
28 |
29 | # Emulator Management: Create, Start and Wait
30 | before_script:
31 | - echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a -c 32M
32 | - emulator -avd test -no-audio -no-window &
33 | - android-wait-for-emulator
34 | - sleep 180
35 | - adb devices
36 | - adb shell input keyevent 82 &
37 |
38 | script:
39 | - ./gradlew connectedAndroidTest
40 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 |
20 | #3F51B5
21 | #303F9F
22 | #FF4081
23 | #1Affffff
24 | #80000000
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 | 16dp
21 | 16dp
22 |
23 | 100dp
24 | 1dp
25 |
26 |
--------------------------------------------------------------------------------
/rxsampleapp/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 | 16dp
21 | 16dp
22 |
23 | 100dp
24 | 1dp
25 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/interfaces/StringRequestListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.interfaces;
19 |
20 | import com.androidnetworking.error.ANError;
21 |
22 | /**
23 | * Created by amitshekhar on 23/05/16.
24 | */
25 | public interface StringRequestListener {
26 |
27 | void onResponse(String response);
28 |
29 | void onError(ANError anError);
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/core/ExecutorSupplier.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.core;
19 |
20 | import java.util.concurrent.Executor;
21 |
22 | /**
23 | * Created by amitshekhar on 22/03/16.
24 | */
25 | public interface ExecutorSupplier {
26 |
27 | ANExecutor forNetworkTasks();
28 |
29 | ANExecutor forImmediateNetworkTasks();
30 |
31 | Executor forMainThreadTasks();
32 | }
33 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/interfaces/ConnectionQualityChangeListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.interfaces;
19 |
20 | import com.androidnetworking.common.ConnectionQuality;
21 |
22 | /**
23 | * Created by amitshekhar on 29/05/16.
24 | */
25 | public interface ConnectionQualityChangeListener {
26 |
27 | void onChange(ConnectionQuality currentConnectionQuality, int currentBandwidth);
28 | }
29 |
--------------------------------------------------------------------------------
/rxsampleapp/src/test/java/com/rxsampleapp/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.rxsampleapp;
19 |
20 | import org.junit.Test;
21 |
22 | import static org.junit.Assert.*;
23 |
24 | /**
25 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
26 | */
27 | public class ExampleUnitTest {
28 | @Test
29 | public void addition_isCorrect() throws Exception {
30 | assertEquals(4, 2 + 2);
31 | }
32 | }
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
22 | 64dp
23 |
24 |
--------------------------------------------------------------------------------
/app/src/test/java/com/androidnetworking/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking;
19 |
20 | import org.junit.Test;
21 |
22 | import static org.junit.Assert.*;
23 |
24 | /**
25 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
26 | */
27 | public class ExampleUnitTest {
28 | @Test
29 | public void addition_isCorrect() throws Exception {
30 | assertEquals(4, 2 + 2);
31 | }
32 | }
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/interfaces/BitmapRequestListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.interfaces;
19 |
20 | import android.graphics.Bitmap;
21 |
22 | import com.androidnetworking.error.ANError;
23 |
24 | /**
25 | * Created by amitshekhar on 23/05/16.
26 | */
27 | public interface BitmapRequestListener {
28 |
29 | void onResponse(Bitmap response);
30 |
31 | void onError(ANError anError);
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/interfaces/JSONArrayRequestListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.interfaces;
19 |
20 | import com.androidnetworking.error.ANError;
21 |
22 | import org.json.JSONArray;
23 |
24 | /**
25 | * Created by amitshekhar on 23/05/16.
26 | */
27 | public interface JSONArrayRequestListener {
28 |
29 | void onResponse(JSONArray response);
30 |
31 | void onError(ANError anError);
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/android-networking/src/test/java/com/androidnetworking/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking;
19 |
20 | import org.junit.Test;
21 |
22 | import static org.junit.Assert.*;
23 |
24 | /**
25 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
26 | */
27 | public class ExampleUnitTest {
28 | @Test
29 | public void addition_isCorrect() throws Exception {
30 | assertEquals(4, 2 + 2);
31 | }
32 | }
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/interfaces/JSONObjectRequestListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.interfaces;
19 |
20 | import com.androidnetworking.error.ANError;
21 |
22 | import org.json.JSONObject;
23 |
24 | /**
25 | * Created by amitshekhar on 23/05/16.
26 | */
27 | public interface JSONObjectRequestListener {
28 |
29 | void onResponse(JSONObject response);
30 |
31 | void onError(ANError anError);
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/interfaces/ParsedRequestListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.androidnetworking.interfaces;
21 |
22 | import com.androidnetworking.error.ANError;
23 |
24 | /**
25 | * Created by amitshekhar on 31/07/16.
26 | */
27 | public interface ParsedRequestListener {
28 |
29 | void onResponse(T response);
30 |
31 | void onError(ANError anError);
32 |
33 | }
--------------------------------------------------------------------------------
/rx-android-networking/src/test/java/com/rxandroidnetworking/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.rxandroidnetworking;
19 |
20 | import org.junit.Test;
21 |
22 | import static org.junit.Assert.*;
23 |
24 | /**
25 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
26 | */
27 | public class ExampleUnitTest {
28 | @Test
29 | public void addition_isCorrect() throws Exception {
30 | assertEquals(4, 2 + 2);
31 | }
32 | }
--------------------------------------------------------------------------------
/rx2-android-networking/src/androidTest/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
19 |
20 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/jackson-android-networking/src/androidTest/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
19 |
20 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/rxsampleapp/src/androidTest/java/com/rxsampleapp/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.rxsampleapp;
19 |
20 | import android.app.Application;
21 | import android.test.ApplicationTestCase;
22 |
23 | /**
24 | * Testing Fundamentals
25 | */
26 | public class ApplicationTest extends ApplicationTestCase {
27 | public ApplicationTest() {
28 | super(Application.class);
29 | }
30 | }
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/androidnetworking/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking;
19 |
20 | import android.app.Application;
21 | import android.test.ApplicationTestCase;
22 |
23 | /**
24 | * Testing Fundamentals
25 | */
26 | public class ApplicationTest extends ApplicationTestCase {
27 | public ApplicationTest() {
28 | super(Application.class);
29 | }
30 | }
--------------------------------------------------------------------------------
/rxsampleapp/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
21 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/rx-android-networking/src/androidTest/java/com/rxandroidnetworking/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.rxandroidnetworking;
19 |
20 | import android.app.Application;
21 | import android.test.ApplicationTestCase;
22 |
23 | /**
24 | * Testing Fundamentals
25 | */
26 | public class ApplicationTest extends ApplicationTestCase {
27 | public ApplicationTest() {
28 | super(Application.class);
29 | }
30 | }
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/interfaces/OkHttpResponseListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.androidnetworking.interfaces;
21 |
22 | import com.androidnetworking.error.ANError;
23 |
24 | import okhttp3.Response;
25 |
26 | /**
27 | * Created by amitshekhar on 22/08/16.
28 | */
29 | public interface OkHttpResponseListener {
30 |
31 | void onResponse(Response response);
32 |
33 | void onError(ANError anError);
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/rx2sampleapp/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
19 |
20 |
21 |
24 | 64dp
25 |
26 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/model/Progress.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.model;
19 |
20 | import java.io.Serializable;
21 |
22 | /**
23 | * Created by amitshekhar on 24/05/16.
24 | */
25 |
26 | public class Progress implements Serializable {
27 |
28 | public long currentBytes;
29 | public long totalBytes;
30 |
31 | public Progress(long currentBytes, long totalBytes) {
32 | this.currentBytes = currentBytes;
33 | this.totalBytes = totalBytes;
34 | }
35 |
36 | }
--------------------------------------------------------------------------------
/jackson-android-networking/src/test/java/com/jacksonandroidnetworking/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.jacksonandroidnetworking;
21 |
22 | import org.junit.Test;
23 |
24 | import static org.junit.Assert.*;
25 |
26 | /**
27 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
28 | */
29 | public class ExampleUnitTest {
30 | @Test
31 | public void addition_isCorrect() throws Exception {
32 | assertEquals(4, 2 + 2);
33 | }
34 | }
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/interfaces/OkHttpResponseAndParsedRequestListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.androidnetworking.interfaces;
21 |
22 | import com.androidnetworking.error.ANError;
23 |
24 | import okhttp3.Response;
25 |
26 | /**
27 | * Created by amitshekhar on 31/07/16.
28 | */
29 | public interface OkHttpResponseAndParsedRequestListener {
30 |
31 | void onResponse(Response okHttpResponse, T response);
32 |
33 | void onError(ANError anError);
34 |
35 | }
--------------------------------------------------------------------------------
/rx2sampleapp/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
19 |
20 |
21 |
22 |
23 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/rxsampleapp/src/main/java/com/rxsampleapp/model/User.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.rxsampleapp.model;
21 |
22 | /**
23 | * Created by amitshekhar on 31/07/16.
24 | */
25 | public class User {
26 | public long id;
27 | public String firstname;
28 | public String lastname;
29 | public boolean isFollowing;
30 |
31 | public User(ApiUser apiUser) {
32 | this.id = apiUser.id;
33 | this.firstname = apiUser.firstname;
34 | this.lastname = apiUser.lastname;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/interfaces/OkHttpResponseAndStringRequestListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.androidnetworking.interfaces;
21 |
22 | import com.androidnetworking.error.ANError;
23 |
24 | import okhttp3.Response;
25 |
26 | /**
27 | * Created by amitshekhar on 23/05/16.
28 | */
29 | public interface OkHttpResponseAndStringRequestListener {
30 |
31 | void onResponse(Response okHttpResponse, String response);
32 |
33 | void onError(ANError anError);
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/rx2sampleapp/src/main/java/com/rx2sampleapp/model/User.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.rx2sampleapp.model;
21 |
22 | /**
23 | * Created by amitshekhar on 31/07/16.
24 | */
25 | public class User {
26 | public long id;
27 | public String firstname;
28 | public String lastname;
29 | public boolean isFollowing;
30 |
31 | public User(ApiUser apiUser) {
32 | this.id = apiUser.id;
33 | this.firstname = apiUser.firstname;
34 | this.lastname = apiUser.lastname;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/core/MainThreadExecutor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.core;
19 |
20 | import android.os.Handler;
21 | import android.os.Looper;
22 |
23 | import java.util.concurrent.Executor;
24 |
25 | /**
26 | * Created by amitshekhar on 22/03/16.
27 | */
28 | public class MainThreadExecutor implements Executor {
29 |
30 | private final Handler handler = new Handler(Looper.getMainLooper());
31 |
32 | @Override
33 | public void execute(Runnable runnable) {
34 | handler.post(runnable);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_web_socket.xml:
--------------------------------------------------------------------------------
1 |
19 |
20 |
23 |
24 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/rx2sampleapp/src/test/java/com/rx2sampleapp/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.rx2sampleapp;
21 |
22 | import org.junit.Test;
23 |
24 | import static org.junit.Assert.*;
25 |
26 | /**
27 | * Example local unit test, which will execute on the development machine (host).
28 | *
29 | * @see Testing documentation
30 | */
31 | public class ExampleUnitTest {
32 | @Test
33 | public void addition_isCorrect() throws Exception {
34 | assertEquals(4, 2 + 2);
35 | }
36 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/photogrid_list_selector.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 | -
21 |
22 |
23 |
24 |
25 |
26 | -
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/interfaces/OkHttpResponseAndBitmapRequestListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.androidnetworking.interfaces;
21 |
22 | import android.graphics.Bitmap;
23 |
24 | import com.androidnetworking.error.ANError;
25 |
26 | import okhttp3.Response;
27 |
28 | /**
29 | * Created by amitshekhar on 23/05/16.
30 | */
31 | public interface OkHttpResponseAndBitmapRequestListener {
32 |
33 | void onResponse(Response okHttpResponse, Bitmap response);
34 |
35 | void onError(ANError anError);
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/interfaces/OkHttpResponseAndJSONArrayRequestListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.androidnetworking.interfaces;
21 |
22 | import com.androidnetworking.error.ANError;
23 |
24 | import org.json.JSONArray;
25 |
26 | import okhttp3.Response;
27 |
28 | /**
29 | * Created by amitshekhar on 23/05/16.
30 | */
31 | public interface OkHttpResponseAndJSONArrayRequestListener {
32 |
33 | void onResponse(Response okHttpResponse, JSONArray response);
34 |
35 | void onError(ANError anError);
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/interfaces/OkHttpResponseAndJSONObjectRequestListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.androidnetworking.interfaces;
21 |
22 | import com.androidnetworking.error.ANError;
23 |
24 | import org.json.JSONObject;
25 |
26 | import okhttp3.Response;
27 |
28 | /**
29 | * Created by amitshekhar on 23/05/16.
30 | */
31 | public interface OkHttpResponseAndJSONObjectRequestListener {
32 |
33 | void onResponse(Response okHttpResponse, JSONObject response);
34 |
35 | void onError(ANError anError);
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/rx2-android-networking/src/test/java/com/rx2androidnetworking/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.rx2androidnetworking;
21 |
22 | import org.junit.Test;
23 |
24 | import static org.junit.Assert.*;
25 |
26 | /**
27 | * Example local unit test, which will execute on the development machine (host).
28 | *
29 | * @see Testing documentation
30 | */
31 | public class ExampleUnitTest {
32 | @Test
33 | public void addition_isCorrect() throws Exception {
34 | assertEquals(4, 2 + 2);
35 | }
36 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/image_grid_fragment.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/networking/ApiEndPoint.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.networking;
19 |
20 | /**
21 | * Created by amitshekhar on 29/03/16.
22 | */
23 | public class ApiEndPoint {
24 |
25 | public static final String BASE_URL = "https://fierce-cove-29863.herokuapp.com";
26 | public static final String GET_JSON_ARRAY = "/getAllUsers/{pageNumber}";
27 | public static final String GET_JSON_OBJECT = "/getAnUserDetail/{userId}";
28 | public static final String CHECK_FOR_HEADER = "/checkForHeader";
29 | public static final String POST_CREATE_AN_USER = "/createAnUser";
30 | public static final String UPLOAD_IMAGE = "/uploadImage";
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/rxsampleapp/src/main/java/com/rxsampleapp/ApiEndPoint.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.rxsampleapp;
19 |
20 | /**
21 | * Created by amitshekhar on 29/03/16.
22 | */
23 | public class ApiEndPoint {
24 |
25 | public static final String BASE_URL = "https://fierce-cove-29863.herokuapp.com";
26 | public static final String GET_JSON_ARRAY = "/getAllUsers/{pageNumber}";
27 | public static final String GET_JSON_OBJECT = "/getAnUserDetail/{userId}";
28 | public static final String CHECK_FOR_HEADER = "/checkForHeader";
29 | public static final String POST_CREATE_AN_USER = "/createAnUser";
30 | public static final String UPLOAD_IMAGE = "/uploadImage";
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/rx2sampleapp/src/main/java/com/rx2sampleapp/ApiEndPoint.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.rx2sampleapp;
19 |
20 | /**
21 | * Created by amitshekhar on 29/03/16.
22 | */
23 | public class ApiEndPoint {
24 |
25 | public static final String BASE_URL = "https://fierce-cove-29863.herokuapp.com";
26 | public static final String GET_JSON_ARRAY = "/getAllUsers/{pageNumber}";
27 | public static final String GET_JSON_OBJECT = "/getAnUserDetail/{userId}";
28 | public static final String CHECK_FOR_HEADER = "/checkForHeader";
29 | public static final String POST_CREATE_AN_USER = "/createAnUser";
30 | public static final String UPLOAD_IMAGE = "/uploadImage";
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
21 |
27 |
28 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/common/ConnectionQuality.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.common;
19 |
20 | /**
21 | * Created by amitshekhar on 29/05/16.
22 | */
23 | public enum ConnectionQuality {
24 | /**
25 | * Bandwidth under 150 kbps.
26 | */
27 | POOR,
28 | /**
29 | * Bandwidth between 150 and 550 kbps.
30 | */
31 | MODERATE,
32 | /**
33 | * Bandwidth between 550 and 2000 kbps.
34 | */
35 | GOOD,
36 | /**
37 | * EXCELLENT - Bandwidth over 2000 kbps.
38 | */
39 | EXCELLENT,
40 | /**
41 | * Placeholder for unknown bandwidth. This is the initial value and will stay at this value
42 | * if a bandwidth cannot be accurately found.
43 | */
44 | UNKNOWN
45 | }
46 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (C) 2016 Amit Shekhar
3 | # Copyright (C) 2011 Android Open Source Project
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | # Project-wide Gradle settings.
19 |
20 | # IDE (e.g. Android Studio) users:
21 | # Gradle settings configured through the IDE *will override*
22 | # any settings specified in this file.
23 |
24 | # For more details on how to configure your build environment visit
25 | # http://www.gradle.org/docs/current/userguide/build_environment.html
26 |
27 | # Specifies the JVM arguments used for the daemon process.
28 | # The setting is particularly useful for tweaking memory settings.
29 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
30 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
31 |
32 | # When configured, Gradle will run in incubating parallel mode.
33 | # This option should only be used with decoupled projects. More details, visit
34 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
35 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/app/src/main/java/com/networking/ImageGridActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.networking;
19 |
20 | import android.os.Bundle;
21 | import android.support.v4.app.FragmentActivity;
22 | import android.support.v4.app.FragmentTransaction;
23 |
24 | import com.networking.fragments.ImageGridFragment;
25 |
26 | /**
27 | * Created by amitshekhar on 23/03/16.
28 | */
29 | public class ImageGridActivity extends FragmentActivity {
30 | private static final String TAG = "ImageGridActivity";
31 |
32 | @Override
33 | protected void onCreate(Bundle savedInstanceState) {
34 | super.onCreate(savedInstanceState);
35 |
36 | if (getSupportFragmentManager().findFragmentByTag(TAG) == null) {
37 | final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
38 | ft.add(android.R.id.content, new ImageGridFragment(), TAG);
39 | ft.commit();
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/utils/SourceCloseUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.androidnetworking.utils;
21 |
22 | import com.androidnetworking.common.ANRequest;
23 | import com.androidnetworking.common.ResponseType;
24 |
25 | import okhttp3.Response;
26 |
27 | /**
28 | * Created by amitshekhar on 15/09/16.
29 | */
30 | public final class SourceCloseUtil {
31 |
32 | private SourceCloseUtil() {
33 | }
34 |
35 | public static void close(Response response, ANRequest request) {
36 | if (request.getResponseAs() != ResponseType.OK_HTTP_RESPONSE &&
37 | response != null && response.body() != null &&
38 | response.body().source() != null) {
39 | try {
40 | response.body().source().close();
41 | } catch (Exception ignore) {
42 |
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/jackson-android-networking/src/main/java/com/jacksonandroidnetworking/JacksonResponseBodyParser.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.jacksonandroidnetworking;
21 |
22 | import com.androidnetworking.interfaces.Parser;
23 | import com.fasterxml.jackson.databind.ObjectReader;
24 |
25 | import java.io.IOException;
26 |
27 | import okhttp3.ResponseBody;
28 |
29 | /**
30 | * Created by amitshekhar on 15/09/16.
31 | */
32 | final class JacksonResponseBodyParser implements Parser {
33 |
34 | private final ObjectReader adapter;
35 |
36 | JacksonResponseBodyParser(ObjectReader adapter) {
37 | this.adapter = adapter;
38 | }
39 |
40 | @Override
41 | public T convert(ResponseBody value) throws IOException {
42 | try {
43 | return adapter.readValue(value.charStream());
44 | } finally {
45 | value.close();
46 | }
47 | }
48 |
49 | }
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/utils/ParseUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.androidnetworking.utils;
21 |
22 | import com.androidnetworking.gsonparserfactory.GsonParserFactory;
23 | import com.androidnetworking.interfaces.Parser;
24 | import com.google.gson.Gson;
25 |
26 | /**
27 | * Created by amitshekhar on 15/09/16.
28 | */
29 | public class ParseUtil {
30 |
31 | private static Parser.Factory mParserFactory;
32 |
33 | public static void setParserFactory(Parser.Factory parserFactory) {
34 | mParserFactory = parserFactory;
35 | }
36 |
37 | public static Parser.Factory getParserFactory() {
38 | if (mParserFactory == null) {
39 | mParserFactory = new GsonParserFactory(new Gson());
40 | }
41 | return mParserFactory;
42 | }
43 |
44 | public static void shutDown() {
45 | mParserFactory = null;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | apply plugin: 'com.android.application'
19 |
20 | android {
21 | compileSdkVersion rootProject.ext.compileSdkVersion
22 | buildToolsVersion rootProject.ext.buildToolsVersion
23 |
24 | defaultConfig {
25 | applicationId "com.networking"
26 | minSdkVersion rootProject.ext.minSdkVersion
27 | targetSdkVersion rootProject.ext.targetSdkVersion
28 | versionCode 1
29 | versionName "1.0"
30 | }
31 | buildTypes {
32 | release {
33 | minifyEnabled false
34 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
35 | }
36 | }
37 | }
38 |
39 | dependencies {
40 | compile fileTree(dir: 'libs', include: ['*.jar'])
41 | testCompile "junit:junit:$rootProject.ext.jUnitVersion"
42 | compile "com.android.support:appcompat-v7:$rootProject.ext.supportAppCompatVersion"
43 | compile project(':android-networking')
44 | }
45 |
--------------------------------------------------------------------------------
/rxsampleapp/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | apply plugin: 'com.android.application'
19 |
20 | android {
21 | compileSdkVersion rootProject.ext.compileSdkVersion
22 | buildToolsVersion rootProject.ext.buildToolsVersion
23 |
24 | defaultConfig {
25 | applicationId "com.rxsampleapp"
26 | minSdkVersion rootProject.ext.minSdkVersion
27 | targetSdkVersion rootProject.ext.targetSdkVersion
28 | versionCode 1
29 | versionName "1.0"
30 | }
31 | buildTypes {
32 | release {
33 | minifyEnabled false
34 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
35 | }
36 | }
37 | }
38 |
39 | dependencies {
40 | compile fileTree(dir: 'libs', include: ['*.jar'])
41 | testCompile "junit:junit:$rootProject.ext.jUnitVersion"
42 | compile "com.android.support:appcompat-v7:$rootProject.ext.supportAppCompatVersion"
43 | compile project(':rx-android-networking')
44 | }
45 |
--------------------------------------------------------------------------------
/rx2sampleapp/src/androidTest/java/com/rx2sampleapp/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.rx2sampleapp;
21 |
22 | import android.content.Context;
23 | import android.support.test.InstrumentationRegistry;
24 | import android.support.test.runner.AndroidJUnit4;
25 |
26 | import org.junit.Test;
27 | import org.junit.runner.RunWith;
28 |
29 | import static org.junit.Assert.*;
30 |
31 | /**
32 | * Instrumentation test, which will execute on an Android device.
33 | *
34 | * @see Testing documentation
35 | */
36 | @RunWith(AndroidJUnit4.class)
37 | public class ExampleInstrumentedTest {
38 | @Test
39 | public void useAppContext() throws Exception {
40 | // Context of the app under test.
41 | Context appContext = InstrumentationRegistry.getTargetContext();
42 |
43 | assertEquals("com.rx2sampleapp", appContext.getPackageName());
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/common/Priority.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.common;
19 |
20 | /**
21 | * Created by amitshekhar on 22/03/16.
22 | */
23 |
24 |
25 | /**
26 | * Priority levels recognized by the request server.
27 | */
28 | public enum Priority {
29 | /**
30 | * NOTE: DO NOT CHANGE ORDERING OF THOSE CONSTANTS UNDER ANY CIRCUMSTANCES.
31 | * Doing so will make ordering incorrect.
32 | */
33 |
34 | /**
35 | * Lowest priority level. Used for prefetches of data.
36 | */
37 | LOW,
38 |
39 | /**
40 | * Medium priority level. Used for warming of data that might soon get visible.
41 | */
42 | MEDIUM,
43 |
44 | /**
45 | * Highest priority level. Used for data that are currently visible on screen.
46 | */
47 | HIGH,
48 |
49 | /**
50 | * Highest priority level. Used for data that are required instantly(mainly for emergency).
51 | */
52 | IMMEDIATE
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/core/Core.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.core;
19 |
20 | /**
21 | * Created by amitshekhar on 22/03/16.
22 | */
23 | public class Core {
24 |
25 | private static Core sInstance = null;
26 | private final ExecutorSupplier mExecutorSupplier;
27 |
28 | private Core() {
29 | this.mExecutorSupplier = new DefaultExecutorSupplier();
30 | }
31 |
32 | public static Core getInstance() {
33 | if (sInstance == null) {
34 | synchronized (Core.class) {
35 | if (sInstance == null) {
36 | sInstance = new Core();
37 | }
38 | }
39 | }
40 | return sInstance;
41 | }
42 |
43 | public ExecutorSupplier getExecutorSupplier() {
44 | return mExecutorSupplier;
45 | }
46 |
47 | public static void shutDown() {
48 | if (sInstance != null) {
49 | sInstance = null;
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/rx-android-networking/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | apply plugin: 'com.android.library'
19 |
20 | android {
21 | compileSdkVersion rootProject.ext.compileSdkVersion
22 | buildToolsVersion rootProject.ext.buildToolsVersion
23 |
24 | defaultConfig {
25 | minSdkVersion rootProject.ext.minSdkVersion
26 | targetSdkVersion rootProject.ext.targetSdkVersion
27 | versionCode 1
28 | versionName "1.0"
29 | }
30 | buildTypes {
31 | release {
32 | minifyEnabled false
33 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
34 | }
35 | }
36 | }
37 |
38 | dependencies {
39 | compile fileTree(dir: 'libs', include: ['*.jar'])
40 | testCompile "junit:junit:$rootProject.ext.jUnitVersion"
41 | compile "io.reactivex:rxandroid:$rootProject.ext.rxJavaAndroidVersion"
42 | compile "io.reactivex:rxjava:$rootProject.ext.rxJavaVersion"
43 | compile project(':android-networking')
44 | }
45 | //apply from: 'rx-upload.gradle'
46 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/common/ANConstants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.common;
19 |
20 | /**
21 | * Created by amitshekhar on 29/03/16.
22 | */
23 | public final class ANConstants {
24 | public static final int MAX_CACHE_SIZE = 10 * 1024 * 1024;
25 | public static final int UPDATE = 0x01;
26 | public static final String CACHE_DIR_NAME = "cache_an";
27 | public static final String CONNECTION_ERROR = "connectionError";
28 | public static final String RESPONSE_FROM_SERVER_ERROR = "responseFromServerError";
29 | public static final String REQUEST_CANCELLED_ERROR = "requestCancelledError";
30 | public static final String PARSE_ERROR = "parseError";
31 | public static final String PREFETCH = "prefetch";
32 | public static final String FAST_ANDROID_NETWORKING = "FastAndroidNetworking";
33 | public static final String USER_AGENT = "User-Agent";
34 | public static final String SUCCESS = "success";
35 | public static final String OPTIONS = "OPTIONS";
36 | }
37 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/core/PriorityThreadFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.core;
19 |
20 | /**
21 | * Created by amitshekhar on 22/03/16.
22 | */
23 |
24 |
25 | import android.os.Process;
26 |
27 | import java.util.concurrent.ThreadFactory;
28 |
29 | public class PriorityThreadFactory implements ThreadFactory {
30 |
31 | private final int mThreadPriority;
32 |
33 | public PriorityThreadFactory(int threadPriority) {
34 | mThreadPriority = threadPriority;
35 | }
36 |
37 | @Override
38 | public Thread newThread(final Runnable runnable) {
39 | Runnable wrapperRunnable = new Runnable() {
40 | @Override
41 | public void run() {
42 | try {
43 | Process.setThreadPriority(mThreadPriority);
44 | } catch (Throwable t) {
45 |
46 | }
47 | runnable.run();
48 | }
49 | };
50 | return new Thread(wrapperRunnable);
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/jackson-android-networking/src/main/java/com/jacksonandroidnetworking/JacksonRequestBodyParser.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.jacksonandroidnetworking;
21 |
22 | import com.androidnetworking.interfaces.Parser;
23 | import com.fasterxml.jackson.databind.ObjectWriter;
24 |
25 | import java.io.IOException;
26 |
27 | import okhttp3.MediaType;
28 | import okhttp3.RequestBody;
29 |
30 | /**
31 | * Created by amitshekhar on 15/09/16.
32 | */
33 | final class JacksonRequestBodyParser implements Parser {
34 |
35 | private static final MediaType MEDIA_TYPE = MediaType.parse("application/json; charset=UTF-8");
36 |
37 | private final ObjectWriter adapter;
38 |
39 | JacksonRequestBodyParser(ObjectWriter adapter) {
40 | this.adapter = adapter;
41 | }
42 |
43 | @Override
44 | public RequestBody convert(T value) throws IOException {
45 | byte[] bytes = adapter.writeValueAsBytes(value);
46 | return RequestBody.create(MEDIA_TYPE, bytes);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/cache/LruBitmapCache.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.cache;
19 |
20 | import android.graphics.Bitmap;
21 |
22 | import com.androidnetworking.internal.ANImageLoader;
23 |
24 | /**
25 | * Created by amitshekhar on 24/03/16.
26 | */
27 | public class LruBitmapCache extends LruCache
28 | implements ANImageLoader.ImageCache {
29 |
30 | public LruBitmapCache(int maxSize) {
31 | super(maxSize);
32 | }
33 |
34 | @Override
35 | protected int sizeOf(String key, Bitmap value) {
36 | return value.getRowBytes() * value.getHeight();
37 | }
38 |
39 | @Override
40 | public Bitmap getBitmap(String key) {
41 | return get(key);
42 | }
43 |
44 | @Override
45 | public void evictBitmap(String key) {
46 | remove(key);
47 | }
48 |
49 | @Override
50 | public void evictAllBitmap() {
51 | evictAll();
52 | }
53 |
54 | @Override
55 | public void putBitmap(String url, Bitmap bitmap) {
56 | put(url, bitmap);
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/rxsampleapp/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
20 |
21 |
22 |
23 |
24 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/gsonparserfactory/GsonResponseBodyParser.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.androidnetworking.gsonparserfactory;
21 |
22 | import com.androidnetworking.interfaces.Parser;
23 | import com.google.gson.Gson;
24 | import com.google.gson.TypeAdapter;
25 | import com.google.gson.stream.JsonReader;
26 |
27 | import java.io.IOException;
28 |
29 | import okhttp3.ResponseBody;
30 |
31 | /**
32 | * Created by amitshekhar on 31/07/16.
33 | */
34 | final class GsonResponseBodyParser implements Parser {
35 | private final Gson gson;
36 | private final TypeAdapter adapter;
37 |
38 | GsonResponseBodyParser(Gson gson, TypeAdapter adapter) {
39 | this.gson = gson;
40 | this.adapter = adapter;
41 | }
42 |
43 | @Override
44 | public T convert(ResponseBody value) throws IOException {
45 | JsonReader jsonReader = gson.newJsonReader(value.charStream());
46 | try {
47 | return adapter.read(jsonReader);
48 | } finally {
49 | value.close();
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/interfaces/Parser.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.androidnetworking.interfaces;
21 |
22 | import java.io.IOException;
23 | import java.lang.reflect.Type;
24 | import java.util.HashMap;
25 |
26 | import okhttp3.RequestBody;
27 | import okhttp3.ResponseBody;
28 |
29 | /**
30 | * Created by amitshekhar on 31/07/16.
31 | */
32 | public interface Parser {
33 |
34 | T convert(F value) throws IOException;
35 |
36 | abstract class Factory {
37 |
38 | public Parser responseBodyParser(Type type) {
39 | return null;
40 | }
41 |
42 | public Parser, RequestBody> requestBodyParser(Type type) {
43 | return null;
44 | }
45 |
46 | public Object getObject(String string, Type type) {
47 | return null;
48 | }
49 |
50 | public String getString(Object object) {
51 | return null;
52 | }
53 |
54 | public HashMap getStringMap(Object object) {
55 | return null;
56 | }
57 |
58 | }
59 |
60 | }
--------------------------------------------------------------------------------
/rx2-android-networking/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | apply plugin: 'com.android.library'
21 |
22 | android {
23 | compileSdkVersion rootProject.ext.compileSdkVersion
24 | buildToolsVersion rootProject.ext.buildToolsVersion
25 |
26 | defaultConfig {
27 | minSdkVersion rootProject.ext.minSdkVersion
28 | targetSdkVersion rootProject.ext.targetSdkVersion
29 | versionCode 1
30 | versionName "1.0"
31 | }
32 | buildTypes {
33 | release {
34 | minifyEnabled false
35 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
36 | }
37 | }
38 | }
39 |
40 | dependencies {
41 | compile fileTree(dir: 'libs', include: ['*.jar'])
42 | testCompile "junit:junit:$rootProject.ext.jUnitVersion"
43 | androidTestCompile "com.squareup.okhttp3:mockwebserver:$rootProject.ext.mockWebServerVersion"
44 | compile "io.reactivex.rxjava2:rxandroid:$rootProject.ext.rxJava2AndroidVersion"
45 | compile "io.reactivex.rxjava2:rxjava:$rootProject.ext.rxJava2Version"
46 | compile project(':android-networking')
47 | }
48 | //apply from: 'rx2-upload.gradle'
49 |
--------------------------------------------------------------------------------
/rx2sampleapp/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
19 |
20 |
22 |
23 |
24 |
25 |
26 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 |
21 |
22 |
23 |
24 |
25 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/android-networking/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | apply plugin: 'com.android.library'
19 |
20 | android {
21 | compileSdkVersion rootProject.ext.compileSdkVersion
22 | buildToolsVersion rootProject.ext.buildToolsVersion
23 |
24 | defaultConfig {
25 | minSdkVersion rootProject.ext.minSdkVersion
26 | targetSdkVersion rootProject.ext.targetSdkVersion
27 | versionCode 1
28 | versionName "1.0"
29 | consumerProguardFiles 'proguard-rules.pro'
30 | }
31 | buildTypes {
32 | release {
33 | minifyEnabled false
34 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
35 | }
36 | }
37 | lintOptions {
38 | abortOnError false
39 | }
40 | }
41 |
42 | dependencies {
43 | compile fileTree(dir: 'libs', include: ['*.jar'])
44 | testCompile "junit:junit:$rootProject.ext.jUnitVersion"
45 | androidTestCompile "com.squareup.okhttp3:mockwebserver:$rootProject.ext.mockWebServerVersion"
46 | compile "com.squareup.okhttp3:okhttp:$rootProject.ext.okHttp3Version"
47 | compile "com.google.code.gson:gson:$rootProject.ext.gsonVersion"
48 | compile "com.android.support:appcompat-v7:$rootProject.ext.supportAppCompatVersion"
49 | }
50 | //apply from: 'upload.gradle'
51 |
--------------------------------------------------------------------------------
/rx2sampleapp/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | apply plugin: 'com.android.application'
21 |
22 | android {
23 | compileSdkVersion rootProject.ext.compileSdkVersion
24 | buildToolsVersion rootProject.ext.buildToolsVersion
25 |
26 | defaultConfig {
27 | applicationId "com.rx2sampleapp"
28 | minSdkVersion rootProject.ext.minSdkVersion
29 | targetSdkVersion rootProject.ext.targetSdkVersion
30 | versionCode 1
31 | versionName "1.0"
32 |
33 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
34 |
35 | }
36 | buildTypes {
37 | release {
38 | minifyEnabled false
39 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
40 | }
41 | }
42 | }
43 |
44 | dependencies {
45 | compile fileTree(dir: 'libs', include: ['*.jar'])
46 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
47 | exclude group: 'com.android.support', module: 'support-annotations'
48 | })
49 | compile "com.android.support:appcompat-v7:$rootProject.ext.supportAppCompatVersion"
50 | testCompile "junit:junit:$rootProject.ext.jUnitVersion"
51 | compile project(':rx2-android-networking')
52 | }
53 |
--------------------------------------------------------------------------------
/rxsampleapp/src/main/java/com/rxsampleapp/RxMyApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package com.rxsampleapp;
18 |
19 | import android.app.Application;
20 | import android.util.Log;
21 |
22 | import com.androidnetworking.AndroidNetworking;
23 | import com.androidnetworking.common.ConnectionQuality;
24 | import com.androidnetworking.interfaces.ConnectionQualityChangeListener;
25 |
26 | public class RxMyApplication extends Application {
27 |
28 | private static final String TAG = RxMyApplication.class.getSimpleName();
29 | private static RxMyApplication appInstance = null;
30 |
31 | public static RxMyApplication getInstance() {
32 | return appInstance;
33 | }
34 |
35 | @Override
36 | public void onCreate() {
37 | super.onCreate();
38 | appInstance = this;
39 | AndroidNetworking.initialize(getApplicationContext());
40 | AndroidNetworking.enableLogging();
41 | AndroidNetworking.setConnectionQualityChangeListener(new ConnectionQualityChangeListener() {
42 | @Override
43 | public void onChange(ConnectionQuality currentConnectionQuality, int currentBandwidth) {
44 | Log.d(TAG, "onChange: currentConnectionQuality : " + currentConnectionQuality + " currentBandwidth : " + currentBandwidth);
45 | }
46 | });
47 | }
48 |
49 | }
--------------------------------------------------------------------------------
/rx2sampleapp/src/main/java/com/rx2sampleapp/Rx2MyApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package com.rx2sampleapp;
18 |
19 | import android.app.Application;
20 | import android.util.Log;
21 |
22 | import com.androidnetworking.AndroidNetworking;
23 | import com.androidnetworking.common.ConnectionQuality;
24 | import com.androidnetworking.interfaces.ConnectionQualityChangeListener;
25 |
26 | public class Rx2MyApplication extends Application {
27 |
28 | private static final String TAG = Rx2MyApplication.class.getSimpleName();
29 | private static Rx2MyApplication appInstance = null;
30 |
31 | public static Rx2MyApplication getInstance() {
32 | return appInstance;
33 | }
34 |
35 | @Override
36 | public void onCreate() {
37 | super.onCreate();
38 | appInstance = this;
39 | AndroidNetworking.initialize(getApplicationContext());
40 | AndroidNetworking.enableLogging();
41 | AndroidNetworking.setConnectionQualityChangeListener(new ConnectionQualityChangeListener() {
42 | @Override
43 | public void onChange(ConnectionQuality currentConnectionQuality, int currentBandwidth) {
44 | Log.d(TAG, "onChange: currentConnectionQuality : " + currentConnectionQuality + " currentBandwidth : " + currentBandwidth);
45 | }
46 | });
47 | }
48 |
49 | }
--------------------------------------------------------------------------------
/rx2sampleapp/src/main/res/layout/activity_subscription.xml:
--------------------------------------------------------------------------------
1 |
19 |
20 |
23 |
24 |
32 |
33 |
37 |
38 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/rxsampleapp/src/main/res/layout/activity_subscription.xml:
--------------------------------------------------------------------------------
1 |
19 |
20 |
23 |
24 |
32 |
33 |
37 |
38 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/internal/UploadProgressHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.internal;
19 |
20 | import android.os.Handler;
21 | import android.os.Looper;
22 | import android.os.Message;
23 |
24 | import com.androidnetworking.common.ANConstants;
25 | import com.androidnetworking.interfaces.UploadProgressListener;
26 | import com.androidnetworking.model.Progress;
27 |
28 | /**
29 | * Created by amitshekhar on 24/05/16.
30 | */
31 | public class UploadProgressHandler extends Handler {
32 |
33 | private final UploadProgressListener mUploadProgressListener;
34 |
35 | public UploadProgressHandler(UploadProgressListener uploadProgressListener) {
36 | super(Looper.getMainLooper());
37 | mUploadProgressListener = uploadProgressListener;
38 | }
39 |
40 | @Override
41 | public void handleMessage(Message msg) {
42 | switch (msg.what) {
43 | case ANConstants.UPDATE:
44 | if (mUploadProgressListener != null) {
45 | final Progress progress = (Progress) msg.obj;
46 | mUploadProgressListener.onProgress(progress.currentBytes, progress.totalBytes);
47 | }
48 | break;
49 | default:
50 | super.handleMessage(msg);
51 | break;
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/internal/DownloadProgressHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.internal;
19 |
20 | import android.os.Handler;
21 | import android.os.Looper;
22 | import android.os.Message;
23 |
24 | import com.androidnetworking.common.ANConstants;
25 | import com.androidnetworking.interfaces.DownloadProgressListener;
26 | import com.androidnetworking.model.Progress;
27 |
28 | /**
29 | * Created by amitshekhar on 24/05/16.
30 | */
31 | public class DownloadProgressHandler extends Handler {
32 |
33 | private final DownloadProgressListener mDownloadProgressListener;
34 |
35 | public DownloadProgressHandler(DownloadProgressListener downloadProgressListener) {
36 | super(Looper.getMainLooper());
37 | mDownloadProgressListener = downloadProgressListener;
38 | }
39 |
40 | @Override
41 | public void handleMessage(Message msg) {
42 | switch (msg.what) {
43 | case ANConstants.UPDATE:
44 | if (mDownloadProgressListener != null) {
45 | final Progress progress = (Progress) msg.obj;
46 | mDownloadProgressListener.onProgress(progress.currentBytes, progress.totalBytes);
47 | }
48 | break;
49 | default:
50 | super.handleMessage(msg);
51 | break;
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/common/ANResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.common;
19 |
20 | import com.androidnetworking.error.ANError;
21 |
22 | import okhttp3.Response;
23 |
24 | /**
25 | * Created by amitshekhar on 22/03/16.
26 | */
27 | public class ANResponse {
28 |
29 | private final T mResult;
30 |
31 | private final ANError mANError;
32 |
33 | private Response response;
34 |
35 | public static ANResponse success(T result) {
36 | return new ANResponse<>(result);
37 | }
38 |
39 | public static ANResponse failed(ANError anError) {
40 | return new ANResponse<>(anError);
41 | }
42 |
43 | public ANResponse(T result) {
44 | this.mResult = result;
45 | this.mANError = null;
46 | }
47 |
48 | public ANResponse(ANError anError) {
49 | this.mResult = null;
50 | this.mANError = anError;
51 | }
52 |
53 | public T getResult() {
54 | return mResult;
55 | }
56 |
57 | public boolean isSuccess() {
58 | return mANError == null;
59 | }
60 |
61 | public ANError getError() {
62 | return mANError;
63 | }
64 |
65 | public void setOkHttpResponse(Response response) {
66 | this.response = response;
67 | }
68 |
69 | public Response getOkHttpResponse() {
70 | return response;
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/core/DefaultExecutorSupplier.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.core;
19 |
20 | import android.os.Process;
21 |
22 | import java.util.concurrent.Executor;
23 | import java.util.concurrent.ThreadFactory;
24 |
25 | /**
26 | * Created by amitshekhar on 22/03/16.
27 | */
28 | public class DefaultExecutorSupplier implements ExecutorSupplier {
29 |
30 | public static final int DEFAULT_MAX_NUM_THREADS = 2 * Runtime.getRuntime().availableProcessors() + 1;
31 | private final ANExecutor mNetworkExecutor;
32 | private final ANExecutor mImmediateNetworkExecutor;
33 | private final Executor mMainThreadExecutor;
34 |
35 | public DefaultExecutorSupplier() {
36 | ThreadFactory backgroundPriorityThreadFactory = new PriorityThreadFactory(Process.THREAD_PRIORITY_BACKGROUND);
37 | mNetworkExecutor = new ANExecutor(DEFAULT_MAX_NUM_THREADS, backgroundPriorityThreadFactory);
38 | mImmediateNetworkExecutor = new ANExecutor(2, backgroundPriorityThreadFactory);
39 | mMainThreadExecutor = new MainThreadExecutor();
40 | }
41 |
42 | @Override
43 | public ANExecutor forNetworkTasks() {
44 | return mNetworkExecutor;
45 | }
46 |
47 | @Override
48 | public ANExecutor forImmediateNetworkTasks() {
49 | return mImmediateNetworkExecutor;
50 | }
51 |
52 | @Override
53 | public Executor forMainThreadTasks() {
54 | return mMainThreadExecutor;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/app/src/main/java/com/networking/MyApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.networking;
19 |
20 | import android.app.Application;
21 | import android.graphics.BitmapFactory;
22 | import android.util.Log;
23 |
24 | import com.androidnetworking.AndroidNetworking;
25 | import com.androidnetworking.common.ConnectionQuality;
26 | import com.androidnetworking.interfaces.ConnectionQualityChangeListener;
27 |
28 | /**
29 | * Created by amitshekhar on 22/03/16.
30 | */
31 | public class MyApplication extends Application {
32 |
33 | private static final String TAG = MyApplication.class.getSimpleName();
34 | private static MyApplication appInstance = null;
35 |
36 | public static MyApplication getInstance() {
37 | return appInstance;
38 | }
39 |
40 | @Override
41 | public void onCreate() {
42 | super.onCreate();
43 | appInstance = this;
44 | AndroidNetworking.initialize(getApplicationContext());
45 | BitmapFactory.Options options = new BitmapFactory.Options();
46 | options.inPurgeable = true;
47 | AndroidNetworking.setBitmapDecodeOptions(options);
48 | AndroidNetworking.enableLogging();
49 | AndroidNetworking.setConnectionQualityChangeListener(new ConnectionQualityChangeListener() {
50 | @Override
51 | public void onChange(ConnectionQuality currentConnectionQuality, int currentBandwidth) {
52 | Log.d(TAG, "onChange: currentConnectionQuality : " + currentConnectionQuality + " currentBandwidth : " + currentBandwidth);
53 | }
54 | });
55 |
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/jackson-android-networking/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | apply plugin: 'com.android.library'
21 |
22 | android {
23 | compileSdkVersion rootProject.ext.compileSdkVersion
24 | buildToolsVersion rootProject.ext.buildToolsVersion
25 |
26 | defaultConfig {
27 | minSdkVersion rootProject.ext.minSdkVersion
28 | targetSdkVersion rootProject.ext.targetSdkVersion
29 | versionCode 1
30 | versionName "1.0"
31 | }
32 | buildTypes {
33 | release {
34 | minifyEnabled false
35 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
36 | }
37 | }
38 | packagingOptions {
39 | exclude 'META-INF/DEPENDENCIES.txt'
40 | exclude 'META-INF/LICENSE.txt'
41 | exclude 'META-INF/NOTICE.txt'
42 | exclude 'META-INF/NOTICE'
43 | exclude 'META-INF/LICENSE'
44 | exclude 'META-INF/DEPENDENCIES'
45 | exclude 'META-INF/notice.txt'
46 | exclude 'META-INF/license.txt'
47 | exclude 'META-INF/dependencies.txt'
48 | exclude 'META-INF/LGPL2.1'
49 | }
50 | }
51 |
52 | dependencies {
53 | compile fileTree(dir: 'libs', include: ['*.jar'])
54 | testCompile "junit:junit:$rootProject.ext.jUnitVersion"
55 | androidTestCompile "com.squareup.okhttp3:mockwebserver:$rootProject.ext.mockWebServerVersion"
56 | compile "com.fasterxml.jackson.core:jackson-databind:$rootProject.ext.jacksonVersion"
57 | compile project(':android-networking')
58 | }
59 |
60 | //apply from: 'jackson-upload.gradle'
61 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/gsonparserfactory/GsonRequestBodyParser.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.androidnetworking.gsonparserfactory;
21 |
22 | import com.androidnetworking.interfaces.Parser;
23 | import com.google.gson.Gson;
24 | import com.google.gson.TypeAdapter;
25 | import com.google.gson.stream.JsonWriter;
26 |
27 | import java.io.IOException;
28 | import java.io.OutputStreamWriter;
29 | import java.io.Writer;
30 | import java.nio.charset.Charset;
31 |
32 | import okhttp3.MediaType;
33 | import okhttp3.RequestBody;
34 | import okio.Buffer;
35 |
36 | /**
37 | * Created by amitshekhar on 31/07/16.
38 | */
39 | final class GsonRequestBodyParser implements Parser {
40 | private static final MediaType MEDIA_TYPE = MediaType.parse("application/json; charset=UTF-8");
41 | private static final Charset UTF_8 = Charset.forName("UTF-8");
42 |
43 | private final Gson gson;
44 | private final TypeAdapter adapter;
45 |
46 | GsonRequestBodyParser(Gson gson, TypeAdapter adapter) {
47 | this.gson = gson;
48 | this.adapter = adapter;
49 | }
50 |
51 | @Override
52 | public RequestBody convert(T value) throws IOException {
53 | Buffer buffer = new Buffer();
54 | Writer writer = new OutputStreamWriter(buffer.outputStream(), UTF_8);
55 | JsonWriter jsonWriter = gson.newJsonWriter(writer);
56 | adapter.write(jsonWriter, value);
57 | jsonWriter.close();
58 | return RequestBody.create(MEDIA_TYPE, buffer.readByteString());
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/common/RequestBuilder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.common;
19 |
20 | import java.util.Map;
21 | import java.util.concurrent.Executor;
22 | import java.util.concurrent.TimeUnit;
23 |
24 | import okhttp3.OkHttpClient;
25 |
26 | /**
27 | * Created by amitshekhar on 26/03/16.
28 | */
29 | public interface RequestBuilder {
30 |
31 | RequestBuilder setPriority(Priority priority);
32 |
33 | RequestBuilder setTag(Object tag);
34 |
35 | RequestBuilder addHeaders(String key, String value);
36 |
37 | RequestBuilder addHeaders(Map headerMap);
38 |
39 | RequestBuilder addHeaders(Object object);
40 |
41 | RequestBuilder addQueryParameter(String key, String value);
42 |
43 | RequestBuilder addQueryParameter(Map queryParameterMap);
44 |
45 | RequestBuilder addQueryParameter(Object object);
46 |
47 | RequestBuilder addPathParameter(String key, String value);
48 |
49 | RequestBuilder addPathParameter(Map pathParameterMap);
50 |
51 | RequestBuilder addPathParameter(Object object);
52 |
53 | RequestBuilder doNotCacheResponse();
54 |
55 | RequestBuilder getResponseOnlyIfCached();
56 |
57 | RequestBuilder getResponseOnlyFromNetwork();
58 |
59 | RequestBuilder setMaxAgeCacheControl(int maxAge, TimeUnit timeUnit);
60 |
61 | RequestBuilder setMaxStaleCacheControl(int maxStale, TimeUnit timeUnit);
62 |
63 | RequestBuilder setExecutor(Executor executor);
64 |
65 | RequestBuilder setOkHttpClient(OkHttpClient okHttpClient);
66 |
67 | RequestBuilder setUserAgent(String userAgent);
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/app/src/main/java/com/networking/utils/Utils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.networking.utils;
19 |
20 | import android.content.Context;
21 | import android.os.Environment;
22 | import android.support.v4.content.ContextCompat;
23 | import android.util.Log;
24 |
25 | import com.androidnetworking.error.ANError;
26 |
27 | import java.io.File;
28 |
29 | /**
30 | * Created by amitshekhar on 04/04/16.
31 | */
32 | public class Utils {
33 |
34 | public static String getRootDirPath(Context context) {
35 | if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
36 | File file = ContextCompat.getExternalFilesDirs(context.getApplicationContext(), null)[0];
37 | return file.getAbsolutePath();
38 | } else {
39 | return context.getApplicationContext().getFilesDir().getAbsolutePath();
40 | }
41 | }
42 |
43 | public static void logError(String TAG,ANError error) {
44 | if (error.getErrorCode() != 0) {
45 | // received ANError from server
46 | // error.getErrorCode() - the ANError code from server
47 | // error.getErrorBody() - the ANError body from server
48 | // error.getErrorDetail() - just a ANError detail
49 | Log.d(TAG, "onError errorCode : " + error.getErrorCode());
50 | Log.d(TAG, "onError errorBody : " + error.getErrorBody());
51 | Log.d(TAG, "onError errorDetail : " + error.getErrorDetail());
52 | } else {
53 | // error.getErrorDetail() : connectionError, parseError, requestCancelledError
54 | Log.d(TAG, "onError errorDetail : " + error.getErrorDetail());
55 | }
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/rxsampleapp/src/main/java/com/rxsampleapp/utils/Utils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package com.rxsampleapp.utils;
18 |
19 | import android.content.Context;
20 | import android.os.Environment;
21 | import android.support.v4.content.ContextCompat;
22 | import android.util.Log;
23 |
24 | import com.androidnetworking.error.ANError;
25 |
26 | import java.io.File;
27 |
28 | /**
29 | * Created by Prashant Gupta on 29-07-2016.
30 | */
31 | public class Utils {
32 |
33 | public static String getRootDirPath(Context context) {
34 | if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
35 | File file = ContextCompat.getExternalFilesDirs(context.getApplicationContext(), null)[0];
36 | return file.getAbsolutePath();
37 | } else {
38 | return context.getApplicationContext().getFilesDir().getAbsolutePath();
39 | }
40 | }
41 |
42 | public static void logError(String TAG, Throwable e) {
43 | if (e instanceof ANError) {
44 | ANError anError = (ANError) e;
45 | if (anError.getErrorCode() != 0) {
46 | // received ANError from server
47 | // error.getErrorCode() - the ANError code from server
48 | // error.getErrorBody() - the ANError body from server
49 | // error.getErrorDetail() - just a ANError detail
50 | Log.d(TAG, "onError errorCode : " + anError.getErrorCode());
51 | Log.d(TAG, "onError errorBody : " + anError.getErrorBody());
52 | Log.d(TAG, "onError errorDetail : " + anError.getErrorDetail());
53 | } else {
54 | // error.getErrorDetail() : connectionError, parseError, requestCancelledError
55 | Log.d(TAG, "onError errorDetail : " + anError.getErrorDetail());
56 | }
57 | } else {
58 | Log.d(TAG, "onError errorMessage : " + e.getMessage());
59 | }
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/rx2sampleapp/src/main/java/com/rx2sampleapp/utils/Utils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package com.rx2sampleapp.utils;
18 |
19 | import android.content.Context;
20 | import android.os.Environment;
21 | import android.support.v4.content.ContextCompat;
22 | import android.util.Log;
23 |
24 | import com.androidnetworking.error.ANError;
25 |
26 | import java.io.File;
27 |
28 | /**
29 | * Created by Prashant Gupta on 29-07-2016.
30 | */
31 | public class Utils {
32 |
33 | public static String getRootDirPath(Context context) {
34 | if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
35 | File file = ContextCompat.getExternalFilesDirs(context.getApplicationContext(), null)[0];
36 | return file.getAbsolutePath();
37 | } else {
38 | return context.getApplicationContext().getFilesDir().getAbsolutePath();
39 | }
40 | }
41 |
42 | public static void logError(String TAG, Throwable e) {
43 | if (e instanceof ANError) {
44 | ANError anError = (ANError) e;
45 | if (anError.getErrorCode() != 0) {
46 | // received ANError from server
47 | // error.getErrorCode() - the ANError code from server
48 | // error.getErrorBody() - the ANError body from server
49 | // error.getErrorDetail() - just a ANError detail
50 | Log.d(TAG, "onError errorCode : " + anError.getErrorCode());
51 | Log.d(TAG, "onError errorBody : " + anError.getErrorBody());
52 | Log.d(TAG, "onError errorDetail : " + anError.getErrorDetail());
53 | } else {
54 | // error.getErrorDetail() : connectionError, parseError, requestCancelledError
55 | Log.d(TAG, "onError errorDetail : " + anError.getErrorDetail());
56 | }
57 | } else {
58 | Log.d(TAG, "onError errorMessage : " + e.getMessage());
59 | }
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/gsonparserfactory/GsonParserFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.androidnetworking.gsonparserfactory;
21 |
22 | import com.androidnetworking.interfaces.Parser;
23 | import com.google.gson.Gson;
24 | import com.google.gson.TypeAdapter;
25 | import com.google.gson.reflect.TypeToken;
26 |
27 | import java.lang.reflect.Type;
28 | import java.util.HashMap;
29 |
30 | import okhttp3.RequestBody;
31 | import okhttp3.ResponseBody;
32 |
33 | /**
34 | * Created by amitshekhar on 31/07/16.
35 | */
36 | public final class GsonParserFactory extends Parser.Factory {
37 |
38 | private final Gson gson;
39 |
40 | public GsonParserFactory() {
41 | this.gson = new Gson();
42 | }
43 |
44 | public GsonParserFactory(Gson gson) {
45 | this.gson = gson;
46 | }
47 |
48 | @Override
49 | public Parser responseBodyParser(Type type) {
50 | TypeAdapter> adapter = gson.getAdapter(TypeToken.get(type));
51 | return new GsonResponseBodyParser<>(gson, adapter);
52 | }
53 |
54 | @Override
55 | public Parser, RequestBody> requestBodyParser(Type type) {
56 | TypeAdapter> adapter = gson.getAdapter(TypeToken.get(type));
57 | return new GsonRequestBodyParser<>(gson, adapter);
58 | }
59 |
60 | @Override
61 | public Object getObject(String string, Type type) {
62 | try {
63 | return gson.fromJson(string, type);
64 | } catch (Exception e) {
65 | e.printStackTrace();
66 | }
67 | return null;
68 | }
69 |
70 | @Override
71 | public String getString(Object object) {
72 | try {
73 | return gson.toJson(object);
74 | } catch (Exception e) {
75 | e.printStackTrace();
76 | }
77 | return "";
78 | }
79 |
80 | @Override
81 | public HashMap getStringMap(Object object) {
82 | try {
83 | Type type = new TypeToken>() {
84 | }.getType();
85 | return gson.fromJson(gson.toJson(object), type);
86 | } catch (Exception e) {
87 | e.printStackTrace();
88 | }
89 | return new HashMap<>();
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | Change Log
2 | ==========
3 |
4 | Version 1.0.2 *(2018-07-10)*
5 | ----------------------------
6 |
7 | * New: Add support for multiple file upload with same key
8 | * New: Add support for multi contentType in multipart
9 | * Bump OkHttp Version to 3.10.0
10 | * Bump other dependencies
11 |
12 |
13 | Version 1.0.1 *(2017-12-20)*
14 | ----------------------------
15 |
16 | * New: Add support for `Single`, `Completable`, `Flowable`, `Maybe` Observable
17 | * New: Add support for OPTIONS request
18 | * Bump OkHttp Version to 3.9.1
19 | * Bump other dependencies
20 | * New: Add support for specifying request method dynamically
21 | * New: Add API to check isRequestRunning
22 | * Fix: Add more than one values for one key in header and query
23 | * Merge pull requests
24 |
25 |
26 | Version 1.0.0 *(2017-03-19)*
27 | ----------------------------
28 |
29 | * Fix: Progress bug for large files download
30 | * Merge pull requests
31 | * New: Add new API
32 | * Bump OkHttp Version to 3.6.0
33 | * New: Add config options for BitmapDecode
34 | * New: Add Consumer Proguard
35 |
36 |
37 | Version 0.4.0 *(2017-02-01)*
38 | ----------------------------
39 |
40 | * New: RxJava2 Support [link](https://amitshekhariitbhu.github.io/Fast-Android-Networking/rxjava2_support.html)
41 | * New: Add Java Object directly in any request [link](https://amitshekhariitbhu.github.io/Fast-Android-Networking/post_request.html)
42 | * New: Java Object is supported for query parameter, headers also
43 | * Update OkHttp to 3.5.0
44 | * Fix: Allow all Map implementations
45 | * New: Add better logging of request
46 | * New: Get parsed error body [link](https://amitshekhariitbhu.github.io/Fast-Android-Networking/error_code_handling.html)
47 | * Merged pull requests
48 |
49 |
50 | Version 0.3.0 *(2016-11-07)*
51 | ----------------------------
52 |
53 | * Fix: Few minor bug fixes
54 | * Remove unwanted tags from manifest file
55 |
56 |
57 | Version 0.2.0 *(2016-09-16)*
58 | ----------------------------
59 |
60 | * New: Jackson Parser Support
61 | * New: Making Synchronous Request - [Check Here](https://amitshekhariitbhu.github.io/Fast-Android-Networking/synchronous_request.html)
62 | * New: setContentType("application/json; charset=utf-8") in POST and Multipart request.
63 | * New: Getting OkHttpResponse in Response to access headers - [Check Here](https://amitshekhariitbhu.github.io/Fast-Android-Networking/getting_okhttpresponse.html)
64 | * Bug fixes : As always we are squashing bugs.
65 | * New: Few other features which are request by the fans of Fast Android Networking.
66 |
67 |
68 | Version 0.1.0 *(2016-07-31)*
69 | ----------------------------
70 |
71 | * New: RxJava Support For Fast-Android-Networking
72 | * New: Now RxJava can be used with Fast-Android-Networking
73 | * New: Operators like `flatMap`, `filter`, `map`, `zip`, etc can be used easily with Fast-Android-Networking.
74 | * New: Chaining of Requests can be done.
75 | * New: Requests can be bind with Activity-Lifecycle.
76 | * New: Java Object Parsing Support
77 |
78 |
79 | Version 0.0.1 *(2016-06-03)*
80 | ----------------------------
81 |
82 | Initial release.
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/internal/RequestProgressBody.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.internal;
19 |
20 | import com.androidnetworking.common.ANConstants;
21 | import com.androidnetworking.interfaces.UploadProgressListener;
22 | import com.androidnetworking.model.Progress;
23 |
24 | import java.io.IOException;
25 |
26 | import okhttp3.MediaType;
27 | import okhttp3.RequestBody;
28 | import okio.Buffer;
29 | import okio.BufferedSink;
30 | import okio.ForwardingSink;
31 | import okio.Okio;
32 | import okio.Sink;
33 |
34 | /**
35 | * Created by amitshekhar on 21/04/16.
36 | */
37 | public class RequestProgressBody extends RequestBody {
38 | private final RequestBody requestBody;
39 | private BufferedSink bufferedSink;
40 | private UploadProgressHandler uploadProgressHandler;
41 |
42 | public RequestProgressBody(RequestBody requestBody, UploadProgressListener uploadProgressListener) {
43 | this.requestBody = requestBody;
44 | if (uploadProgressListener != null) {
45 | this.uploadProgressHandler = new UploadProgressHandler(uploadProgressListener);
46 | }
47 | }
48 |
49 | public MediaType contentType() {
50 | return requestBody.contentType();
51 | }
52 |
53 | @Override
54 | public long contentLength() throws IOException {
55 | return requestBody.contentLength();
56 | }
57 |
58 | @Override
59 | public void writeTo(BufferedSink sink) throws IOException {
60 | if (bufferedSink == null) {
61 | bufferedSink = Okio.buffer(sink(sink));
62 | }
63 | requestBody.writeTo(bufferedSink);
64 | bufferedSink.flush();
65 | }
66 |
67 | private Sink sink(Sink sink) {
68 | return new ForwardingSink(sink) {
69 | long bytesWritten = 0L;
70 | long contentLength = 0L;
71 |
72 | @Override
73 | public void write(Buffer source, long byteCount) throws IOException {
74 | super.write(source, byteCount);
75 | if (contentLength == 0) {
76 | contentLength = contentLength();
77 | }
78 | bytesWritten += byteCount;
79 | if (uploadProgressHandler != null) {
80 | uploadProgressHandler.obtainMessage(ANConstants.UPDATE,
81 | new Progress(bytesWritten, contentLength)).sendToTarget();
82 | }
83 | }
84 | };
85 | }
86 | }
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/internal/ResponseProgressBody.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.internal;
19 |
20 | import com.androidnetworking.common.ANConstants;
21 | import com.androidnetworking.interfaces.DownloadProgressListener;
22 | import com.androidnetworking.model.Progress;
23 |
24 | import java.io.IOException;
25 |
26 | import okhttp3.MediaType;
27 | import okhttp3.ResponseBody;
28 | import okio.Buffer;
29 | import okio.BufferedSource;
30 | import okio.ForwardingSource;
31 | import okio.Okio;
32 | import okio.Source;
33 |
34 | /**
35 | * Created by amitshekhar on 24/05/16.
36 | */
37 | public class ResponseProgressBody extends ResponseBody {
38 |
39 | private final ResponseBody mResponseBody;
40 | private BufferedSource bufferedSource;
41 | private DownloadProgressHandler downloadProgressHandler;
42 |
43 | public ResponseProgressBody(ResponseBody responseBody, DownloadProgressListener downloadProgressListener) {
44 | this.mResponseBody = responseBody;
45 | if (downloadProgressListener != null) {
46 | this.downloadProgressHandler = new DownloadProgressHandler(downloadProgressListener);
47 | }
48 | }
49 |
50 | @Override
51 | public MediaType contentType() {
52 | return mResponseBody.contentType();
53 | }
54 |
55 | @Override
56 | public long contentLength() {
57 | return mResponseBody.contentLength();
58 | }
59 |
60 | @Override
61 | public BufferedSource source() {
62 | if (bufferedSource == null) {
63 | bufferedSource = Okio.buffer(source(mResponseBody.source()));
64 | }
65 | return bufferedSource;
66 | }
67 |
68 | private Source source(Source source) {
69 |
70 | return new ForwardingSource(source) {
71 |
72 | long totalBytesRead;
73 |
74 | @Override
75 | public long read(Buffer sink, long byteCount) throws IOException {
76 | long bytesRead = super.read(sink, byteCount);
77 | totalBytesRead += ((bytesRead != -1) ? bytesRead : 0);
78 | if (downloadProgressHandler != null) {
79 | downloadProgressHandler
80 | .obtainMessage(ANConstants.UPDATE,
81 | new Progress(totalBytesRead, mResponseBody.contentLength()))
82 | .sendToTarget();
83 | }
84 | return bytesRead;
85 | }
86 | };
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/rxsampleapp/src/main/java/com/rxsampleapp/SubscriptionActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.rxsampleapp;
19 |
20 | import android.app.Activity;
21 | import android.os.Bundle;
22 | import android.support.v7.app.AppCompatActivity;
23 | import android.util.Log;
24 | import android.view.View;
25 |
26 | import com.rxandroidnetworking.RxAndroidNetworking;
27 | import com.rxsampleapp.utils.Utils;
28 |
29 | import rx.Observable;
30 | import rx.Observer;
31 | import rx.Subscription;
32 | import rx.android.schedulers.AndroidSchedulers;
33 | import rx.schedulers.Schedulers;
34 |
35 | /**
36 | * Created by amitshekhar on 31/07/16.
37 | */
38 | public class SubscriptionActivity extends AppCompatActivity {
39 |
40 | private static final String TAG = SubscriptionActivity.class.getSimpleName();
41 | private static final String URL = "http://i.imgur.com/AtbX9iX.png";
42 | private String dirPath;
43 | private String fileName = "imgurimage.png";
44 | Subscription subscription;
45 |
46 | @Override
47 | protected void onCreate(Bundle savedInstanceState) {
48 | super.onCreate(savedInstanceState);
49 | setContentView(R.layout.activity_subscription);
50 | dirPath = Utils.getRootDirPath(getApplicationContext());
51 | }
52 |
53 |
54 | @Override
55 | protected void onDestroy() {
56 | super.onDestroy();
57 | if (subscription != null) {
58 | subscription.unsubscribe();
59 | }
60 | }
61 |
62 | public Observable getObservable() {
63 | return RxAndroidNetworking.download(URL, dirPath, fileName)
64 | .build()
65 | .getDownloadObservable();
66 | }
67 |
68 | private Observer getObserver() {
69 | return new Observer() {
70 | @Override
71 | public void onCompleted() {
72 | Log.d(TAG, "onCompleted");
73 | }
74 |
75 | @Override
76 | public void onError(Throwable e) {
77 | Log.d(TAG, "onError " + e.getMessage());
78 | }
79 |
80 | @Override
81 | public void onNext(String response) {
82 | Log.d(TAG, "onResponse response : " + response);
83 | }
84 | };
85 | }
86 |
87 | public void downloadFile(View view) {
88 | subscription = getObservable()
89 | .subscribeOn(Schedulers.io())
90 | .observeOn(AndroidSchedulers.mainThread())
91 | .subscribe(getObserver());
92 | }
93 | }
--------------------------------------------------------------------------------
/rx2sampleapp/src/main/java/com/rx2sampleapp/SubscriptionActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * * Copyright (C) 2016 Amit Shekhar
4 | * * Copyright (C) 2011 Android Open Source Project
5 | * *
6 | * * Licensed under the Apache License, Version 2.0 (the "License");
7 | * * you may not use this file except in compliance with the License.
8 | * * You may obtain a copy of the License at
9 | * *
10 | * * http://www.apache.org/licenses/LICENSE-2.0
11 | * *
12 | * * Unless required by applicable law or agreed to in writing, software
13 | * * distributed under the License is distributed on an "AS IS" BASIS,
14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * * See the License for the specific language governing permissions and
16 | * * limitations under the License.
17 | *
18 | */
19 |
20 | package com.rx2sampleapp;
21 |
22 | import android.os.Bundle;
23 | import android.support.v7.app.AppCompatActivity;
24 | import android.util.Log;
25 | import android.view.View;
26 |
27 | import com.rx2androidnetworking.Rx2AndroidNetworking;
28 | import com.rx2sampleapp.utils.Utils;
29 |
30 | import io.reactivex.Completable;
31 | import io.reactivex.android.schedulers.AndroidSchedulers;
32 | import io.reactivex.annotations.NonNull;
33 | import io.reactivex.disposables.CompositeDisposable;
34 | import io.reactivex.observers.DisposableCompletableObserver;
35 | import io.reactivex.schedulers.Schedulers;
36 |
37 |
38 | /**
39 | * Created by amitshekhar on 31/07/16.
40 | */
41 | public class SubscriptionActivity extends AppCompatActivity {
42 |
43 | private static final String TAG = SubscriptionActivity.class.getSimpleName();
44 | private static final String URL = "http://i.imgur.com/AtbX9iX.png";
45 | private String dirPath;
46 | private String fileName = "imgurimage.png";
47 | private final CompositeDisposable disposables = new CompositeDisposable();
48 |
49 | @Override
50 | protected void onCreate(Bundle savedInstanceState) {
51 | super.onCreate(savedInstanceState);
52 | setContentView(R.layout.activity_subscription);
53 | dirPath = Utils.getRootDirPath(getApplicationContext());
54 | }
55 |
56 | @Override
57 | protected void onDestroy() {
58 | super.onDestroy();
59 | disposables.clear();
60 | }
61 |
62 | public Completable getCompletable() {
63 | return Rx2AndroidNetworking.download(URL, dirPath, fileName)
64 | .build()
65 | .getDownloadCompletable();
66 | }
67 |
68 | private DisposableCompletableObserver getDisposableObserver() {
69 |
70 | return new DisposableCompletableObserver() {
71 | @Override
72 | public void onComplete() {
73 | Log.d(TAG, "onCompleted");
74 | }
75 |
76 | @Override
77 | public void onError(@NonNull Throwable throwable) {
78 | Log.d(TAG, "onError " + throwable.getMessage());
79 | }
80 | };
81 |
82 | }
83 |
84 | public void downloadFile(View view) {
85 | disposables.add(getCompletable()
86 | .subscribeOn(Schedulers.io())
87 | .observeOn(AndroidSchedulers.mainThread())
88 | .subscribeWith(getDisposableObserver()));
89 | }
90 | }
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/interceptors/GzipRequestInterceptor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.interceptors;
19 |
20 | import java.io.IOException;
21 |
22 | import okhttp3.Interceptor;
23 | import okhttp3.MediaType;
24 | import okhttp3.Request;
25 | import okhttp3.RequestBody;
26 | import okhttp3.Response;
27 | import okio.Buffer;
28 | import okio.BufferedSink;
29 | import okio.GzipSink;
30 | import okio.Okio;
31 |
32 | /**
33 | * Created by amitshekhar on 02/05/16.
34 | */
35 | public class GzipRequestInterceptor implements Interceptor {
36 | @Override
37 | public Response intercept(Chain chain) throws IOException {
38 | Request originalRequest = chain.request();
39 | if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) {
40 | return chain.proceed(originalRequest);
41 | }
42 |
43 | Request compressedRequest = originalRequest.newBuilder()
44 | .header("Content-Encoding", "gzip")
45 | .method(originalRequest.method(), forceContentLength(gzip(originalRequest.body())))
46 | .build();
47 | return chain.proceed(compressedRequest);
48 | }
49 |
50 | private RequestBody forceContentLength(final RequestBody requestBody) throws IOException {
51 | final Buffer buffer = new Buffer();
52 | requestBody.writeTo(buffer);
53 | return new RequestBody() {
54 | @Override
55 | public MediaType contentType() {
56 | return requestBody.contentType();
57 | }
58 |
59 | @Override
60 | public long contentLength() {
61 | return buffer.size();
62 | }
63 |
64 | @Override
65 | public void writeTo(BufferedSink sink) throws IOException {
66 | sink.write(buffer.snapshot());
67 | }
68 | };
69 | }
70 |
71 |
72 | private RequestBody gzip(final RequestBody body) {
73 | return new RequestBody() {
74 | @Override
75 | public MediaType contentType() {
76 | return body.contentType();
77 | }
78 |
79 | @Override
80 | public long contentLength() {
81 | return -1; // We don't know the compressed length in advance!
82 | }
83 |
84 | @Override
85 | public void writeTo(BufferedSink sink) throws IOException {
86 | BufferedSink gzipSink = Okio.buffer(new GzipSink(sink));
87 | body.writeTo(gzipSink);
88 | gzipSink.close();
89 | }
90 | };
91 | }
92 | }
--------------------------------------------------------------------------------
/android-networking/upload.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | apply plugin: 'com.github.dcendents.android-maven'
19 | apply plugin: "com.jfrog.bintray"
20 |
21 | def siteUrl = 'https://github.com/amitshekhariitbhu/Fast-Android-Networking'
22 | def gitUrl = 'https://github.com/amitshekhariitbhu/Fast-Android-Networking.git'
23 |
24 | group = "com.amitshekhar.android"
25 | version = '1.0.2'
26 |
27 | install {
28 | repositories.mavenInstaller {
29 | pom.project {
30 | packaging 'aar'
31 |
32 | name 'Fast Android Networking'
33 | description 'Fast Android Networking is a powerful library for doing any type of networking in Android applications'
34 |
35 | url siteUrl
36 |
37 | licenses {
38 | license {
39 | name 'The Apache Software License, Version 2.0'
40 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
41 | }
42 | }
43 |
44 | developers {
45 | developer {
46 | id 'amitshekhariitbhu'
47 | name 'Amit Shekhar'
48 | email 'amit.shekhar.iitbhu@gmail.com'
49 | }
50 | }
51 |
52 | scm {
53 | connection gitUrl
54 | developerConnection gitUrl
55 | url siteUrl
56 | }
57 | }
58 | }
59 | }
60 |
61 | task sourcesJar(type: Jar) {
62 | from android.sourceSets.main.java.srcDirs
63 | classifier = 'sources'
64 | }
65 |
66 | task javadoc(type: Javadoc) {
67 | source = android.sourceSets.main.java.srcDirs
68 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
69 | classpath += configurations.compile
70 | }
71 |
72 | task javadocJar(type: Jar, dependsOn: javadoc) {
73 | classifier = 'javadoc'
74 | from javadoc.destinationDir
75 | }
76 | artifacts {
77 | archives javadocJar
78 | archives sourcesJar
79 | }
80 |
81 | if (project.rootProject.file("local.properties").exists()) {
82 | Properties properties = new Properties()
83 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
84 |
85 | bintray {
86 | user = properties.getProperty("bintray.user")
87 | key = properties.getProperty("bintray.apikey")
88 |
89 | configurations = ['archives']
90 | dryRun = false
91 |
92 | pkg {
93 | repo = "maven"
94 | name = "android-networking"
95 | websiteUrl = siteUrl
96 | vcsUrl = gitUrl
97 | licenses = ["Apache-2.0"]
98 | publish = true
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/android-networking/src/main/java/com/androidnetworking/error/ANError.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.androidnetworking.error;
19 |
20 | import com.androidnetworking.common.ANConstants;
21 | import com.androidnetworking.utils.ParseUtil;
22 |
23 | import okhttp3.Response;
24 |
25 | /**
26 | * Created by amitshekhar on 22/03/16.
27 | */
28 | @SuppressWarnings({"unchecked", "unused"})
29 | public class ANError extends Exception {
30 |
31 | private String errorBody;
32 |
33 | private int errorCode = 0;
34 |
35 | private String errorDetail;
36 |
37 | private Response response;
38 |
39 | public ANError() {
40 | }
41 |
42 | public ANError(Response response) {
43 | this.response = response;
44 | }
45 |
46 | public ANError(String message) {
47 | super(message);
48 | }
49 |
50 | public ANError(String message, Response response) {
51 | super(message);
52 | this.response = response;
53 | }
54 |
55 | public ANError(String message, Throwable throwable) {
56 | super(message, throwable);
57 | }
58 |
59 | public ANError(String message, Response response, Throwable throwable) {
60 | super(message, throwable);
61 | this.response = response;
62 | }
63 |
64 | public ANError(Response response, Throwable throwable) {
65 | super(throwable);
66 | this.response = response;
67 | }
68 |
69 | public ANError(Throwable throwable) {
70 | super(throwable);
71 | }
72 |
73 | public Response getResponse() {
74 | return response;
75 | }
76 |
77 | public void setErrorDetail(String errorDetail) {
78 | this.errorDetail = errorDetail;
79 | }
80 |
81 | public String getErrorDetail() {
82 | return this.errorDetail;
83 | }
84 |
85 | public void setErrorCode(int errorCode) {
86 | this.errorCode = errorCode;
87 | }
88 |
89 | public int getErrorCode() {
90 | return this.errorCode;
91 | }
92 |
93 | public void setCancellationMessageInError() {
94 | this.errorDetail = ANConstants.REQUEST_CANCELLED_ERROR;
95 | }
96 |
97 | public String getErrorBody() {
98 | return errorBody;
99 | }
100 |
101 | public void setErrorBody(String errorBody) {
102 | this.errorBody = errorBody;
103 | }
104 |
105 | public T getErrorAsObject(Class objectClass) {
106 | try {
107 | return (T) (ParseUtil
108 | .getParserFactory()
109 | .getObject(errorBody, objectClass));
110 | } catch (Exception e) {
111 | e.printStackTrace();
112 | }
113 | return null;
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/rx-android-networking/rx-upload.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 Amit Shekhar
3 | * Copyright (C) 2011 Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | apply plugin: 'com.github.dcendents.android-maven'
19 | apply plugin: "com.jfrog.bintray"
20 |
21 | def siteUrl = 'https://github.com/amitshekhariitbhu/Fast-Android-Networking'
22 | def gitUrl = 'https://github.com/amitshekhariitbhu/Fast-Android-Networking.git'
23 |
24 | group = "com.amitshekhar.android"
25 | version = '1.0.2'
26 |
27 | install {
28 | repositories.mavenInstaller {
29 | pom.project {
30 | packaging 'aar'
31 |
32 | name 'Fast Android Networking'
33 | description 'Fast Android Networking is a powerful library for doing any type of networking in Android applications'
34 |
35 | url siteUrl
36 |
37 | licenses {
38 | license {
39 | name 'The Apache Software License, Version 2.0'
40 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
41 | }
42 | }
43 |
44 | developers {
45 | developer {
46 | id 'amitshekhariitbhu'
47 | name 'Amit Shekhar'
48 | email 'amit.shekhar.iitbhu@gmail.com'
49 | }
50 | }
51 |
52 | scm {
53 | connection gitUrl
54 | developerConnection gitUrl
55 | url siteUrl
56 | }
57 | }
58 | }
59 | }
60 |
61 | task sourcesJar(type: Jar) {
62 | from android.sourceSets.main.java.srcDirs
63 | classifier = 'sources'
64 | }
65 |
66 | task javadoc(type: Javadoc) {
67 | source = android.sourceSets.main.java.srcDirs
68 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
69 | classpath += configurations.compile
70 | }
71 |
72 | task javadocJar(type: Jar, dependsOn: javadoc) {
73 | classifier = 'javadoc'
74 | from javadoc.destinationDir
75 | }
76 | artifacts {
77 | archives javadocJar
78 | archives sourcesJar
79 | }
80 |
81 | if (project.rootProject.file("local.properties").exists()) {
82 | Properties properties = new Properties()
83 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
84 |
85 | bintray {
86 | user = properties.getProperty("bintray.user")
87 | key = properties.getProperty("bintray.apikey")
88 |
89 | configurations = ['archives']
90 | dryRun = false
91 |
92 | pkg {
93 | repo = "maven"
94 | name = "rx-android-networking"
95 | websiteUrl = siteUrl
96 | vcsUrl = gitUrl
97 | licenses = ["Apache-2.0"]
98 | publish = true
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------