Skip to content

Commit

Permalink
Retrofit返回值错误采用不同的Toast
Browse files Browse the repository at this point in the history
  • Loading branch information
fly803 committed Aug 7, 2018
1 parent 6b10426 commit 0d4f5ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ public void onNext(AirForecast airForecast) {
}
}, this));*/
RequestBusiness.getInstance().toSubscribe(RequestBusiness.getInstance().getAPI().psalms(3),
new ProgressSubscriber<BaseResponse<String>>(new SubscriberOnNextListener<String>() {
new ProgressSubscriber<BaseResponse<DataBean>>(new SubscriberOnNextListener<DataBean>() {
@Override
public void onNext(String envProportion) {
// Log.d("cg", "MainActivity onNext: "+envProportion.toString());
// Snackbar.make(mRvDataIndex, "getEnvProportion:" + envProportion.toString(), Snackbar.LENGTH_SHORT).show();
public void onNext(DataBean envProportion) {
Log.d("cg", "MainActivity onNext: "+envProportion.toString());
Snackbar.make(mRvDataIndex, "getEnvProportion:" + envProportion.toString(), Snackbar.LENGTH_SHORT).show();
}
}, this));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import com.cg.baseproject.configs.BaseProjectConfig;
import com.cg.baseproject.request.data.BaseResponse;
import com.cg.baseproject.request.data.JsonFormatParser;
import com.cg.baseproject.request.retrofit.factory.FastJsonConverterFactory;
import com.cg.baseproject.request.retrofit.factory.MyGsonConverterFactory;
import com.cg.baseproject.request.retrofit.factory.MyStringConverterFactory;
import com.cg.baseproject.request.retrofit.interceptor.BaseUrlInterceptor;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
Expand Down Expand Up @@ -73,8 +75,10 @@ public Retrofit getRetrofit() {
private void initRetrofit() {
mRetrofit = new Retrofit.Builder()
.baseUrl(BaseProjectConfig.BASE_URL)//配置服务器路径
// .addConverterFactory(MyStringConverterFactory.create())//配置转化库,String
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(MyGsonConverterFactory.create())//配置转化库 字符串类型 的
// .addConverterFactory(FastJsonConverterFactory.create())//配置转化库,FastJson
.addConverterFactory(MyGsonConverterFactory.create())//配置转化库,Gson
// 配置转化库,默认是Gson(返回参数不规范 要不然可以直接转换成实体类)
//配置回调库,采用RxJava
//设置OKHttpClient为网络客户端
Expand Down

0 comments on commit 0d4f5ea

Please sign in to comment.