Avoid error delivery to disposed Disposable
This commit is contained in:
parent
c98a7c0c38
commit
382860d65e
|
@ -5,6 +5,7 @@ import android.os.Bundle;
|
|||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.widget.SearchView;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
|
@ -106,7 +107,7 @@ public class ItunesSearchFragment extends Fragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View root = inflater.inflate(R.layout.fragment_itunes_search, container, false);
|
||||
|
@ -146,8 +147,10 @@ public class ItunesSearchFragment extends Fragment {
|
|||
emitter.onError(new IOException(prefix + response));
|
||||
}
|
||||
} catch (IOException | JSONException e) {
|
||||
if (!disposable.isDisposed()) {
|
||||
emitter.onError(e);
|
||||
}
|
||||
}
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
@ -249,8 +252,10 @@ public class ItunesSearchFragment extends Fragment {
|
|||
List<Podcast> podcasts = parseFeed(feedString);
|
||||
emitter.onSuccess(podcasts);
|
||||
} catch (IOException | JSONException e) {
|
||||
if (!disposable.isDisposed()) {
|
||||
emitter.onError(e);
|
||||
}
|
||||
}
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
|
Loading…
Reference in New Issue