├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── fatchao
│ │ └── rxrequest
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── fatchao
│ │ │ └── rxrequest
│ │ │ ├── BaseApplication.java
│ │ │ ├── MainActivity.java
│ │ │ ├── bean
│ │ │ ├── LoginBean.java
│ │ │ └── OneBean.java
│ │ │ ├── callback
│ │ │ └── Callback.java
│ │ │ ├── constants
│ │ │ ├── Constant.java
│ │ │ └── RxUrl.java
│ │ │ ├── request
│ │ │ ├── ProxyHandler.java
│ │ │ ├── RequestManager.java
│ │ │ ├── RxRequest.java
│ │ │ └── RxSubscriber.java
│ │ │ └── utils
│ │ │ ├── HintUtils.java
│ │ │ ├── NetworkManager.java
│ │ │ └── PrefUtils.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
│ └── fatchao
│ └── rxrequest
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── 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 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | 1.8
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | dexOptions {
5 | javaMaxHeapSize "4g"
6 | }
7 | compileSdkVersion 25
8 | buildToolsVersion "25.0.2"
9 | aaptOptions {
10 | cruncherEnabled = false
11 | useNewCruncher = false
12 | }
13 | lintOptions {
14 | checkReleaseBuilds false
15 | // Or, if you prefer, you can continue to check for errors in release builds,
16 | // but continue the build even when errors are found:
17 | abortOnError false
18 | }
19 | configurations.all {
20 | resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
21 | }
22 | defaultConfig {
23 | ndk {
24 | abiFilter 'armeabi'
25 | }
26 | applicationId "com.fatchao.rxrequest"
27 | minSdkVersion 16
28 | targetSdkVersion 23
29 | multiDexEnabled true
30 | versionCode 1
31 | versionName "1.2"
32 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
33 | }
34 |
35 |
36 | buildTypes {
37 | release {
38 | minifyEnabled false
39 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
40 | }
41 | debug {
42 | }
43 | }
44 | }
45 |
46 | dependencies {
47 | compile fileTree(include: ['*.jar'], dir: 'libs')
48 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
49 | exclude group: 'com.android.support', module: 'support-annotations'
50 | })
51 |
52 | compile 'com.android.support:support-v4:25.3.0'
53 | compile 'com.squareup.retrofit2:converter-gson:2.1.0'
54 | compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
55 | compile 'io.reactivex:rxjava:1.1.9'
56 | compile 'io.reactivex:rxandroid:1.2.1'
57 | compile 'com.google.code.gson:gson:2.7'
58 | compile 'com.trello:rxlifecycle:1.0'
59 | compile 'com.trello:rxlifecycle-android:1.0'
60 | compile 'com.trello:rxlifecycle-components:1.0'
61 | compile 'com.android.support:recyclerview-v7:25.3.0'
62 | compile 'com.squareup.okhttp3:logging-interceptor:3.6.0'
63 | compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
64 | }
65 |
--------------------------------------------------------------------------------
/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:\l\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 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/fatchao/rxrequest/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.fatchao.rxrequest;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.fatchao.rxrequest", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fatchao/rxrequest/BaseApplication.java:
--------------------------------------------------------------------------------
1 | package com.fatchao.rxrequest;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 |
6 | public class BaseApplication extends Application {
7 | private static Context mContext;
8 |
9 | public static Context getContext() {
10 | return mContext;
11 | }
12 |
13 |
14 | @Override
15 | public void onCreate() {
16 | super.onCreate();
17 | mContext = getApplicationContext();
18 | }
19 |
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fatchao/rxrequest/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.fatchao.rxrequest;
2 |
3 | import android.os.Bundle;
4 | import android.view.View;
5 | import android.widget.TextView;
6 |
7 | import com.fatchao.rxrequest.bean.OneBean;
8 | import com.fatchao.rxrequest.callback.Callback;
9 | import com.fatchao.rxrequest.request.RequestManager;
10 | import com.fatchao.rxrequest.request.RxRequest;
11 | import com.fatchao.rxrequest.request.RxSubscriber;
12 | import com.trello.rxlifecycle.components.support.RxAppCompatActivity;
13 |
14 | import java.util.HashMap;
15 |
16 | import rx.Observable;
17 |
18 | public class MainActivity extends RxAppCompatActivity {
19 | private TextView tvData;
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_main);
25 | iniViews();
26 | }
27 |
28 | private void iniViews() {
29 | tvData = (TextView) findViewById(R.id.tv_data);
30 | }
31 |
32 | @SuppressWarnings("unchecked")
33 | public void getData(View view) {
34 | HashMap hashMap = new HashMap<>();
35 | hashMap.put("strDate", "2017-03-25");
36 | Observable weather = RxRequest.getInstance().getProxy(false).postData(hashMap);
37 | RxSubscriber subscriber = new RxSubscriber(this, new Callback() {
38 | @Override
39 | public void onSuccess(OneBean oneBean) {
40 | tvData.setText(oneBean.getHpEntity().getStrContent());
41 | }
42 | });
43 | RequestManager.getInstance().sendRequest(weather, subscriber);
44 | }
45 |
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fatchao/rxrequest/bean/LoginBean.java:
--------------------------------------------------------------------------------
1 | package com.fatchao.rxrequest.bean;
2 |
3 | import java.io.Serializable;
4 | import java.util.List;
5 |
6 | /**
7 | * Created by fatchao
8 | * 日期 2017-03-31.
9 | * 邮箱 fat_chao@163.com
10 | */
11 | public class LoginBean implements Serializable {
12 |
13 | private String code;
14 | private String message;
15 |
16 | private DataBean data;
17 | private ProfileBean profile;
18 |
19 | public String getCode() {
20 | return code;
21 | }
22 |
23 | public void setCode(String code) {
24 | this.code = code;
25 | }
26 |
27 | public String getMessage() {
28 | return message;
29 | }
30 |
31 | public void setMessage(String message) {
32 | this.message = message;
33 | }
34 |
35 | public DataBean getData() {
36 | return data;
37 | }
38 |
39 | public void setData(DataBean data) {
40 | this.data = data;
41 | }
42 |
43 | public ProfileBean getProfile() {
44 | return profile;
45 | }
46 |
47 | public void setProfile(ProfileBean profile) {
48 | this.profile = profile;
49 | }
50 |
51 | public static class DataBean {
52 | private String token;
53 | private int expiredSecond;
54 |
55 | public String getToken() {
56 | return token;
57 | }
58 |
59 | public void setToken(String token) {
60 | this.token = token;
61 | }
62 |
63 | public int getExpiredSecond() {
64 | return expiredSecond;
65 | }
66 |
67 | public void setExpiredSecond(int expiredSecond) {
68 | this.expiredSecond = expiredSecond;
69 | }
70 | }
71 |
72 | public static class ProfileBean {
73 | private List type;
74 |
75 | public List getType() {
76 | return type;
77 | }
78 |
79 | public void setType(List type) {
80 | this.type = type;
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fatchao/rxrequest/bean/OneBean.java:
--------------------------------------------------------------------------------
1 | package com.fatchao.rxrequest.bean;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * Created by fatchao
7 | * 日期 2017-03-31.
8 | * 邮箱 fat_chao@163.com
9 | */
10 |
11 | public class OneBean implements Serializable {
12 |
13 | /**
14 | * result : SUCCESS
15 | * hpEntity : {"strLastUpdateDate":"2017-03-31 03:50:13","strDayDiffer":"6","strHpId":"1657","strHpTitle":"VOL.1630","strThumbnailUrl":"http://image.wufazhuce.com/FkJa30EpkRFgPookYi7Uit1y08L5","strOriginalImgUrl":"http://image.wufazhuce.com/FkJa30EpkRFgPookYi7Uit1y08L5","strAuthor":"插画","strContent":"可不想让自己沉溺于虚荣,挣扎于诋毁,磨灭你本该拥有的自在欢愉,真情实性。那你就要记住,知道你自己是谁,比知道他们是谁重要。","strMarketTime":"2017-03-25","sWebLk":"http://m.wufazhuce.com/one/1657","strPn":"","wImgUrl":""}
16 | */
17 |
18 | private String result;
19 | private HpEntityBean hpEntity;
20 |
21 | public String getResult() {
22 | return result;
23 | }
24 |
25 | public void setResult(String result) {
26 | this.result = result;
27 | }
28 |
29 | public HpEntityBean getHpEntity() {
30 | return hpEntity;
31 | }
32 |
33 | public void setHpEntity(HpEntityBean hpEntity) {
34 | this.hpEntity = hpEntity;
35 | }
36 |
37 | public static class HpEntityBean {
38 | /**
39 | * strLastUpdateDate : 2017-03-31 03:50:13
40 | * strDayDiffer : 6
41 | * strHpId : 1657
42 | * strHpTitle : VOL.1630
43 | * strThumbnailUrl : http://image.wufazhuce.com/FkJa30EpkRFgPookYi7Uit1y08L5
44 | * strOriginalImgUrl : http://image.wufazhuce.com/FkJa30EpkRFgPookYi7Uit1y08L5
45 | * strAuthor : 插画
46 | * strContent : 可不想让自己沉溺于虚荣,挣扎于诋毁,磨灭你本该拥有的自在欢愉,真情实性。那你就要记住,知道你自己是谁,比知道他们是谁重要。
47 | * strMarketTime : 2017-03-25
48 | * sWebLk : http://m.wufazhuce.com/one/1657
49 | * strPn :
50 | * wImgUrl :
51 | */
52 |
53 | private String strLastUpdateDate;
54 | private String strDayDiffer;
55 | private String strHpId;
56 | private String strHpTitle;
57 | private String strThumbnailUrl;
58 | private String strOriginalImgUrl;
59 | private String strAuthor;
60 | private String strContent;
61 | private String strMarketTime;
62 | private String sWebLk;
63 | private String strPn;
64 | private String wImgUrl;
65 |
66 | public String getStrLastUpdateDate() {
67 | return strLastUpdateDate;
68 | }
69 |
70 | public void setStrLastUpdateDate(String strLastUpdateDate) {
71 | this.strLastUpdateDate = strLastUpdateDate;
72 | }
73 |
74 | public String getStrDayDiffer() {
75 | return strDayDiffer;
76 | }
77 |
78 | public void setStrDayDiffer(String strDayDiffer) {
79 | this.strDayDiffer = strDayDiffer;
80 | }
81 |
82 | public String getStrHpId() {
83 | return strHpId;
84 | }
85 |
86 | public void setStrHpId(String strHpId) {
87 | this.strHpId = strHpId;
88 | }
89 |
90 | public String getStrHpTitle() {
91 | return strHpTitle;
92 | }
93 |
94 | public void setStrHpTitle(String strHpTitle) {
95 | this.strHpTitle = strHpTitle;
96 | }
97 |
98 | public String getStrThumbnailUrl() {
99 | return strThumbnailUrl;
100 | }
101 |
102 | public void setStrThumbnailUrl(String strThumbnailUrl) {
103 | this.strThumbnailUrl = strThumbnailUrl;
104 | }
105 |
106 | public String getStrOriginalImgUrl() {
107 | return strOriginalImgUrl;
108 | }
109 |
110 | public void setStrOriginalImgUrl(String strOriginalImgUrl) {
111 | this.strOriginalImgUrl = strOriginalImgUrl;
112 | }
113 |
114 | public String getStrAuthor() {
115 | return strAuthor;
116 | }
117 |
118 | public void setStrAuthor(String strAuthor) {
119 | this.strAuthor = strAuthor;
120 | }
121 |
122 | public String getStrContent() {
123 | return strContent;
124 | }
125 |
126 | public void setStrContent(String strContent) {
127 | this.strContent = strContent;
128 | }
129 |
130 | public String getStrMarketTime() {
131 | return strMarketTime;
132 | }
133 |
134 | public void setStrMarketTime(String strMarketTime) {
135 | this.strMarketTime = strMarketTime;
136 | }
137 |
138 | public String getSWebLk() {
139 | return sWebLk;
140 | }
141 |
142 | public void setSWebLk(String sWebLk) {
143 | this.sWebLk = sWebLk;
144 | }
145 |
146 | public String getStrPn() {
147 | return strPn;
148 | }
149 |
150 | public void setStrPn(String strPn) {
151 | this.strPn = strPn;
152 | }
153 |
154 | public String getWImgUrl() {
155 | return wImgUrl;
156 | }
157 |
158 | public void setWImgUrl(String wImgUrl) {
159 | this.wImgUrl = wImgUrl;
160 | }
161 | }
162 | }
163 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fatchao/rxrequest/callback/Callback.java:
--------------------------------------------------------------------------------
1 | package com.fatchao.rxrequest.callback;
2 |
3 | import android.util.Log;
4 |
5 | public abstract class Callback {
6 |
7 | public abstract void onSuccess(T t);
8 |
9 | public void onError(Throwable e) {
10 | Log.d("net_error---->", e.toString());
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fatchao/rxrequest/constants/Constant.java:
--------------------------------------------------------------------------------
1 | package com.fatchao.rxrequest.constants;
2 |
3 | /**
4 | * Created by fatchao
5 | * 日期 2017-03-31.
6 | * 邮箱 fat_chao@163.com
7 | */
8 | public class Constant {
9 | public static final String USER_PHONE = "phone";
10 | public static final String USER_PASSWORD = "password";
11 | public static String USER_TOKEN = "TOKEN";
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fatchao/rxrequest/constants/RxUrl.java:
--------------------------------------------------------------------------------
1 | package com.fatchao.rxrequest.constants;
2 |
3 | import com.fatchao.rxrequest.bean.LoginBean;
4 | import com.fatchao.rxrequest.bean.OneBean;
5 |
6 | import java.util.Map;
7 |
8 | import retrofit2.http.FieldMap;
9 | import retrofit2.http.FormUrlEncoded;
10 | import retrofit2.http.GET;
11 | import retrofit2.http.POST;
12 | import retrofit2.http.QueryMap;
13 | import rx.Observable;
14 |
15 | /**
16 | * Created by fatchao
17 | * 日期 2017-03-31.
18 | * 邮箱 fat_chao@163.com
19 | */
20 | public interface RxUrl {
21 |
22 | // ------------服务器地址------------------//
23 | String SERVER_ADDRESS = "http://rest.wufazhuce.com/";
24 |
25 | //GET请求
26 | @GET("OneForWeb/one/getHpinfo")
27 | Observable getData(@QueryMap Map map);
28 |
29 |
30 | //POST请求
31 | @FormUrlEncoded
32 | @POST("OneForWeb/one/getHpinfo")
33 | Observable postData(@FieldMap Map map);
34 |
35 |
36 | @FormUrlEncoded //登陆
37 | @POST("server/account/common/login.json")
38 | Observable login(@FieldMap Map map);
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/fatchao/rxrequest/request/ProxyHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 david.wei (lighters)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.fatchao.rxrequest.request;
18 | /**
19 | * Created by fatchao
20 | * 日期 2017-03-31.
21 | * 邮箱 fat_chao@163.com
22 | */
23 | import android.accounts.NetworkErrorException;
24 | import android.support.annotation.NonNull;
25 | import android.text.TextUtils;
26 | import android.util.Log;
27 |
28 | import com.fatchao.rxrequest.BaseApplication;
29 | import com.fatchao.rxrequest.bean.LoginBean;
30 | import com.fatchao.rxrequest.constants.Constant;
31 | import com.fatchao.rxrequest.utils.HintUtils;
32 | import com.fatchao.rxrequest.utils.NetworkManager;
33 | import com.fatchao.rxrequest.utils.PrefUtils;
34 |
35 | import java.lang.annotation.Annotation;
36 | import java.lang.reflect.InvocationHandler;
37 | import java.lang.reflect.InvocationTargetException;
38 | import java.lang.reflect.Method;
39 | import java.util.Date;
40 | import java.util.HashMap;
41 | import java.util.Map;
42 | import java.util.concurrent.TimeUnit;
43 |
44 | import okhttp3.CacheControl;
45 | import retrofit2.adapter.rxjava.HttpException;
46 | import retrofit2.http.FieldMap;
47 | import rx.Observable;
48 | import rx.Subscriber;
49 | import rx.functions.Func1;
50 |
51 |
52 | public class ProxyHandler implements InvocationHandler {
53 | private final static int REFRESH_TOKEN_VALID_TIME = 30;
54 | private static long tokenChangedTime = 0;
55 | private Throwable mRefreshTokenError = null;
56 | private boolean mIsTokenNeedRefresh;
57 | private boolean isCache;
58 |
59 | private Object mProxyObject;
60 | private HashMap hashMap = new HashMap<>();
61 | int cacheTime = 10;
62 | public CacheControl FORCE_CACHE1 = new CacheControl.Builder()
63 | .onlyIfCached()
64 | .maxStale(cacheTime, TimeUnit.SECONDS)//CacheControl.FORCE_CACHE--是int型最大值
65 | .build();
66 |
67 | public ProxyHandler(Object proxyObject, boolean isCache) {
68 | this.isCache = isCache;
69 | hashMap.put("account", PrefUtils.getString(BaseApplication.getContext(), Constant.USER_PHONE, ""));
70 | hashMap.put("client", "app");
71 | hashMap.put("password", PrefUtils.getString(BaseApplication.getContext(), Constant.USER_PASSWORD, ""));
72 | mProxyObject = proxyObject;
73 | }
74 |
75 | @Override
76 | public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
77 | return Observable.just(null).flatMap(new Func1