我使用Retrofit2创建@GET
响应,但onNext()
,onError()
和onComplete()
不起作用。
retrofit = new Retrofit.Builder().baseUrl("https://gist.githubusercontent.com/MaxWBB/747f2eca800e05861bebc8f02ddb2721/raw/65673cae770b9b1fe8a668466868f1378e061f0d/").
addConverterFactory(GsonConverterFactory.create()).addCallAdapterFactory(RxJava2CallAdapterFactory.create()).build();
serverApi = retrofit.create(ServerApi.class);
serverApi.getDatas().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new DisposableObserver<List<Client>>() {
@Override
public void onNext(List<Client> clients) {
tv1.setText(String.valueOf(clients.size()));
Log.d("getData()","Works");
}
@Override
public void onError(Throwable e){
Log.d("OnError()","error:"+String.valueOf(e));
}
@Override
public void onComplete() {
}
});