diff --git a/app/src/main/java/com/morihacky/android/rxjava/pagination/PaginationAutoFragment.java b/app/src/main/java/com/morihacky/android/rxjava/pagination/PaginationAutoFragment.java index e90d923b..c8b8c91e 100644 --- a/app/src/main/java/com/morihacky/android/rxjava/pagination/PaginationAutoFragment.java +++ b/app/src/main/java/com/morihacky/android/rxjava/pagination/PaginationAutoFragment.java @@ -8,20 +8,23 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ProgressBar; -import butterknife.BindView; -import butterknife.ButterKnife; + import com.morihacky.android.rxjava.MainActivity; import com.morihacky.android.rxjava.R; import com.morihacky.android.rxjava.fragments.BaseFragment; import com.morihacky.android.rxjava.rxbus.RxBus; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import butterknife.BindView; +import butterknife.ButterKnife; import io.reactivex.Flowable; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.CompositeDisposable; import io.reactivex.disposables.Disposable; import io.reactivex.processors.PublishProcessor; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; public class PaginationAutoFragment extends BaseFragment { @@ -109,7 +112,7 @@ public void onStart() { _disposables.add(d1); _disposables.add(d2); - _paginator.onNext(0); + _paginator.onNext(_adapter.getItemCount()); } @Override diff --git a/app/src/main/java/com/morihacky/android/rxjava/volley/VolleyDemoFragment.java b/app/src/main/java/com/morihacky/android/rxjava/volley/VolleyDemoFragment.java index aaa55d08..8392e27d 100644 --- a/app/src/main/java/com/morihacky/android/rxjava/volley/VolleyDemoFragment.java +++ b/app/src/main/java/com/morihacky/android/rxjava/volley/VolleyDemoFragment.java @@ -9,9 +9,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ListView; -import butterknife.BindView; -import butterknife.ButterKnife; -import butterknife.OnClick; + import com.android.volley.Request; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; @@ -20,17 +18,22 @@ import com.morihacky.android.rxjava.fragments.BaseFragment; import com.morihacky.android.rxjava.wiring.LogAdapter; +import org.json.JSONObject; + +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +import butterknife.BindView; +import butterknife.ButterKnife; +import butterknife.OnClick; import butterknife.Unbinder; import io.reactivex.Flowable; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.CompositeDisposable; import io.reactivex.schedulers.Schedulers; import io.reactivex.subscribers.DisposableSubscriber; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutionException; -import org.json.JSONObject; import timber.log.Timber; public class VolleyDemoFragment extends BaseFragment { @@ -108,10 +111,12 @@ public void onNext(JSONObject jsonObject) { @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); + if (cause.networkResponse != null) { + String s = new String(cause.networkResponse.data, Charset.forName("UTF-8")); + Log.e(TAG, s); + _log("onError " + s); + } } @Override