Search in sources :

Example 1 with DisposableSubscriber

use of io.reactivex.subscribers.DisposableSubscriber in project RxJava-Android-Samples by kaushikgopal.

the class VolleyDemoFragment method startVolleyRequest.

private void startVolleyRequest() {
    DisposableSubscriber<JSONObject> d = new DisposableSubscriber<JSONObject>() {

        @Override
        public void onNext(JSONObject jsonObject) {
            Log.e(TAG, "onNext " + jsonObject.toString());
            _log("onNext " + jsonObject.toString());
        }

        @Override
        public void onError(Throwable e) {
            VolleyError cause = (VolleyError) e.getCause();
            String s = new String(cause.networkResponse.data, Charset.forName("UTF-8"));
            Log.e(TAG, s);
            Log.e(TAG, cause.toString());
            _log("onError " + s);
        }

        @Override
        public void onComplete() {
            Log.e(TAG, "onCompleted");
            Timber.d("----- onCompleted");
            _log("onCompleted ");
        }
    };
    newGetRouteData().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(d);
    _disposables.add(d);
}
Also used : VolleyError(com.android.volley.VolleyError) JSONObject(org.json.JSONObject) DisposableSubscriber(io.reactivex.subscribers.DisposableSubscriber)

Aggregations

VolleyError (com.android.volley.VolleyError)1 DisposableSubscriber (io.reactivex.subscribers.DisposableSubscriber)1 JSONObject (org.json.JSONObject)1