Commit 03248c7f9b84eda6b65d8750169fdf127f695738
1 parent
1ca28828
Exists in
yxb_dev
and in
1 other branch
no message
Showing
5 changed files
with
69 additions
and
9 deletions
Show diff stats
app/src/main/java/com/shunzhi/parent/AppConfig.java
... | ... | @@ -39,17 +39,18 @@ public class AppConfig { |
39 | 39 | public static String APP_IS_START = "app_is_start"; |
40 | 40 | |
41 | 41 | //测试 |
42 | -// public static String BASE_URL="http://60.190.202.57:1000/"; | |
43 | -// public static String BASE_URL_ORDER="http://60.190.202.57:8101/"; | |
44 | -// public static String BASE_URL_FILE="http://60.190.202.57:8196"; | |
45 | -// public static String BASE_URL_VOTE = "http://60.190.202.57:8812/"; | |
42 | + public static String BASE_URL="http://60.190.202.57:1000/"; | |
43 | + public static String BASE_URL_ORDER="http://60.190.202.57:8101/"; | |
44 | + public static String BASE_URL_FILE="http://60.190.202.57:8196"; | |
45 | + public static String BASE_URL_VOTE = "http://60.190.202.57:8812/"; | |
46 | 46 | |
47 | 47 | |
48 | 48 | //正式 |
49 | - public static String BASE_URL = "http://campus.myjxt.com/"; | |
50 | - public static String BASE_URL_ORDER = "http://parent.myjxt.com/"; | |
51 | - public static String BASE_URL_FILE = "http://manage.myjxt.com"; | |
52 | - public static String BASE_URL_VOTE = "www.sxspy.net/"; | |
49 | +// public static String BASE_URL = "http://campus.myjxt.com/"; | |
50 | +// public static String BASE_URL_ORDER = "http://parent.myjxt.com/"; | |
51 | +// public static String BASE_URL_FILE = "http://manage.myjxt.com"; | |
52 | +// public static String BASE_URL_VOTE = "www.sxspy.net/"; | |
53 | +// public static String BASE_URL_VOTE = "http://www.sxspy.net/"; | |
53 | 54 | // public static final String url_version = BASE_URL + "api/Common/AppVersion?appType=3"; |
54 | 55 | |
55 | 56 | ... | ... |
app/src/main/java/com/shunzhi/parent/model/consult/ConsultModel.java
... | ... | @@ -49,7 +49,7 @@ public class ConsultModel extends BaseModel implements ConsultContract.IConsultM |
49 | 49 | |
50 | 50 | @Override |
51 | 51 | public Observable<String> loginVote(String phoneNum, String password) { |
52 | - return RetrofitCreateHelper.getInstance().createApi(Consult.class, AppConfig.BASE_URL_VOTE) | |
52 | + return RetrofitCreateHelper.getInstance().createStringApi(Consult.class, AppConfig.BASE_URL_VOTE) | |
53 | 53 | .loginVote(phoneNum,password).compose(RxHelper.<String>rxSchedulerHelper()); |
54 | 54 | // return null; |
55 | 55 | } | ... | ... |
app/src/main/java/com/shunzhi/parent/presenter/consult/ConsultPresenter.java
... | ... | @@ -137,6 +137,7 @@ public class ConsultPresenter extends ConsultContract.ConsultPresenter { |
137 | 137 | mRxManager.register(mIModel.loginVote(phoneNum, password).subscribe(new Consumer<String>() { |
138 | 138 | @Override |
139 | 139 | public void accept(String str) throws Exception { |
140 | + Log.e("111111",str.toString()); | |
140 | 141 | mIView.showVote(position); |
141 | 142 | } |
142 | 143 | }, new Consumer<Throwable>() { | ... | ... |
mvpsdk/src/main/java/com/share/mvpsdk/helper/RetrofitCreateHelper.java
... | ... | @@ -90,6 +90,17 @@ public class RetrofitCreateHelper { |
90 | 90 | return retrofit.create(clazz); |
91 | 91 | } |
92 | 92 | |
93 | + public <T> T createStringApi(Class<T> clazz, String url) { | |
94 | + Authorization = token; | |
95 | + Retrofit retrofit = new Retrofit.Builder() | |
96 | + .baseUrl(url) | |
97 | + .client(okhttpClientBuilder.build()) | |
98 | + .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) | |
99 | + .addConverterFactory(new ToStringConverterFactory()) | |
100 | + .build(); | |
101 | + return retrofit.create(clazz); | |
102 | + } | |
103 | + | |
93 | 104 | // public static <T> T loginApi(Class<T> clazz, String url) { |
94 | 105 | // Authorization= StringUtils.getSign(); |
95 | 106 | // okHttpClient.newBuilder().addInterceptor(new Interceptor() { | ... | ... |
mvpsdk/src/main/java/com/share/mvpsdk/helper/ToStringConverterFactory.java
0 → 100644
... | ... | @@ -0,0 +1,47 @@ |
1 | +package com.share.mvpsdk.helper; | |
2 | + | |
3 | + | |
4 | +import java.io.IOException; | |
5 | +import java.lang.annotation.Annotation; | |
6 | +import java.lang.reflect.Type; | |
7 | + | |
8 | +import okhttp3.MediaType; | |
9 | +import okhttp3.RequestBody; | |
10 | +import okhttp3.ResponseBody; | |
11 | +import retrofit2.Converter; | |
12 | +import retrofit2.Retrofit; | |
13 | + | |
14 | +/** | |
15 | + * Created by ToaHanDong on 2018/4/24. | |
16 | + */ | |
17 | + | |
18 | +public class ToStringConverterFactory extends Converter.Factory { | |
19 | + | |
20 | + private static final MediaType MEDIA_TYPE = MediaType.parse("text/plain"); | |
21 | + @Override | |
22 | + public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations, Retrofit retrofit) { | |
23 | + if (String.class.equals(type)) { | |
24 | + return new Converter<ResponseBody, String>() { | |
25 | + @Override | |
26 | + public String convert(ResponseBody value) throws IOException { | |
27 | + return value.string(); | |
28 | + } | |
29 | + }; | |
30 | + } | |
31 | + return null; | |
32 | + } | |
33 | + | |
34 | + @Override public Converter<?, RequestBody> requestBodyConverter(Type type, Annotation[] parameterAnnotations, | |
35 | + Annotation[] methodAnnotations, Retrofit retrofit) { | |
36 | + if (String.class.equals(type)) { | |
37 | + return new Converter<String, RequestBody>() { | |
38 | + @Override | |
39 | + public RequestBody convert(String value) throws IOException { | |
40 | + return RequestBody.create(MEDIA_TYPE, value); | |
41 | + } | |
42 | + }; | |
43 | + } | |
44 | + return null; | |
45 | + } | |
46 | + | |
47 | +} | ... | ... |