当call()方法编译时,它不会设置Endpoint url并抛出NP Exception
public Observable<ResultPojo> call() {
final ResultPojo resultPojo;
try {
resultPojo = buildRestAdapter().registerSubDistributor
(subDistributorDetailModel.getRoleType(),
subDistributorDetailModel.getPassword(),
subDistributorDetailModel.getUserName(),
subDistributorDetailModel.getMobileNumber(),
subDistributorDetailModel.getAddress(),
subDistributorDetailModel.getFirmName(),
subDistributorDetailModel.getAge(),
subDistributorDetailModel.getFathersName());
} catch (Exception e) {
throw OnErrorThrowable.from(e);
}
return Observable.just(resultPojo);
}
});
}
“构建RestAdapter的方法,它返回apiManager对象”
private static SubDistributorApiManager buildRestAdapter(){
Builder builder = new Builder()
.setEndpoint(SubDistributorApiManager.BASE_URL);
RestAdapter restAdapter = builder.build();
SubDistributorApiManager apiManager = restAdapter.create(SubDistributorApiManager.class);
return apiManager;
}