//View层注入
@Inject
IMVP.IMainPresenter mPresenter;// 声明接口
DaggerMainConponent// 注入
.create()
.inject(this);
//Presenter层注入
@Inject
IMVP.IMainView mView;// 声明接口
@Inject
IMVP.IMainModule mModule;// 声明接口
DaggerMainConponent// 注入
.create()
.inject(this);
{ "Data": [ { "ParkId": 1, "ParkName": "sample string 2", "ParkCode": "sample string 3" }, null ], "Code": 0, "Message": "sample string 1", "Success": true }
ApiClient.getApiService(ApiService.MainService.class)
.getInfo("北京")
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new ProgressSubscriber<>(mView.getContext(), new SubscriberOnNextListener<String>() {
@Override
public void onNext(String s) {
}
}));
ApiClient.getApiService(ApiService.MainService.class)
.getInfo("北京")
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new ComSubscriber<>(mView.getContext(), new SubscriberOnNextListener<String>() {
@Override
public void onNext(String s) {
}
},null));
@Override
public void catchException(Throwable e) {
if (e instanceof SocketTimeoutException) {
//"网络中断,请检查您的网络状态"
} else if (e instanceof SocketException || e instanceof UnknownHostException) {
//"网络中断,请检查您的网络状态"
Toast.makeText(mContext, mContext.getString(R.string.no_network), Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(mContext, "error:" + e.getMessage(), Toast.LENGTH_SHORT).show();
final String erroLog = getErroLog(e);
Log.e(TAG,erroLog);
}
}
```