diff options
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java index fb6280021..e8f35b180 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java @@ -3,6 +3,7 @@ package de.danoeh.antennapod.fragment; import android.content.Context; import android.content.res.TypedArray; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.v4.app.ListFragment; import android.support.v4.view.MenuItemCompat; import android.util.Log; @@ -29,11 +30,12 @@ import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.util.FeedItemUtil; import de.danoeh.antennapod.core.util.LongList; +import de.danoeh.antennapod.view.EmptyViewHandler; import de.greenrobot.event.EventBus; -import rx.Observable; -import rx.Subscription; -import rx.android.schedulers.AndroidSchedulers; -import rx.schedulers.Schedulers; +import io.reactivex.Observable; +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.disposables.Disposable; +import io.reactivex.schedulers.Schedulers; public class PlaybackHistoryFragment extends ListFragment { @@ -50,7 +52,7 @@ public class PlaybackHistoryFragment extends ListFragment { private List<Downloader> downloaderList; - private Subscription subscription; + private Disposable disposable; @Override public void onAttach(Context context) { @@ -81,6 +83,12 @@ public class PlaybackHistoryFragment extends ListFragment { if (itemsLoaded) { onFragmentLoaded(); } + + EmptyViewHandler emptyView = new EmptyViewHandler(getActivity()); + emptyView.setTitle(R.string.no_history_head_label); + emptyView.setMessage(R.string.no_history_label); + emptyView.attachToListView(getListView()); + } @@ -107,16 +115,16 @@ public class PlaybackHistoryFragment extends ListFragment { public void onStop() { super.onStop(); EventDistributor.getInstance().unregister(contentUpdate); - if(subscription != null) { - subscription.unsubscribe(); + if(disposable != null) { + disposable.dispose(); } } @Override public void onDetach() { super.onDetach(); - if(subscription != null) { - subscription.unsubscribe(); + if(disposable != null) { + disposable.dispose(); } } @@ -269,11 +277,11 @@ public class PlaybackHistoryFragment extends ListFragment { }; private void loadItems() { - if(subscription != null) { - subscription.unsubscribe(); + if(disposable != null) { + disposable.dispose(); } - subscription = Observable.fromCallable(this::loadData) - .subscribeOn(Schedulers.newThread()) + disposable = Observable.fromCallable(this::loadData) + .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(result -> { if (result != null) { @@ -286,6 +294,7 @@ public class PlaybackHistoryFragment extends ListFragment { }, error -> Log.e(TAG, Log.getStackTraceString(error))); } + @NonNull private List<FeedItem> loadData() { List<FeedItem> history = DBReader.getPlaybackHistory(); DBReader.loadAdditionalFeedItemListData(history); |