├── RxJavaRetrofit
├── settings.gradle
├── app
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ ├── values
│ │ │ │ │ ├── strings.xml
│ │ │ │ │ ├── colors.xml
│ │ │ │ │ ├── dimens.xml
│ │ │ │ │ └── styles.xml
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ ├── loading_01.png
│ │ │ │ │ ├── loading_02.png
│ │ │ │ │ ├── loading_03.png
│ │ │ │ │ ├── loading_04.png
│ │ │ │ │ ├── loading_05.png
│ │ │ │ │ ├── loading_06.png
│ │ │ │ │ ├── loading_07.png
│ │ │ │ │ ├── loading_08.png
│ │ │ │ │ ├── loading_09.png
│ │ │ │ │ ├── loading_10.png
│ │ │ │ │ ├── loading_11.png
│ │ │ │ │ └── loading_12.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── drawable
│ │ │ │ │ ├── loading_bg_drawable.xml
│ │ │ │ │ └── loading_animal.xml
│ │ │ │ ├── values-w820dp
│ │ │ │ │ └── dimens.xml
│ │ │ │ └── layout
│ │ │ │ │ ├── activity_main.xml
│ │ │ │ │ └── loading_layout.xml
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── ywl5320
│ │ │ │ │ └── rxjavaretrofit
│ │ │ │ │ ├── httpservice
│ │ │ │ │ ├── beans
│ │ │ │ │ │ ├── UserBean.java
│ │ │ │ │ │ └── WeatherBean.java
│ │ │ │ │ ├── subscribers
│ │ │ │ │ │ ├── SubscriberOnListener.java
│ │ │ │ │ │ ├── ResponStatusCode.java
│ │ │ │ │ │ └── HttpSubscriber.java
│ │ │ │ │ ├── service
│ │ │ │ │ │ ├── ExceptionApi.java
│ │ │ │ │ │ ├── BaseApi.java
│ │ │ │ │ │ └── HttpMethod.java
│ │ │ │ │ ├── serviceapi
│ │ │ │ │ │ ├── UserService.java
│ │ │ │ │ │ └── UserApi.java
│ │ │ │ │ └── httpentity
│ │ │ │ │ │ └── HttpResult.java
│ │ │ │ │ ├── MyApplication.java
│ │ │ │ │ ├── dialog
│ │ │ │ │ └── LoadDialog.java
│ │ │ │ │ ├── MainActivity.java
│ │ │ │ │ └── utils
│ │ │ │ │ └── NetUtil.java
│ │ │ └── AndroidManifest.xml
│ │ ├── test
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── ywl5320
│ │ │ │ └── rxjavaretrofit
│ │ │ │ └── ExampleUnitTest.java
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── com
│ │ │ └── ywl5320
│ │ │ └── rxjavaretrofit
│ │ │ └── ApplicationTest.java
│ ├── proguard-rules.pro
│ └── build.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── build.gradle
├── gradle.properties
├── gradlew.bat
└── gradlew
├── RxJava2Retrofit2Okhttp3
└── RxJavaRetrofit
│ ├── settings.gradle
│ ├── app
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ ├── values
│ │ │ │ │ ├── strings.xml
│ │ │ │ │ ├── colors.xml
│ │ │ │ │ ├── dimens.xml
│ │ │ │ │ └── styles.xml
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ ├── loading_01.png
│ │ │ │ │ ├── loading_02.png
│ │ │ │ │ ├── loading_03.png
│ │ │ │ │ ├── loading_04.png
│ │ │ │ │ ├── loading_05.png
│ │ │ │ │ ├── loading_06.png
│ │ │ │ │ ├── loading_07.png
│ │ │ │ │ ├── loading_08.png
│ │ │ │ │ ├── loading_09.png
│ │ │ │ │ ├── loading_10.png
│ │ │ │ │ ├── loading_11.png
│ │ │ │ │ └── loading_12.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── drawable
│ │ │ │ │ ├── loading_bg_drawable.xml
│ │ │ │ │ └── loading_animal.xml
│ │ │ │ ├── values-w820dp
│ │ │ │ │ └── dimens.xml
│ │ │ │ └── layout
│ │ │ │ │ ├── activity_main.xml
│ │ │ │ │ └── loading_layout.xml
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── ywl5320
│ │ │ │ │ └── rxjavaretrofit
│ │ │ │ │ ├── httpservice
│ │ │ │ │ ├── beans
│ │ │ │ │ │ ├── UserBean.java
│ │ │ │ │ │ └── WeatherBean.java
│ │ │ │ │ ├── subscribers
│ │ │ │ │ │ ├── SubscriberOnListener.java
│ │ │ │ │ │ ├── ResponStatusCode.java
│ │ │ │ │ │ └── HttpSubscriber.java
│ │ │ │ │ ├── service
│ │ │ │ │ │ ├── ExceptionApi.java
│ │ │ │ │ │ ├── BaseApi.java
│ │ │ │ │ │ └── HttpMethod.java
│ │ │ │ │ ├── serviceapi
│ │ │ │ │ │ ├── UserService.java
│ │ │ │ │ │ └── UserApi.java
│ │ │ │ │ └── httpentity
│ │ │ │ │ │ └── HttpResult.java
│ │ │ │ │ ├── MyApplication.java
│ │ │ │ │ ├── dialog
│ │ │ │ │ └── LoadDialog.java
│ │ │ │ │ ├── MainActivity.java
│ │ │ │ │ └── utils
│ │ │ │ │ └── NetUtil.java
│ │ │ └── AndroidManifest.xml
│ │ ├── test
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── ywl5320
│ │ │ │ └── rxjavaretrofit
│ │ │ │ └── ExampleUnitTest.java
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── com
│ │ │ └── ywl5320
│ │ │ └── rxjavaretrofit
│ │ │ └── ApplicationTest.java
│ ├── proguard-rules.pro
│ └── build.gradle
│ ├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradlew.bat
│ └── gradlew
├── imgs
└── weather.gif
├── .gitignore
├── README.md
└── LICENSE
/RxJavaRetrofit/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/imgs/weather.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/imgs/weather.gif
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | RxJavaRetrofit
3 |
4 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJavaRetrofit/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | RxJavaRetrofit
3 |
4 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJavaRetrofit/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJavaRetrofit/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_01.png
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_02.png
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_03.png
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_04.png
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_05.png
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_06.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_06.png
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_07.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_07.png
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_08.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_08.png
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_09.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_09.png
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_10.png
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_11.png
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_12.png
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJavaRetrofit/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJavaRetrofit/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_01.png
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_02.png
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_03.png
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_04.png
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_05.png
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_06.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_06.png
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_07.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_07.png
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_08.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_08.png
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_09.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_09.png
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_10.png
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_11.png
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xhdpi/loading_12.png
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ywl5320/RxjavaRetrofit/HEAD/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/httpservice/beans/UserBean.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.httpservice.beans;
2 |
3 | /**
4 | * Created by ywl on 2016/6/24.
5 | */
6 | public class UserBean {
7 | }
8 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/httpservice/beans/UserBean.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.httpservice.beans;
2 |
3 | /**
4 | * Created by ywl on 2016/6/24.
5 | */
6 | public class UserBean {
7 | }
8 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
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-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/httpservice/beans/WeatherBean.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.httpservice.beans;
2 |
3 | /**
4 | * Created by ywl on 2016/6/26.
5 | */
6 | public class WeatherBean {
7 | private int status;
8 | private String message;
9 | }
10 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
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-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/httpservice/beans/WeatherBean.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.httpservice.beans;
2 |
3 | /**
4 | * Created by ywl on 2016/6/26.
5 | */
6 | public class WeatherBean {
7 | private int status;
8 | private String message;
9 | }
10 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/httpservice/subscribers/SubscriberOnListener.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.httpservice.subscribers;
2 |
3 | /**
4 | * Created by ywl on 2016/5/19.
5 | */
6 | public interface SubscriberOnListener {
7 |
8 | void onSucceed(T data);
9 |
10 | void onError(int code, String msg);
11 | }
12 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/httpservice/subscribers/SubscriberOnListener.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.httpservice.subscribers;
2 |
3 | /**
4 | * Created by ywl on 2016/5/19.
5 | */
6 | public interface SubscriberOnListener {
7 |
8 | void onSucceed(T data);
9 |
10 | void onError(int code, String msg);
11 | }
12 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/drawable/loading_bg_drawable.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/drawable/loading_bg_drawable.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/test/java/com/ywl5320/rxjavaretrofit/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/test/java/com/ywl5320/rxjavaretrofit/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/androidTest/java/com/ywl5320/rxjavaretrofit/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/androidTest/java/com/ywl5320/rxjavaretrofit/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/MyApplication.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit;
2 |
3 | import android.app.Application;
4 |
5 | /**
6 | * Created by ywl on 2016/6/24.
7 | */
8 | public class MyApplication extends Application{
9 |
10 | private static MyApplication instance;
11 |
12 | @Override
13 | public void onCreate() {
14 | super.onCreate();
15 | instance = this;
16 | }
17 |
18 | public static MyApplication getInstance() {
19 | return instance;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/MyApplication.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit;
2 |
3 | import android.app.Application;
4 |
5 | /**
6 | * Created by ywl on 2016/6/24.
7 | */
8 | public class MyApplication extends Application{
9 |
10 | private static MyApplication instance;
11 |
12 | @Override
13 | public void onCreate() {
14 | super.onCreate();
15 | instance = this;
16 | }
17 |
18 | public static MyApplication getInstance() {
19 | return instance;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.1.2'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/httpservice/service/ExceptionApi.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.httpservice.service;
2 |
3 |
4 | /**
5 | * Created by ywl on 2016/5/19.
6 | */
7 | public class ExceptionApi extends RuntimeException{
8 |
9 | private int code;
10 | private String msg;
11 |
12 | public ExceptionApi(int resultCode, String msg) {
13 | this.code = resultCode;
14 | this.msg = msg;
15 | }
16 |
17 | public int getCode() {
18 | return code;
19 | }
20 |
21 | public String getMsg() {
22 | return msg;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/httpservice/subscribers/ResponStatusCode.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.httpservice.subscribers;
2 |
3 | /**
4 | * Created by ywl on 2016/6/21.
5 | */
6 | public class ResponStatusCode {
7 |
8 | /**
9 | * 判断code 是否成功
10 | * @param code
11 | * @return
12 | */
13 | public static String getCode(int code, String msg){
14 | if(code == 1){
15 | return "1";
16 | }
17 | else if(code == -1){
18 | return "参数不合法";
19 | }else{
20 | return msg;
21 | }
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.3'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/httpservice/service/ExceptionApi.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.httpservice.service;
2 |
3 |
4 | /**
5 | * Created by ywl on 2016/5/19.
6 | */
7 | public class ExceptionApi extends RuntimeException{
8 |
9 | private int code;
10 | private String msg;
11 |
12 | public ExceptionApi(int resultCode, String msg) {
13 | this.code = resultCode;
14 | this.msg = msg;
15 | }
16 |
17 | public int getCode() {
18 | return code;
19 | }
20 |
21 | public String getMsg() {
22 | return msg;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/workspace.xml
38 |
39 | # Keystore files
40 | *.jks
41 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/httpservice/subscribers/ResponStatusCode.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.httpservice.subscribers;
2 |
3 | /**
4 | * Created by ywl on 2016/6/21.
5 | */
6 | public class ResponStatusCode {
7 |
8 | /**
9 | * 判断code 是否成功
10 | * @param code
11 | * @return
12 | */
13 | public static String getCode(int code, String msg){
14 | if(code == 1){
15 | return "1";
16 | }
17 | else if(code == -1){
18 | return "参数不合法";
19 | }else{
20 | return msg;
21 | }
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/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 D:\Android\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 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/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 D:\Android\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 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/httpservice/serviceapi/UserService.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.httpservice.serviceapi;
2 |
3 |
4 | import com.ywl5320.rxjavaretrofit.httpservice.beans.WeatherBean;
5 | import com.ywl5320.rxjavaretrofit.httpservice.httpentity.HttpResult;
6 |
7 |
8 | import retrofit2.http.POST;
9 | import retrofit2.http.Query;
10 | import rx.Observable;
11 |
12 | /**
13 | * Created by ywl on 2016/5/19.
14 | */
15 | public interface UserService {
16 |
17 | /**
18 | * 获取百度天气数据
19 | * @param location
20 | * @param output
21 | * @param ak
22 | * @return
23 | */
24 | @POST("telematics/v3/weather")
25 | Observable> getWeather(@Query("location") String location, @Query("output") String output, @Query("ak") String ak);
26 | }
27 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
17 |
18 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/httpservice/httpentity/HttpResult.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.httpservice.httpentity;
2 |
3 | /**
4 | * Created by ywl on 2016/5/19.
5 | */
6 | public class HttpResult {
7 |
8 | private int status;
9 | private String message;
10 | private T data;
11 |
12 | public int getStatus() {
13 | return status;
14 | }
15 |
16 | public void setStatus(int status) {
17 | this.status = status;
18 | }
19 |
20 | public String getMessage() {
21 | return message;
22 | }
23 |
24 | public void setMessage(String message) {
25 | this.message = message;
26 | }
27 |
28 | public T getData() {
29 | return data;
30 | }
31 |
32 | public void setData(T data) {
33 | this.data = data;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/httpservice/serviceapi/UserService.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.httpservice.serviceapi;
2 |
3 |
4 | import com.ywl5320.rxjavaretrofit.httpservice.beans.WeatherBean;
5 | import com.ywl5320.rxjavaretrofit.httpservice.httpentity.HttpResult;
6 |
7 |
8 | import io.reactivex.Observable;
9 | import retrofit2.http.POST;
10 | import retrofit2.http.Query;
11 |
12 | /**
13 | * Created by ywl on 2016/5/19.
14 | */
15 | public interface UserService {
16 |
17 | /**
18 | * 获取百度天气数据
19 | * @param location
20 | * @param output
21 | * @param ak
22 | * @return
23 | */
24 | @POST("telematics/v3/weather")
25 | Observable> getWeather(@Query("location") String location, @Query("output") String output, @Query("ak") String ak);
26 | }
27 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
17 |
18 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/httpservice/httpentity/HttpResult.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.httpservice.httpentity;
2 |
3 | /**
4 | * Created by ywl on 2016/5/19.
5 | */
6 | public class HttpResult {
7 |
8 | private int status;
9 | private String message;
10 | private T data;
11 |
12 | public int getStatus() {
13 | return status;
14 | }
15 |
16 | public void setStatus(int status) {
17 | this.status = status;
18 | }
19 |
20 | public String getMessage() {
21 | return message;
22 | }
23 |
24 | public void setMessage(String message) {
25 | this.message = message;
26 | }
27 |
28 | public T getData() {
29 | return data;
30 | }
31 |
32 | public void setData(T data) {
33 | this.data = data;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # RxjavaRetrofit
2 | ### Rxjava + Retrofit网络访问
3 | #### 此Demo是根据 RxJava 与 Retrofit 结合的最佳实践 进行的封装,已在项目中使用。
4 |
5 | 实例图片:
6 | 
7 |
8 | #### 使用方法:
9 |
10 | /**
11 | 这里是访问的百度天气预报接口
12 | 返回数据可以根据自己的需要更改 HttpResult 类里面的参数 (如:int code; T data; String msg)
13 |
14 | */
15 | UserApi.getInstance().getWeather("成都", "json", "5NImrCXDE8hR05Yc49Bgs5QG", new HttpSubscriber(new SubscriberOnListener() {
16 | @Override
17 | public void onSucceed(WeatherBean data) {
18 | hideLoadDialog();//这个可以在回调里面添加到complete里面,关闭对话框只写到这个里面就可以了
19 | }
20 |
21 | @Override
22 | public void onError(String msg) {
23 | Toast.makeText(MainActivity.this, msg, Toast.LENGTH_LONG).show();
24 | hideLoadDialog();
25 | }
26 | }, MainActivity.this));
27 |
28 |
29 | # create by ywl5320
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/dialog/LoadDialog.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.dialog;
2 |
3 | import android.app.Dialog;
4 | import android.content.Context;
5 | import android.os.Bundle;
6 | import android.widget.TextView;
7 |
8 | import com.ywl5320.rxjavaretrofit.R;
9 |
10 | /**
11 | * Created by ywl on 2016/3/9.
12 | */
13 | public class LoadDialog extends Dialog{
14 |
15 | public Context context;
16 | private TextView mtvLoadmsg;
17 |
18 | public LoadDialog(Context context) {
19 | super(context, R.style.ShareDialog);
20 | this.context = context;
21 | }
22 |
23 | @Override
24 | public void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.loading_layout);
27 | mtvLoadmsg = (TextView) findViewById(R.id.tv_load_msg);
28 | }
29 |
30 | public void setLoadMsg(String msg)
31 | {
32 | if(mtvLoadmsg != null)
33 | {
34 | mtvLoadmsg.setText(msg);
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/dialog/LoadDialog.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.dialog;
2 |
3 | import android.app.Dialog;
4 | import android.content.Context;
5 | import android.os.Bundle;
6 | import android.widget.TextView;
7 |
8 | import com.ywl5320.rxjavaretrofit.R;
9 |
10 | /**
11 | * Created by ywl on 2016/3/9.
12 | */
13 | public class LoadDialog extends Dialog{
14 |
15 | public Context context;
16 | private TextView mtvLoadmsg;
17 |
18 | public LoadDialog(Context context) {
19 | super(context, R.style.ShareDialog);
20 | this.context = context;
21 | }
22 |
23 | @Override
24 | public void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.loading_layout);
27 | mtvLoadmsg = (TextView) findViewById(R.id.tv_load_msg);
28 | }
29 |
30 | public void setLoadMsg(String msg)
31 | {
32 | if(mtvLoadmsg != null)
33 | {
34 | mtvLoadmsg.setText(msg);
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.3"
6 |
7 | defaultConfig {
8 | applicationId "com.ywl5320.rxjavaretrofit"
9 | minSdkVersion 14
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.4.0'
26 |
27 | compile 'io.reactivex:rxjava:1.1.0'
28 | compile 'io.reactivex:rxandroid:1.1.0'
29 | compile 'com.squareup.okhttp3:logging-interceptor:3.3.1'
30 | compile 'com.squareup.okhttp3:okhttp:3.1.2'
31 | compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
32 | compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
33 | compile 'com.squareup.retrofit2:adapter-rxjava:2.0.0-beta4'
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.3"
6 |
7 | defaultConfig {
8 | applicationId "com.ywl5320.rxjavaretrofit"
9 | minSdkVersion 14
10 | targetSdkVersion 25
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:25.3.1'
26 |
27 | compile 'io.reactivex.rxjava2:rxjava:2.1.1'
28 | compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
29 | compile 'com.squareup.retrofit2:retrofit:2.3.0'
30 | compile 'com.squareup.retrofit2:converter-gson:2.3.0'
31 | compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
32 | compile 'com.squareup.okhttp3:okhttp:3.8.1'
33 | compile 'com.squareup.okhttp3:logging-interceptor:3.8.1'
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/httpservice/service/BaseApi.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.httpservice.service;
2 |
3 |
4 | import com.ywl5320.rxjavaretrofit.httpservice.httpentity.HttpResult;
5 |
6 | import rx.Observable;
7 | import rx.Subscriber;
8 | import rx.android.schedulers.AndroidSchedulers;
9 | import rx.functions.Func1;
10 | import rx.schedulers.Schedulers;
11 |
12 | /**
13 | * Created by ywl on 2016/5/19.
14 | */
15 | public class BaseApi {
16 |
17 | public void toSubscribe(Observable o, Subscriber s){
18 | o.subscribeOn(Schedulers.io())
19 | .unsubscribeOn(Schedulers.io())
20 | .observeOn(AndroidSchedulers.mainThread())
21 | .subscribe(s);
22 | }
23 |
24 | /**
25 | * 用来统一处理Http的resultCode,并将HttpResult的Data部分剥离出来返回给subscriber
26 | *
27 | * @param Subscriber真正需要的数据类型,也就是Data部分的数据类型
28 | * Func1(I,O) 输入和输出
29 | */
30 | public class HttpResultFunc implements Func1, T> {
31 |
32 | @Override
33 | public T call(HttpResult httpResult) {
34 | if (httpResult.getStatus() == 1) {
35 | return httpResult.getData();
36 | }
37 | throw new ExceptionApi(httpResult.getStatus(), httpResult.getMessage());
38 | }
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/drawable/loading_animal.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/drawable/loading_animal.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/httpservice/serviceapi/UserApi.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.httpservice.serviceapi;
2 |
3 |
4 | import com.ywl5320.rxjavaretrofit.httpservice.beans.UserBean;
5 | import com.ywl5320.rxjavaretrofit.httpservice.beans.WeatherBean;
6 | import com.ywl5320.rxjavaretrofit.httpservice.service.BaseApi;
7 | import com.ywl5320.rxjavaretrofit.httpservice.service.HttpMethod;
8 |
9 | import rx.Observable;
10 | import rx.Subscriber;
11 |
12 | /**
13 | * Created by ywl on 2016/5/19.
14 | */
15 | public class UserApi extends BaseApi {
16 |
17 | public static UserApi userApi;
18 | public UserService userService;
19 | public UserApi()
20 | {
21 | userService = HttpMethod.getInstance().createApi(UserService.class);
22 | }
23 |
24 | public static UserApi getInstance()
25 | {
26 | if(userApi == null)
27 | {
28 | userApi = new UserApi();
29 | }
30 | return userApi;
31 | }
32 | /*-------------------------------------获取的方法-------------------------------------*/
33 |
34 | public void getWeather(String loaction, String output, String ak, Subscriber subscriber)
35 | {
36 | Observable observable = userService.getWeather(loaction, output, ak)
37 | .map(new HttpResultFunc());
38 |
39 | toSubscribe(observable, subscriber);
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/httpservice/service/BaseApi.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.httpservice.service;
2 |
3 |
4 | import com.ywl5320.rxjavaretrofit.httpservice.httpentity.HttpResult;
5 |
6 | import io.reactivex.Observable;
7 | import io.reactivex.Observer;
8 | import io.reactivex.android.schedulers.AndroidSchedulers;
9 | import io.reactivex.functions.Function;
10 | import io.reactivex.schedulers.Schedulers;
11 |
12 |
13 | /**
14 | * Created by ywl on 2016/5/19.
15 | */
16 | public class BaseApi {
17 |
18 | public void toSubscribe(Observable o, Observer s){
19 | o.subscribeOn(Schedulers.io())
20 | .unsubscribeOn(Schedulers.io())
21 | .observeOn(AndroidSchedulers.mainThread())
22 | .subscribe(s);
23 | }
24 |
25 | /**
26 | * 用来统一处理Http的resultCode,并将HttpResult的Data部分剥离出来返回给subscriber
27 | *
28 | * @param Subscriber真正需要的数据类型,也就是Data部分的数据类型
29 | * Func1(I,O) 输入和输出
30 | */
31 | public class HttpResultFunc implements Function, T> {
32 |
33 | @Override
34 | public T apply(HttpResult httpResult) {
35 | if (httpResult.getStatus() == 1) {
36 | return httpResult.getData();
37 | }
38 | throw new ExceptionApi(httpResult.getStatus(), httpResult.getMessage());
39 | }
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/httpservice/serviceapi/UserApi.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.httpservice.serviceapi;
2 |
3 |
4 | import com.ywl5320.rxjavaretrofit.httpservice.beans.UserBean;
5 | import com.ywl5320.rxjavaretrofit.httpservice.beans.WeatherBean;
6 | import com.ywl5320.rxjavaretrofit.httpservice.service.BaseApi;
7 | import com.ywl5320.rxjavaretrofit.httpservice.service.HttpMethod;
8 |
9 | import io.reactivex.Observable;
10 | import io.reactivex.Observer;
11 |
12 | /**
13 | * Created by ywl on 2016/5/19.
14 | */
15 | public class UserApi extends BaseApi {
16 |
17 | public static UserApi userApi;
18 | public UserService userService;
19 | public UserApi()
20 | {
21 | userService = HttpMethod.getInstance().createApi(UserService.class);
22 | }
23 |
24 | public static UserApi getInstance()
25 | {
26 | if(userApi == null)
27 | {
28 | userApi = new UserApi();
29 | }
30 | return userApi;
31 | }
32 | /*-------------------------------------获取的方法-------------------------------------*/
33 |
34 | public void getWeather(String loaction, String output, String ak, Observer subscriber)
35 | {
36 | Observable observable = userService.getWeather(loaction, output, ak)
37 | .map(new HttpResultFunc());
38 |
39 | toSubscribe(observable, subscriber);
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/res/layout/loading_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
24 |
25 |
29 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/res/layout/loading_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
24 |
25 |
29 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/httpservice/subscribers/HttpSubscriber.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.httpservice.subscribers;
2 |
3 | import com.ywl5320.rxjavaretrofit.httpservice.service.ExceptionApi;
4 | import android.content.Context;
5 |
6 | import java.net.ConnectException;
7 | import java.net.SocketTimeoutException;
8 |
9 | import rx.Subscriber;
10 |
11 | /**
12 | * Created by ywl on 2016/5/19.
13 | */
14 | public class HttpSubscriber extends Subscriber{
15 |
16 | private SubscriberOnListener subscriberOnListener;
17 | private Context context;
18 |
19 | public HttpSubscriber(SubscriberOnListener subscriberOnListener, Context context)
20 | {
21 | this.subscriberOnListener = subscriberOnListener;
22 | this.context = context;
23 |
24 | }
25 |
26 |
27 |
28 | public void onUnsubscribe() {
29 | if (!this.isUnsubscribed()) {
30 | this.unsubscribe();
31 | }
32 | }
33 |
34 | /**
35 | * 访问网络开始前(可以处理缓存)
36 | */
37 | @Override
38 | public void onStart() {
39 | super.onStart();
40 | }
41 |
42 | @Override
43 | public void onCompleted() {
44 | if(subscriberOnListener != null && context != null)
45 | {
46 | //subscriberOnListener.onError("完成", 1);
47 | }
48 | else
49 | {
50 | onUnsubscribe();
51 | }
52 | }
53 |
54 | @Override
55 | public void onError(Throwable e) {
56 | if(subscriberOnListener != null && context != null)
57 | {
58 | if (e instanceof SocketTimeoutException) {
59 | subscriberOnListener.onError(-1001, "网络超时,请检查您的网络状态");
60 | } else if (e instanceof ConnectException) {
61 | subscriberOnListener.onError(-1002, "网络链接中断,请检查您的网络状态");
62 | } else if(e instanceof ExceptionApi){
63 | subscriberOnListener.onError(((ExceptionApi)e).getCode(), ((ExceptionApi)e).getMsg());
64 | }
65 | else
66 | {
67 | subscriberOnListener.onError(-1003, "未知错误:" + e.getMessage());
68 | }
69 | }
70 | else
71 | {
72 | onUnsubscribe();
73 | }
74 | }
75 |
76 | @Override
77 | public void onNext(T t) {
78 | if(subscriberOnListener != null && context != null)
79 | {
80 | subscriberOnListener.onSucceed(t);
81 | }
82 | else
83 | {
84 | onUnsubscribe();
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.view.View;
6 | import android.widget.Button;
7 | import android.widget.Toast;
8 |
9 | import com.ywl5320.rxjavaretrofit.dialog.LoadDialog;
10 | import com.ywl5320.rxjavaretrofit.httpservice.beans.UserBean;
11 | import com.ywl5320.rxjavaretrofit.httpservice.beans.WeatherBean;
12 | import com.ywl5320.rxjavaretrofit.httpservice.serviceapi.UserApi;
13 | import com.ywl5320.rxjavaretrofit.httpservice.subscribers.HttpSubscriber;
14 | import com.ywl5320.rxjavaretrofit.httpservice.subscribers.SubscriberOnListener;
15 |
16 | public class MainActivity extends AppCompatActivity {
17 |
18 | private Button btnLogin;
19 | public LoadDialog loadDialog;
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_main);
25 | btnLogin = (Button) findViewById(R.id.btn_login);
26 |
27 | btnLogin.setOnClickListener(new View.OnClickListener() {
28 | @Override
29 | public void onClick(View v) {
30 |
31 | showLoadDialog("正在获取天气数据");
32 |
33 | UserApi.getInstance().getWeather("成都", "json", "5NImrCXDE8hR05Yc49Bgs5QG", new HttpSubscriber(new SubscriberOnListener() {
34 | @Override
35 | public void onSucceed(WeatherBean data) {
36 | hideLoadDialog();//这个可以在回调里面添加到complete里面,关闭对话框只写到这个里面就可以了
37 | }
38 |
39 | @Override
40 | public void onError(int code, String msg) {
41 | Toast.makeText(MainActivity.this, "status:" + code + "," + msg, Toast.LENGTH_LONG).show();
42 | hideLoadDialog();
43 | }
44 | }, MainActivity.this));
45 | }
46 | });
47 |
48 | }
49 |
50 | public void showLoadDialog(String msg)
51 | {
52 | if(loadDialog == null)
53 | {
54 | loadDialog = new LoadDialog(this);
55 | }
56 | loadDialog.show();
57 | loadDialog.setLoadMsg(msg);
58 | }
59 |
60 | public void hideLoadDialog()
61 | {
62 | if(loadDialog != null)
63 | loadDialog.dismiss();
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.view.View;
6 | import android.widget.Button;
7 | import android.widget.Toast;
8 |
9 | import com.ywl5320.rxjavaretrofit.dialog.LoadDialog;
10 | import com.ywl5320.rxjavaretrofit.httpservice.beans.UserBean;
11 | import com.ywl5320.rxjavaretrofit.httpservice.beans.WeatherBean;
12 | import com.ywl5320.rxjavaretrofit.httpservice.serviceapi.UserApi;
13 | import com.ywl5320.rxjavaretrofit.httpservice.subscribers.HttpSubscriber;
14 | import com.ywl5320.rxjavaretrofit.httpservice.subscribers.SubscriberOnListener;
15 |
16 | public class MainActivity extends AppCompatActivity {
17 |
18 | private Button btnLogin;
19 | public LoadDialog loadDialog;
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_main);
25 | btnLogin = (Button) findViewById(R.id.btn_login);
26 |
27 | btnLogin.setOnClickListener(new View.OnClickListener() {
28 | @Override
29 | public void onClick(View v) {
30 |
31 | showLoadDialog("正在获取天气数据");
32 |
33 | UserApi.getInstance().getWeather("成都", "json", "5NImrCXDE8hR05Yc49Bgs5QG", new HttpSubscriber(new SubscriberOnListener() {
34 | @Override
35 | public void onSucceed(WeatherBean data) {
36 | hideLoadDialog();//这个可以在回调里面添加到complete里面,关闭对话框只写到这个里面就可以了
37 | }
38 |
39 | @Override
40 | public void onError(int code, String msg) {
41 | Toast.makeText(MainActivity.this, "status:" + code + "," + msg, Toast.LENGTH_LONG).show();
42 | hideLoadDialog();
43 | }
44 | }, MainActivity.this));
45 | }
46 | });
47 |
48 | }
49 |
50 | public void showLoadDialog(String msg)
51 | {
52 | if(loadDialog == null)
53 | {
54 | loadDialog = new LoadDialog(this);
55 | }
56 | loadDialog.show();
57 | loadDialog.setLoadMsg(msg);
58 | }
59 |
60 | public void hideLoadDialog()
61 | {
62 | if(loadDialog != null)
63 | loadDialog.dismiss();
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/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 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/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 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/httpservice/subscribers/HttpSubscriber.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.httpservice.subscribers;
2 |
3 | import com.ywl5320.rxjavaretrofit.httpservice.service.ExceptionApi;
4 |
5 | import android.content.Context;
6 |
7 | import java.net.ConnectException;
8 | import java.net.SocketTimeoutException;
9 |
10 | import io.reactivex.Observer;
11 | import io.reactivex.annotations.NonNull;
12 | import io.reactivex.disposables.Disposable;
13 |
14 | /**
15 | * Created by ywl on 2016/5/19.
16 | */
17 | public class HttpSubscriber implements Observer {
18 |
19 | private SubscriberOnListener subscriberOnListener;
20 | private Context context;
21 | private Disposable disposable;
22 |
23 | public HttpSubscriber(SubscriberOnListener subscriberOnListener, Context context)
24 | {
25 | this.subscriberOnListener = subscriberOnListener;
26 | this.context = context;
27 |
28 | }
29 |
30 | @Override
31 | public void onSubscribe(@NonNull Disposable d) {
32 | disposable = d;
33 | }
34 |
35 | @Override
36 | public void onComplete() {
37 | if(subscriberOnListener != null && context != null)
38 | {
39 | //subscriberOnListener.onError("完成", 1);
40 | }
41 | else
42 | {
43 | if(disposable != null && !disposable.isDisposed())
44 | disposable.dispose();
45 | }
46 | }
47 |
48 | @Override
49 | public void onError(Throwable e) {
50 | if(subscriberOnListener != null && context != null)
51 | {
52 | if (e instanceof SocketTimeoutException) {
53 | subscriberOnListener.onError(-1001, "网络超时,请检查您的网络状态");
54 | } else if (e instanceof ConnectException) {
55 | subscriberOnListener.onError(-1002, "网络链接中断,请检查您的网络状态");
56 | } else if(e instanceof ExceptionApi){
57 | subscriberOnListener.onError(((ExceptionApi)e).getCode(), ((ExceptionApi)e).getMsg());
58 | }
59 | else
60 | {
61 | subscriberOnListener.onError(-1003, "未知错误:" + e.getMessage());
62 | }
63 | }
64 | else
65 | {
66 | if(disposable != null && !disposable.isDisposed())
67 | disposable.dispose();
68 | }
69 | }
70 |
71 | @Override
72 | public void onNext(T t) {
73 | if(subscriberOnListener != null && context != null)
74 | {
75 | subscriberOnListener.onSucceed(t);
76 | }
77 | else
78 | {
79 | if(disposable != null && !disposable.isDisposed())
80 | disposable.dispose();
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/utils/NetUtil.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.utils;
2 |
3 | import android.content.Context;
4 | import android.net.ConnectivityManager;
5 | import android.net.NetworkInfo;
6 |
7 | /**
8 | * Created by ywl on 2016/1/30.
9 | */
10 | public class NetUtil {
11 |
12 | public static final int NETWORN_NONE = 0;
13 | public static final int NETWORN_WIFI = 1;
14 | public static final int NETWORN_MOBILE = 2;
15 |
16 | /**
17 | * 获取网络状态
18 | *
19 | * @param context
20 | * @return
21 | */
22 | public static int getNetworkState(Context context) {
23 | ConnectivityManager connManager = (ConnectivityManager) context
24 | .getSystemService(Context.CONNECTIVITY_SERVICE);
25 |
26 | // Wifi
27 | NetworkInfo.State state = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
28 | .getState();
29 | if (state == NetworkInfo.State.CONNECTED || state == NetworkInfo.State.CONNECTING) {
30 | return NETWORN_WIFI;
31 | }
32 |
33 | // 3G
34 | state = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE)
35 | .getState();
36 | if (state == NetworkInfo.State.CONNECTED || state == NetworkInfo.State.CONNECTING) {
37 | return NETWORN_MOBILE;
38 | }
39 | return NETWORN_NONE;
40 | }
41 |
42 | /**
43 | * 获取当前网络状态
44 | *
45 | * @param context
46 | * 上下文
47 | * @return 网络连接返回true;未连接返回false
48 | */
49 | public static boolean getNetworkIsConnected(Context context) {
50 | // 获取网络连接管理器
51 | ConnectivityManager manager = (ConnectivityManager) context
52 | .getSystemService(Context.CONNECTIVITY_SERVICE);
53 | // 如果管理器为null,返回false
54 | if (manager == null) {
55 | return false;
56 | }
57 | // 获取正在活动的网络信息
58 | NetworkInfo info = manager.getActiveNetworkInfo();
59 | // 如果网络信息为null,返回false
60 | if (info == null) {
61 | return false;
62 | }
63 | // 返回网络是否连接
64 | return info.isConnected();
65 | }
66 | /**
67 | * 网络类型
68 | *
69 | * @param context
70 | * @return true :是,false :否
71 | */
72 | public static boolean isWiFi(Context context) {
73 | ConnectivityManager connectMgr = (ConnectivityManager) context
74 |
75 | .getSystemService(Context.CONNECTIVITY_SERVICE);
76 | NetworkInfo info = connectMgr.getActiveNetworkInfo();
77 | if (info == null) {
78 | return false;
79 | } else {
80 | if (info.getType() == ConnectivityManager.TYPE_WIFI) {
81 | return true;
82 | } else {
83 | return false;
84 | }
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/utils/NetUtil.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.utils;
2 |
3 | import android.content.Context;
4 | import android.net.ConnectivityManager;
5 | import android.net.NetworkInfo;
6 |
7 | /**
8 | * Created by ywl on 2016/1/30.
9 | */
10 | public class NetUtil {
11 |
12 | public static final int NETWORN_NONE = 0;
13 | public static final int NETWORN_WIFI = 1;
14 | public static final int NETWORN_MOBILE = 2;
15 |
16 | /**
17 | * 获取网络状态
18 | *
19 | * @param context
20 | * @return
21 | */
22 | public static int getNetworkState(Context context) {
23 | ConnectivityManager connManager = (ConnectivityManager) context
24 | .getSystemService(Context.CONNECTIVITY_SERVICE);
25 |
26 | // Wifi
27 | NetworkInfo.State state = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
28 | .getState();
29 | if (state == NetworkInfo.State.CONNECTED || state == NetworkInfo.State.CONNECTING) {
30 | return NETWORN_WIFI;
31 | }
32 |
33 | // 3G
34 | state = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE)
35 | .getState();
36 | if (state == NetworkInfo.State.CONNECTED || state == NetworkInfo.State.CONNECTING) {
37 | return NETWORN_MOBILE;
38 | }
39 | return NETWORN_NONE;
40 | }
41 |
42 | /**
43 | * 获取当前网络状态
44 | *
45 | * @param context
46 | * 上下文
47 | * @return 网络连接返回true;未连接返回false
48 | */
49 | public static boolean getNetworkIsConnected(Context context) {
50 | // 获取网络连接管理器
51 | ConnectivityManager manager = (ConnectivityManager) context
52 | .getSystemService(Context.CONNECTIVITY_SERVICE);
53 | // 如果管理器为null,返回false
54 | if (manager == null) {
55 | return false;
56 | }
57 | // 获取正在活动的网络信息
58 | NetworkInfo info = manager.getActiveNetworkInfo();
59 | // 如果网络信息为null,返回false
60 | if (info == null) {
61 | return false;
62 | }
63 | // 返回网络是否连接
64 | return info.isConnected();
65 | }
66 | /**
67 | * 网络类型
68 | *
69 | * @param context
70 | * @return true :是,false :否
71 | */
72 | public static boolean isWiFi(Context context) {
73 | ConnectivityManager connectMgr = (ConnectivityManager) context
74 |
75 | .getSystemService(Context.CONNECTIVITY_SERVICE);
76 | NetworkInfo info = connectMgr.getActiveNetworkInfo();
77 | if (info == null) {
78 | return false;
79 | } else {
80 | if (info.getType() == ConnectivityManager.TYPE_WIFI) {
81 | return true;
82 | } else {
83 | return false;
84 | }
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/httpservice/service/HttpMethod.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.httpservice.service;
2 |
3 |
4 |
5 | import com.ywl5320.rxjavaretrofit.MyApplication;
6 | import com.ywl5320.rxjavaretrofit.utils.NetUtil;
7 |
8 | import java.io.File;
9 | import java.io.IOException;
10 |
11 | import okhttp3.Cache;
12 | import okhttp3.CacheControl;
13 | import okhttp3.Interceptor;
14 | import okhttp3.OkHttpClient;
15 | import okhttp3.Request;
16 | import okhttp3.Response;
17 | import okhttp3.logging.HttpLoggingInterceptor;
18 | import retrofit2.Retrofit;
19 | import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
20 | import retrofit2.converter.gson.GsonConverterFactory;
21 |
22 | /**
23 | * Created by ywl on 2016/5/19.
24 | */
25 | public class HttpMethod {
26 |
27 | public static final String BASE_URL = "http://api.map.baidu.com/";
28 | public static String token = "";//请求时用户的Token
29 | private static Retrofit retrofit;
30 | //构造方法私有
31 | private HttpMethod() {
32 | retrofit = new Retrofit.Builder()
33 | .client(genericClient())
34 | .addConverterFactory(GsonConverterFactory.create())
35 | .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
36 | .baseUrl(BASE_URL)
37 | .build();
38 | }
39 |
40 |
41 | public static T createApi(Class clazz) {
42 |
43 | return retrofit.create(clazz);
44 | }
45 |
46 |
47 | //在访问HttpMethods时创建单例
48 | private static class SingletonHolder{
49 | private static final HttpMethod INSTANCE = new HttpMethod();
50 | }
51 |
52 | //获取单例
53 | public static HttpMethod getInstance(){
54 | return SingletonHolder.INSTANCE;
55 | }
56 |
57 |
58 | public static OkHttpClient genericClient() {
59 | HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
60 | // set your desired log level
61 | logging.setLevel(HttpLoggingInterceptor.Level.BODY);
62 | //设置缓存路径
63 | File httpCacheDirectory = new File(MyApplication.getInstance().getExternalCacheDir().getAbsolutePath(), "responses");
64 | //设置缓存 10M
65 | Cache cache = new Cache(httpCacheDirectory, 50 * 1024 * 1024);
66 | OkHttpClient httpClient = new OkHttpClient.Builder()
67 | .addInterceptor(new Interceptor() {
68 | @Override
69 | public Response intercept(Chain chain) throws IOException {
70 | Request request = chain.request()
71 | .newBuilder()
72 | .addHeader("token", token)//添加token
73 | .build();
74 |
75 | if (!NetUtil.getNetworkIsConnected(MyApplication.getInstance())) {
76 | request = request.newBuilder()
77 | .cacheControl(CacheControl.FORCE_CACHE)
78 | .build();
79 | }
80 |
81 | Response response = chain.proceed(request);
82 | if (NetUtil.getNetworkIsConnected(MyApplication.getInstance())) {
83 | int maxAge = 0 * 60; // 有网络时 设置缓存超时时间0个小时
84 | response.newBuilder()
85 | .addHeader("Cache-Control", "public, max-age=" + maxAge)
86 | .removeHeader("Pragma")// 清除头信息,因为服务器如果不支持,会返回一些干扰信息,不清除下面无法生效
87 | .build();
88 | } else {
89 | int maxStale = 60 * 60 * 24 * 7; // 无网络时,设置超时为1周
90 | response.newBuilder()
91 | .addHeader("Cache-Control", "public, only-if-cached, max-stale=" + maxStale)
92 | .removeHeader("Pragma")
93 | .build();
94 | }
95 | return response;
96 | }
97 |
98 | }).
99 | addInterceptor(logging).
100 | cache(cache)
101 | .build();
102 |
103 | return httpClient;
104 | }
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/app/src/main/java/com/ywl5320/rxjavaretrofit/httpservice/service/HttpMethod.java:
--------------------------------------------------------------------------------
1 | package com.ywl5320.rxjavaretrofit.httpservice.service;
2 |
3 |
4 |
5 | import com.ywl5320.rxjavaretrofit.MyApplication;
6 | import com.ywl5320.rxjavaretrofit.utils.NetUtil;
7 |
8 | import java.io.File;
9 | import java.io.IOException;
10 |
11 | import okhttp3.Cache;
12 | import okhttp3.CacheControl;
13 | import okhttp3.Interceptor;
14 | import okhttp3.OkHttpClient;
15 | import okhttp3.Request;
16 | import okhttp3.Response;
17 | import okhttp3.logging.HttpLoggingInterceptor;
18 | import retrofit2.Retrofit;
19 | import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
20 | import retrofit2.converter.gson.GsonConverterFactory;
21 |
22 | /**
23 | * Created by ywl on 2016/5/19.
24 | */
25 | public class HttpMethod {
26 |
27 | public static final String BASE_URL = "http://api.map.baidu.com/";
28 | public static String token = "";//请求时用户的Token
29 | private static Retrofit retrofit;
30 | //构造方法私有
31 | private HttpMethod() {
32 | retrofit = new Retrofit.Builder()
33 | .client(genericClient())
34 | .addConverterFactory(GsonConverterFactory.create())
35 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
36 | .baseUrl(BASE_URL)
37 | .build();
38 | }
39 |
40 |
41 | public static T createApi(Class clazz) {
42 |
43 | return retrofit.create(clazz);
44 | }
45 |
46 |
47 | //在访问HttpMethods时创建单例
48 | private static class SingletonHolder{
49 | private static final HttpMethod INSTANCE = new HttpMethod();
50 | }
51 |
52 | //获取单例
53 | public static HttpMethod getInstance(){
54 | return SingletonHolder.INSTANCE;
55 | }
56 |
57 |
58 | public static OkHttpClient genericClient() {
59 | HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
60 | // set your desired log level
61 | logging.setLevel(HttpLoggingInterceptor.Level.BODY);
62 | //设置缓存路径
63 | File httpCacheDirectory = new File(MyApplication.getInstance().getExternalCacheDir().getAbsolutePath(), "responses");
64 | //设置缓存 10M
65 | Cache cache = new Cache(httpCacheDirectory, 50 * 1024 * 1024);
66 | OkHttpClient httpClient = new OkHttpClient.Builder()
67 | .addInterceptor(new Interceptor() {
68 | @Override
69 | public Response intercept(Chain chain) throws IOException {
70 | Request request = chain.request()
71 | .newBuilder()
72 | .addHeader("token", token)//添加token
73 | .build();
74 |
75 | if (!NetUtil.getNetworkIsConnected(MyApplication.getInstance())) {
76 | request = request.newBuilder()
77 | .cacheControl(CacheControl.FORCE_CACHE)
78 | .build();
79 | }
80 |
81 | Response response = chain.proceed(request);
82 | if (NetUtil.getNetworkIsConnected(MyApplication.getInstance())) {
83 | int maxAge = 0 * 60; // 有网络时 设置缓存超时时间0个小时
84 | response.newBuilder()
85 | .addHeader("Cache-Control", "public, max-age=" + maxAge)
86 | .removeHeader("Pragma")// 清除头信息,因为服务器如果不支持,会返回一些干扰信息,不清除下面无法生效
87 | .build();
88 | } else {
89 | int maxStale = 60 * 60 * 24 * 7; // 无网络时,设置超时为1周
90 | response.newBuilder()
91 | .addHeader("Cache-Control", "public, only-if-cached, max-stale=" + maxStale)
92 | .removeHeader("Pragma")
93 | .build();
94 | }
95 | return response;
96 | }
97 |
98 | }).
99 | addInterceptor(logging).
100 | cache(cache)
101 | .build();
102 |
103 | return httpClient;
104 | }
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/RxJavaRetrofit/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/RxJava2Retrofit2Okhttp3/RxJavaRetrofit/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------