diff --git a/app/src/main/java/com/shunzhi/parent/AppConfig.java b/app/src/main/java/com/shunzhi/parent/AppConfig.java index 8c0cb05..6d15b6f 100644 --- a/app/src/main/java/com/shunzhi/parent/AppConfig.java +++ b/app/src/main/java/com/shunzhi/parent/AppConfig.java @@ -39,17 +39,18 @@ public class AppConfig { public static String APP_IS_START = "app_is_start"; //测试 -// public static String BASE_URL="http://60.190.202.57:1000/"; -// public static String BASE_URL_ORDER="http://60.190.202.57:8101/"; -// public static String BASE_URL_FILE="http://60.190.202.57:8196"; -// public static String BASE_URL_VOTE = "http://60.190.202.57:8812/"; + public static String BASE_URL="http://60.190.202.57:1000/"; + public static String BASE_URL_ORDER="http://60.190.202.57:8101/"; + public static String BASE_URL_FILE="http://60.190.202.57:8196"; + public static String BASE_URL_VOTE = "http://60.190.202.57:8812/"; //正式 - public static String BASE_URL = "http://campus.myjxt.com/"; - public static String BASE_URL_ORDER = "http://parent.myjxt.com/"; - public static String BASE_URL_FILE = "http://manage.myjxt.com"; - public static String BASE_URL_VOTE = "www.sxspy.net/"; +// public static String BASE_URL = "http://campus.myjxt.com/"; +// public static String BASE_URL_ORDER = "http://parent.myjxt.com/"; +// public static String BASE_URL_FILE = "http://manage.myjxt.com"; +// public static String BASE_URL_VOTE = "www.sxspy.net/"; +// public static String BASE_URL_VOTE = "http://www.sxspy.net/"; // public static final String url_version = BASE_URL + "api/Common/AppVersion?appType=3"; diff --git a/app/src/main/java/com/shunzhi/parent/model/consult/ConsultModel.java b/app/src/main/java/com/shunzhi/parent/model/consult/ConsultModel.java index cc98d31..03f70cb 100644 --- a/app/src/main/java/com/shunzhi/parent/model/consult/ConsultModel.java +++ b/app/src/main/java/com/shunzhi/parent/model/consult/ConsultModel.java @@ -49,7 +49,7 @@ public class ConsultModel extends BaseModel implements ConsultContract.IConsultM @Override public Observable loginVote(String phoneNum, String password) { - return RetrofitCreateHelper.getInstance().createApi(Consult.class, AppConfig.BASE_URL_VOTE) + return RetrofitCreateHelper.getInstance().createStringApi(Consult.class, AppConfig.BASE_URL_VOTE) .loginVote(phoneNum,password).compose(RxHelper.rxSchedulerHelper()); // return null; } diff --git a/app/src/main/java/com/shunzhi/parent/presenter/consult/ConsultPresenter.java b/app/src/main/java/com/shunzhi/parent/presenter/consult/ConsultPresenter.java index 6a5890a..0c84578 100644 --- a/app/src/main/java/com/shunzhi/parent/presenter/consult/ConsultPresenter.java +++ b/app/src/main/java/com/shunzhi/parent/presenter/consult/ConsultPresenter.java @@ -137,6 +137,7 @@ public class ConsultPresenter extends ConsultContract.ConsultPresenter { mRxManager.register(mIModel.loginVote(phoneNum, password).subscribe(new Consumer() { @Override public void accept(String str) throws Exception { + Log.e("111111",str.toString()); mIView.showVote(position); } }, new Consumer() { diff --git a/mvpsdk/src/main/java/com/share/mvpsdk/helper/RetrofitCreateHelper.java b/mvpsdk/src/main/java/com/share/mvpsdk/helper/RetrofitCreateHelper.java index d543091..52985a6 100644 --- a/mvpsdk/src/main/java/com/share/mvpsdk/helper/RetrofitCreateHelper.java +++ b/mvpsdk/src/main/java/com/share/mvpsdk/helper/RetrofitCreateHelper.java @@ -90,6 +90,17 @@ public class RetrofitCreateHelper { return retrofit.create(clazz); } + public T createStringApi(Class clazz, String url) { + Authorization = token; + Retrofit retrofit = new Retrofit.Builder() + .baseUrl(url) + .client(okhttpClientBuilder.build()) + .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) + .addConverterFactory(new ToStringConverterFactory()) + .build(); + return retrofit.create(clazz); + } + // public static T loginApi(Class clazz, String url) { // Authorization= StringUtils.getSign(); // okHttpClient.newBuilder().addInterceptor(new Interceptor() { diff --git a/mvpsdk/src/main/java/com/share/mvpsdk/helper/ToStringConverterFactory.java b/mvpsdk/src/main/java/com/share/mvpsdk/helper/ToStringConverterFactory.java new file mode 100644 index 0000000..c1deda2 --- /dev/null +++ b/mvpsdk/src/main/java/com/share/mvpsdk/helper/ToStringConverterFactory.java @@ -0,0 +1,47 @@ +package com.share.mvpsdk.helper; + + +import java.io.IOException; +import java.lang.annotation.Annotation; +import java.lang.reflect.Type; + +import okhttp3.MediaType; +import okhttp3.RequestBody; +import okhttp3.ResponseBody; +import retrofit2.Converter; +import retrofit2.Retrofit; + +/** + * Created by ToaHanDong on 2018/4/24. + */ + +public class ToStringConverterFactory extends Converter.Factory { + + private static final MediaType MEDIA_TYPE = MediaType.parse("text/plain"); + @Override + public Converter responseBodyConverter(Type type, Annotation[] annotations, Retrofit retrofit) { + if (String.class.equals(type)) { + return new Converter() { + @Override + public String convert(ResponseBody value) throws IOException { + return value.string(); + } + }; + } + return null; + } + + @Override public Converter requestBodyConverter(Type type, Annotation[] parameterAnnotations, + Annotation[] methodAnnotations, Retrofit retrofit) { + if (String.class.equals(type)) { + return new Converter() { + @Override + public RequestBody convert(String value) throws IOException { + return RequestBody.create(MEDIA_TYPE, value); + } + }; + } + return null; + } + +} -- libgit2 0.21.0