summaryrefslogtreecommitdiff
path: root/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java')
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java46
1 files changed, 31 insertions, 15 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java
index ae9c60f65..973772049 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java
@@ -12,21 +12,23 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListView;
+import android.widget.TextView;
import java.util.List;
-import android.widget.TextView;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.adapter.DownloadLogAdapter;
import de.danoeh.antennapod.core.feed.EventDistributor;
+import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.feed.FeedMedia;
import de.danoeh.antennapod.core.service.download.DownloadStatus;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBWriter;
-import rx.Observable;
-import rx.Subscription;
-import rx.android.schedulers.AndroidSchedulers;
-import rx.schedulers.Schedulers;
+import de.danoeh.antennapod.view.EmptyViewHandler;
+import io.reactivex.Observable;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.disposables.Disposable;
+import io.reactivex.schedulers.Schedulers;
/**
* Shows the download log
@@ -41,7 +43,7 @@ public class DownloadLogFragment extends ListFragment {
private boolean viewsCreated = false;
private boolean itemsLoaded = false;
- private Subscription subscription;
+ private Disposable disposable;
@Override
public void onStart() {
@@ -55,8 +57,8 @@ public class DownloadLogFragment extends ListFragment {
public void onStop() {
super.onStop();
EventDistributor.getInstance().unregister(contentUpdate);
- if(subscription != null) {
- subscription.unsubscribe();
+ if(disposable != null) {
+ disposable.dispose();
}
}
@@ -74,6 +76,12 @@ public class DownloadLogFragment extends ListFragment {
if (itemsLoaded) {
onFragmentLoaded();
}
+
+ EmptyViewHandler emptyView = new EmptyViewHandler(getActivity());
+ emptyView.setTitle(R.string.no_log_downloads_head_label);
+ emptyView.setMessage(R.string.no_log_downloads_label);
+ emptyView.attachToListView(getListView());
+
}
private void onFragmentLoaded() {
@@ -93,10 +101,18 @@ public class DownloadLogFragment extends ListFragment {
DownloadStatus status = adapter.getItem(position);
String url = "unknown";
String message = getString(R.string.download_successful);
- FeedMedia media = DBReader.getFeedMedia(status.getFeedfileId());
- if (media != null) {
- url = media.getDownload_url();
+ if (status.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA) {
+ FeedMedia media = DBReader.getFeedMedia(status.getFeedfileId());
+ if (media != null) {
+ url = media.getDownload_url();
+ }
+ } else if (status.getFeedfileType() == Feed.FEEDFILETYPE_FEED) {
+ Feed feed = DBReader.getFeed(status.getFeedfileId());
+ if (feed != null) {
+ url = feed.getDownload_url();
+ }
}
+
if (!status.isSuccessful()) {
message = status.getReasonDetailed();
}
@@ -178,11 +194,11 @@ public class DownloadLogFragment extends ListFragment {
}
private void loadItems() {
- if(subscription != null) {
- subscription.unsubscribe();
+ if(disposable != null) {
+ disposable.dispose();
}
- subscription = Observable.fromCallable(DBReader::getDownloadLog)
- .subscribeOn(Schedulers.newThread())
+ disposable = Observable.fromCallable(DBReader::getDownloadLog)
+ .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(result -> {
if (result != null) {