├── .gitignore
├── EasyRxRetrofit
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── jimi_wu
│ │ └── easyrxretrofit
│ │ ├── RetrofitManager.java
│ │ ├── agent
│ │ └── AgentInterceptor.java
│ │ ├── build
│ │ ├── DefaultRetrofitBuilder.java
│ │ └── RetrofitBuilder.java
│ │ ├── cookie
│ │ ├── CookieManager.java
│ │ ├── CookieStore.java
│ │ └── OkHttpCookies.java
│ │ ├── download
│ │ ├── DownLoadOnSubscribe.java
│ │ ├── DownLoadService.java
│ │ └── DownLoadTransformer.java
│ │ ├── exception
│ │ └── ServerException.java
│ │ ├── observer
│ │ ├── BaseObserver.java
│ │ ├── DownLoadObserver.java
│ │ └── UploadObserver.java
│ │ ├── transformer
│ │ ├── BaseModel.java
│ │ └── BaseModelTransformer.java
│ │ ├── upload
│ │ ├── UploadOnSubscribe.java
│ │ ├── UploadParam.java
│ │ ├── UploadRequestBody.java
│ │ └── UploadService.java
│ │ └── utils
│ │ └── FileUtils.java
│ └── res
│ └── values
│ └── strings.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── jimi_wu
│ │ └── sample
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── jimi_wu
│ │ │ └── sample
│ │ │ ├── Constants.java
│ │ │ ├── FileUtils.java
│ │ │ ├── MainActivity.java
│ │ │ ├── apiservice
│ │ │ └── GetUserService.java
│ │ │ ├── application
│ │ │ ├── SampleApplication.java
│ │ │ └── SampleRetrofitBuilder.java
│ │ │ └── model
│ │ │ ├── FileBean.java
│ │ │ ├── ResultBean.java
│ │ │ └── UserBean.java
│ └── res
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── jimi_wu
│ └── sample
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
11 | .idea/
12 | gradlew
13 | gradlew.bat
--------------------------------------------------------------------------------
/EasyRxRetrofit/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/EasyRxRetrofit/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.github.dcendents.android-maven'
3 | apply plugin: 'com.jfrog.bintray'
4 |
5 | android {
6 | compileSdkVersion 25
7 | buildToolsVersion "25.0.0"
8 | resourcePrefix "init"
9 |
10 | defaultConfig {
11 | minSdkVersion 15
12 | targetSdkVersion 25
13 | versionCode 200
14 | versionName "2.0.0"
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 |
23 | lintOptions {
24 | abortOnError false
25 | }
26 | }
27 |
28 | dependencies {
29 | // rxjava
30 | implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
31 | implementation 'io.reactivex.rxjava2:rxjava:2.2.2'
32 | // retrofit
33 | implementation 'com.squareup.retrofit2:retrofit:2.4.0'
34 | implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
35 | //gson
36 | implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
37 | }
38 |
39 | version = "2.0.0"
40 | def siteUrl = 'https://github.com/whichname/EasyRxRetrofit' // 项目的主页
41 | def gitUrl = 'https://github.com/whichname/EasyRxRetrofit.git' // Git仓库的url
42 | group = "com.jimi_wu" // Maven Group ID for the artifact,一般填你唯一的包名
43 | install {
44 | repositories.mavenInstaller {
45 | // This generates POM.xml with proper parameters
46 | pom {
47 | project {
48 | packaging 'aar'
49 | // Add your description here
50 | name 'EasyRxRetrofit'
51 | url siteUrl
52 | // Set your license
53 | licenses {
54 | license {
55 | name 'The Apache Software License, Version 2.0'
56 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
57 | }
58 | }
59 | developers {
60 | developer {
61 | id 'whichname' //填写的一些基本信息
62 | name 'jimi_wu'
63 | }
64 | }
65 | scm {
66 | connection gitUrl
67 | developerConnection siteUrl
68 | url siteUrl
69 | }
70 | }
71 | }
72 | }
73 | }
74 | task sourcesJar(type: Jar) {
75 | from android.sourceSets.main.java.srcDirs
76 | classifier = 'sources'
77 | }
78 | task javadoc(type: Javadoc) {
79 | options.encoding = "utf-8"
80 | source = android.sourceSets.main.java.srcDirs
81 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
82 | }
83 | task javadocJar(type: Jar, dependsOn: javadoc) {
84 | classifier = 'javadoc'
85 | from javadoc.destinationDir
86 | }
87 | artifacts {
88 | archives javadocJar
89 | archives sourcesJar
90 | }
91 | Properties properties = new Properties()
92 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
93 | bintray {
94 | user = properties.getProperty("bintray.user")
95 | key = properties.getProperty("bintray.apikey")
96 | configurations = ['archives']
97 | pkg {
98 | repo = "maven"
99 | name = "EasyRxRetrofit" //发布到JCenter上的项目名字
100 | websiteUrl = siteUrl
101 | vcsUrl = gitUrl
102 | licenses = ["Apache-2.0"]
103 | publish = true
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/EasyRxRetrofit/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/wuzhiming/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/EasyRxRetrofit/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/EasyRxRetrofit/src/main/java/com/jimi_wu/easyrxretrofit/RetrofitManager.java:
--------------------------------------------------------------------------------
1 | package com.jimi_wu.easyrxretrofit;
2 |
3 | import android.text.TextUtils;
4 |
5 | import com.jimi_wu.easyrxretrofit.build.DefaultRetrofitBuilder;
6 | import com.jimi_wu.easyrxretrofit.build.RetrofitBuilder;
7 | import com.jimi_wu.easyrxretrofit.download.DownLoadService;
8 | import com.jimi_wu.easyrxretrofit.download.DownLoadTransformer;
9 | import com.jimi_wu.easyrxretrofit.transformer.BaseModel;
10 | import com.jimi_wu.easyrxretrofit.transformer.BaseModelTransformer;
11 | import com.jimi_wu.easyrxretrofit.upload.UploadOnSubscribe;
12 | import com.jimi_wu.easyrxretrofit.upload.UploadParam;
13 | import com.jimi_wu.easyrxretrofit.upload.UploadRequestBody;
14 | import com.jimi_wu.easyrxretrofit.upload.UploadService;
15 | import com.jimi_wu.easyrxretrofit.utils.FileUtils;
16 |
17 | import java.util.ArrayList;
18 | import java.util.Arrays;
19 | import java.util.List;
20 |
21 | import io.reactivex.Observable;
22 | import io.reactivex.ObservableTransformer;
23 | import okhttp3.MultipartBody;
24 | import okhttp3.ResponseBody;
25 | import retrofit2.Retrofit;
26 |
27 | /**
28 | * Created by wzm on 2017/6/14.
29 | */
30 | public class RetrofitManager {
31 |
32 | /**
33 | * 初始化
34 | */
35 | private static Retrofit mRetrofit;
36 |
37 | public static void init(RetrofitBuilder builder) {
38 | mRetrofit = builder.initRetrofit();
39 | }
40 |
41 | public static Retrofit getRetrofit() {
42 | if (mRetrofit == null) {
43 | mRetrofit = new DefaultRetrofitBuilder().initRetrofit();
44 | }
45 | return mRetrofit;
46 | }
47 |
48 | /**
49 | * 创建请求
50 | */
51 | public static T createService(final Class service) {
52 | return getRetrofit().create(service);
53 | }
54 |
55 | /**
56 | * 转换
57 | */
58 | public static ObservableTransformer, T> handleResult() {
59 | return new BaseModelTransformer<>();
60 | }
61 |
62 |
63 | /**
64 | * 下载
65 | */
66 | public static Observable