summaryrefslogtreecommitdiff
path: root/src/de/danoeh/antennapod/adapter
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2014-07-26 14:42:59 +0200
committerdaniel oeh <daniel.oeh@gmail.com>2014-07-26 14:42:59 +0200
commit583b2adaae5769fb8bee4d63e4ef10846d7de1b6 (patch)
tree2dfe8481d75fc7a68cee495c3e91bce0a4e5b0c0 /src/de/danoeh/antennapod/adapter
parent1673f6eaf83606a78ce3928b2d7c33d4ff0de862 (diff)
parent460e061d35e45268d3dcfebeba00e7231ce8cfd0 (diff)
downloadAntennaPod-583b2adaae5769fb8bee4d63e4ef10846d7de1b6.zip
Merge branch 'develop'0.9.9.2
Conflicts: submodules/dslv
Diffstat (limited to 'src/de/danoeh/antennapod/adapter')
-rw-r--r--src/de/danoeh/antennapod/adapter/ActionButtonUtils.java21
-rw-r--r--src/de/danoeh/antennapod/adapter/ChapterListAdapter.java2
-rw-r--r--src/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java44
-rw-r--r--src/de/danoeh/antennapod/adapter/DownloadLogAdapter.java2
-rw-r--r--src/de/danoeh/antennapod/adapter/DownloadedEpisodesListAdapter.java2
-rw-r--r--src/de/danoeh/antennapod/adapter/DownloadlistAdapter.java2
-rw-r--r--src/de/danoeh/antennapod/adapter/ExternalEpisodesListAdapter.java4
-rw-r--r--src/de/danoeh/antennapod/adapter/FeedItemlistAdapter.java2
-rw-r--r--src/de/danoeh/antennapod/adapter/FeedItemlistDescriptionAdapter.java4
-rw-r--r--src/de/danoeh/antennapod/adapter/NavListAdapter.java6
-rw-r--r--src/de/danoeh/antennapod/adapter/NewEpisodesListAdapter.java2
-rw-r--r--src/de/danoeh/antennapod/adapter/QueueListAdapter.java2
-rw-r--r--src/de/danoeh/antennapod/adapter/SearchlistAdapter.java2
-rw-r--r--src/de/danoeh/antennapod/adapter/gpodnet/PodcastListAdapter.java2
14 files changed, 58 insertions, 39 deletions
diff --git a/src/de/danoeh/antennapod/adapter/ActionButtonUtils.java b/src/de/danoeh/antennapod/adapter/ActionButtonUtils.java
index 17c61a86c..1de071a73 100644
--- a/src/de/danoeh/antennapod/adapter/ActionButtonUtils.java
+++ b/src/de/danoeh/antennapod/adapter/ActionButtonUtils.java
@@ -4,6 +4,9 @@ import android.content.Context;
import android.content.res.TypedArray;
import android.view.View;
import android.widget.ImageButton;
+
+import org.apache.commons.lang3.Validate;
+
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.feed.FeedItem;
import de.danoeh.antennapod.feed.FeedMedia;
@@ -20,11 +23,12 @@ public class ActionButtonUtils {
private final Context context;
public ActionButtonUtils(Context context) {
- if (context == null) throw new IllegalArgumentException("context = null");
+ Validate.notNull(context);
+
this.context = context;
drawables = context.obtainStyledAttributes(new int[]{
- R.attr.av_play, R.attr.navigation_cancel, R.attr.av_download, R.attr.navigation_chapters});
- labels = new int[]{R.string.play_label, R.string.cancel_download_label, R.string.download_label};
+ R.attr.av_play, R.attr.navigation_cancel, R.attr.av_download, R.attr.navigation_chapters, R.attr.navigation_accept});
+ labels = new int[]{R.string.play_label, R.string.cancel_download_label, R.string.download_label, R.string.mark_read_label};
}
/**
@@ -32,7 +36,8 @@ public class ActionButtonUtils {
* action button so that it matches the state of the FeedItem.
*/
public void configureActionButton(ImageButton butSecondary, FeedItem item) {
- if (butSecondary == null || item == null) throw new IllegalArgumentException("butSecondary or item was null");
+ Validate.isTrue(butSecondary != null && item != null, "butSecondary or item was null");
+
final FeedMedia media = item.getMedia();
if (media != null) {
final boolean isDownloadingMedia = DownloadRequester.getInstance().isDownloadingFile(media);
@@ -61,7 +66,13 @@ public class ActionButtonUtils {
butSecondary.setContentDescription(context.getString(labels[0]));
}
} else {
- butSecondary.setVisibility(View.INVISIBLE);
+ if (item.isRead()) {
+ butSecondary.setVisibility(View.INVISIBLE);
+ } else {
+ butSecondary.setVisibility(View.VISIBLE);
+ butSecondary.setImageDrawable(drawables.getDrawable(4));
+ butSecondary.setContentDescription(context.getString(labels[3]));
+ }
}
}
}
diff --git a/src/de/danoeh/antennapod/adapter/ChapterListAdapter.java b/src/de/danoeh/antennapod/adapter/ChapterListAdapter.java
index 72ad6774f..c12de6ebd 100644
--- a/src/de/danoeh/antennapod/adapter/ChapterListAdapter.java
+++ b/src/de/danoeh/antennapod/adapter/ChapterListAdapter.java
@@ -51,7 +51,7 @@ public class ChapterListAdapter extends ArrayAdapter<Chapter> {
LayoutInflater inflater = (LayoutInflater) getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- convertView = inflater.inflate(R.layout.simplechapter_item, null);
+ convertView = inflater.inflate(R.layout.simplechapter_item, parent, false);
holder.title = (TextView) convertView.findViewById(R.id.txtvTitle);
defaultTextColor = holder.title.getTextColors().getDefaultColor();
holder.start = (TextView) convertView.findViewById(R.id.txtvStart);
diff --git a/src/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java b/src/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java
index 3acd587af..0c4cbe685 100644
--- a/src/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java
+++ b/src/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java
@@ -2,11 +2,15 @@ package de.danoeh.antennapod.adapter;
import android.content.Context;
import android.widget.Toast;
+
+import org.apache.commons.lang3.Validate;
+
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.dialog.DownloadRequestErrorDialogCreator;
import de.danoeh.antennapod.feed.FeedItem;
import de.danoeh.antennapod.feed.FeedMedia;
import de.danoeh.antennapod.storage.DBTasks;
+import de.danoeh.antennapod.storage.DBWriter;
import de.danoeh.antennapod.storage.DownloadRequestException;
import de.danoeh.antennapod.storage.DownloadRequester;
@@ -19,31 +23,35 @@ public class DefaultActionButtonCallback implements ActionButtonCallback {
private final Context context;
public DefaultActionButtonCallback(Context context) {
- if (context == null) throw new IllegalArgumentException("context = null");
+ Validate.notNull(context);
this.context = context;
}
@Override
public void onActionButtonPressed(final FeedItem item) {
- final FeedMedia media = item.getMedia();
- if (media == null) {
- return;
- }
- boolean isDownloading = DownloadRequester.getInstance().isDownloadingFile(media);
- if (!isDownloading && !media.isDownloaded()) {
- try {
- DBTasks.downloadFeedItems(context, item);
- Toast.makeText(context, R.string.status_downloading_label, Toast.LENGTH_SHORT).show();
- } catch (DownloadRequestException e) {
- e.printStackTrace();
- DownloadRequestErrorDialogCreator.newRequestErrorDialog(context, e.getMessage());
+
+ if (item.hasMedia()) {
+ final FeedMedia media = item.getMedia();
+ boolean isDownloading = DownloadRequester.getInstance().isDownloadingFile(media);
+ if (!isDownloading && !media.isDownloaded()) {
+ try {
+ DBTasks.downloadFeedItems(context, item);
+ Toast.makeText(context, R.string.status_downloading_label, Toast.LENGTH_SHORT).show();
+ } catch (DownloadRequestException e) {
+ e.printStackTrace();
+ DownloadRequestErrorDialogCreator.newRequestErrorDialog(context, e.getMessage());
+ }
+ } else if (isDownloading) {
+ DownloadRequester.getInstance().cancelDownload(context, media);
+ Toast.makeText(context, R.string.download_cancelled_msg, Toast.LENGTH_SHORT).show();
+ } else { // media is downloaded
+ DBTasks.playMedia(context, media, true, true, false);
+ }
+ } else {
+ if (!item.isRead()) {
+ DBWriter.markItemRead(context, item, true, true);
}
- } else if (isDownloading) {
- DownloadRequester.getInstance().cancelDownload(context, media);
- Toast.makeText(context, R.string.download_cancelled_msg, Toast.LENGTH_SHORT).show();
- } else { // media is downloaded
- DBTasks.playMedia(context, media, true, true, false);
}
}
}
diff --git a/src/de/danoeh/antennapod/adapter/DownloadLogAdapter.java b/src/de/danoeh/antennapod/adapter/DownloadLogAdapter.java
index e97d69494..2cc216227 100644
--- a/src/de/danoeh/antennapod/adapter/DownloadLogAdapter.java
+++ b/src/de/danoeh/antennapod/adapter/DownloadLogAdapter.java
@@ -34,7 +34,7 @@ public class DownloadLogAdapter extends BaseAdapter {
holder = new Holder();
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- convertView = inflater.inflate(R.layout.downloadlog_item, null);
+ convertView = inflater.inflate(R.layout.downloadlog_item, parent, false);
holder.title = (TextView) convertView.findViewById(R.id.txtvTitle);
holder.type = (TextView) convertView.findViewById(R.id.txtvType);
holder.date = (TextView) convertView.findViewById(R.id.txtvDate);
diff --git a/src/de/danoeh/antennapod/adapter/DownloadedEpisodesListAdapter.java b/src/de/danoeh/antennapod/adapter/DownloadedEpisodesListAdapter.java
index 0bf770df2..33b11774f 100644
--- a/src/de/danoeh/antennapod/adapter/DownloadedEpisodesListAdapter.java
+++ b/src/de/danoeh/antennapod/adapter/DownloadedEpisodesListAdapter.java
@@ -54,7 +54,7 @@ public class DownloadedEpisodesListAdapter extends BaseAdapter {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.downloaded_episodeslist_item,
- null);
+ parent, false);
holder.title = (TextView) convertView.findViewById(R.id.txtvTitle);
holder.pubDate = (TextView) convertView
.findViewById(R.id.txtvPublished);
diff --git a/src/de/danoeh/antennapod/adapter/DownloadlistAdapter.java b/src/de/danoeh/antennapod/adapter/DownloadlistAdapter.java
index fa2e5a0a7..658af9e4e 100644
--- a/src/de/danoeh/antennapod/adapter/DownloadlistAdapter.java
+++ b/src/de/danoeh/antennapod/adapter/DownloadlistAdapter.java
@@ -56,7 +56,7 @@ public class DownloadlistAdapter extends BaseAdapter {
holder = new Holder();
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- convertView = inflater.inflate(R.layout.downloadlist_item, null);
+ convertView = inflater.inflate(R.layout.downloadlist_item, parent, false);
holder.title = (TextView) convertView.findViewById(R.id.txtvTitle);
holder.message = (TextView) convertView
.findViewById(R.id.txtvMessage);
diff --git a/src/de/danoeh/antennapod/adapter/ExternalEpisodesListAdapter.java b/src/de/danoeh/antennapod/adapter/ExternalEpisodesListAdapter.java
index 9a7b607aa..5e857c131 100644
--- a/src/de/danoeh/antennapod/adapter/ExternalEpisodesListAdapter.java
+++ b/src/de/danoeh/antennapod/adapter/ExternalEpisodesListAdapter.java
@@ -72,7 +72,7 @@ public class ExternalEpisodesListAdapter extends BaseExpandableListAdapter {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.external_itemlist_item,
- null);
+ parent, false);
holder.title = (TextView) convertView.findViewById(R.id.txtvTitle);
holder.feedTitle = (TextView) convertView
.findViewById(R.id.txtvFeedname);
@@ -225,7 +225,7 @@ public class ExternalEpisodesListAdapter extends BaseExpandableListAdapter {
View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- convertView = inflater.inflate(R.layout.feeditemlist_header, null);
+ convertView = inflater.inflate(R.layout.feeditemlist_header, parent, false);
TextView headerTitle = (TextView) convertView
.findViewById(0);
ImageButton actionButton = (ImageButton) convertView
diff --git a/src/de/danoeh/antennapod/adapter/FeedItemlistAdapter.java b/src/de/danoeh/antennapod/adapter/FeedItemlistAdapter.java
index c4a16d4db..357b5f8b4 100644
--- a/src/de/danoeh/antennapod/adapter/FeedItemlistAdapter.java
+++ b/src/de/danoeh/antennapod/adapter/FeedItemlistAdapter.java
@@ -67,7 +67,7 @@ public class FeedItemlistAdapter extends BaseAdapter {
holder = new Holder();
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- convertView = inflater.inflate(R.layout.feeditemlist_item, null);
+ convertView = inflater.inflate(R.layout.feeditemlist_item, parent, false);
holder.title = (TextView) convertView
.findViewById(R.id.txtvItemname);
holder.lenSize = (TextView) convertView
diff --git a/src/de/danoeh/antennapod/adapter/FeedItemlistDescriptionAdapter.java b/src/de/danoeh/antennapod/adapter/FeedItemlistDescriptionAdapter.java
index 5fb204b26..c2c2285ac 100644
--- a/src/de/danoeh/antennapod/adapter/FeedItemlistDescriptionAdapter.java
+++ b/src/de/danoeh/antennapod/adapter/FeedItemlistDescriptionAdapter.java
@@ -12,7 +12,7 @@ import de.danoeh.antennapod.feed.FeedItem;
import java.util.List;
/**
- * Created by daniel on 24.08.13.
+ * List adapter for showing a list of FeedItems with their title and description.
*/
public class FeedItemlistDescriptionAdapter extends ArrayAdapter<FeedItem> {
@@ -31,7 +31,7 @@ public class FeedItemlistDescriptionAdapter extends ArrayAdapter<FeedItem> {
holder = new Holder();
LayoutInflater inflater = (LayoutInflater) getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- convertView = inflater.inflate(R.layout.itemdescription_listitem, null);
+ convertView = inflater.inflate(R.layout.itemdescription_listitem, parent, false);
holder.title = (TextView) convertView.findViewById(R.id.txtvTitle);
holder.description = (TextView) convertView.findViewById(R.id.txtvDescription);
diff --git a/src/de/danoeh/antennapod/adapter/NavListAdapter.java b/src/de/danoeh/antennapod/adapter/NavListAdapter.java
index 536bf80e3..9676372fb 100644
--- a/src/de/danoeh/antennapod/adapter/NavListAdapter.java
+++ b/src/de/danoeh/antennapod/adapter/NavListAdapter.java
@@ -110,7 +110,7 @@ public class NavListAdapter extends BaseAdapter {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- convertView = inflater.inflate(R.layout.nav_listitem, null);
+ convertView = inflater.inflate(R.layout.nav_listitem, parent, false);
holder.title = (TextView) convertView.findViewById(R.id.txtvTitle);
holder.count = (TextView) convertView.findViewById(R.id.txtvCount);
@@ -154,7 +154,7 @@ public class NavListAdapter extends BaseAdapter {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- convertView = inflater.inflate(R.layout.nav_section_item, null);
+ convertView = inflater.inflate(R.layout.nav_section_item, parent, false);
holder.title = (TextView) convertView.findViewById(R.id.txtvTitle);
convertView.setTag(holder);
@@ -179,7 +179,7 @@ public class NavListAdapter extends BaseAdapter {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- convertView = inflater.inflate(R.layout.nav_feedlistitem, null);
+ convertView = inflater.inflate(R.layout.nav_feedlistitem, parent, false);
holder.title = (TextView) convertView.findViewById(R.id.txtvTitle);
holder.image = (ImageView) convertView.findViewById(R.id.imgvCover);
diff --git a/src/de/danoeh/antennapod/adapter/NewEpisodesListAdapter.java b/src/de/danoeh/antennapod/adapter/NewEpisodesListAdapter.java
index 555a334f6..07fd3e6b1 100644
--- a/src/de/danoeh/antennapod/adapter/NewEpisodesListAdapter.java
+++ b/src/de/danoeh/antennapod/adapter/NewEpisodesListAdapter.java
@@ -62,7 +62,7 @@ public class NewEpisodesListAdapter extends BaseAdapter {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.new_episodes_listitem,
- null);
+ parent, false);
holder.title = (TextView) convertView.findViewById(R.id.txtvTitle);
holder.pubDate = (TextView) convertView
.findViewById(R.id.txtvPublished);
diff --git a/src/de/danoeh/antennapod/adapter/QueueListAdapter.java b/src/de/danoeh/antennapod/adapter/QueueListAdapter.java
index ecce1b473..f671ba5c6 100644
--- a/src/de/danoeh/antennapod/adapter/QueueListAdapter.java
+++ b/src/de/danoeh/antennapod/adapter/QueueListAdapter.java
@@ -57,7 +57,7 @@ public class QueueListAdapter extends BaseAdapter {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.queue_listitem,
- null);
+ parent, false);
holder.title = (TextView) convertView.findViewById(R.id.txtvTitle);
holder.butSecondary = (ImageButton) convertView
.findViewById(R.id.butSecondaryAction);
diff --git a/src/de/danoeh/antennapod/adapter/SearchlistAdapter.java b/src/de/danoeh/antennapod/adapter/SearchlistAdapter.java
index 5c6af3943..ecfbb4660 100644
--- a/src/de/danoeh/antennapod/adapter/SearchlistAdapter.java
+++ b/src/de/danoeh/antennapod/adapter/SearchlistAdapter.java
@@ -55,7 +55,7 @@ public class SearchlistAdapter extends BaseAdapter {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- convertView = inflater.inflate(R.layout.searchlist_item, null);
+ convertView = inflater.inflate(R.layout.searchlist_item, parent, false);
holder.title = (TextView) convertView.findViewById(R.id.txtvTitle);
holder.cover = (ImageView) convertView
.findViewById(R.id.imgvFeedimage);
diff --git a/src/de/danoeh/antennapod/adapter/gpodnet/PodcastListAdapter.java b/src/de/danoeh/antennapod/adapter/gpodnet/PodcastListAdapter.java
index 795b17917..f20232a6f 100644
--- a/src/de/danoeh/antennapod/adapter/gpodnet/PodcastListAdapter.java
+++ b/src/de/danoeh/antennapod/adapter/gpodnet/PodcastListAdapter.java
@@ -38,7 +38,7 @@ public class PodcastListAdapter extends ArrayAdapter<GpodnetPodcast> {
LayoutInflater inflater = (LayoutInflater) getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- convertView = inflater.inflate(R.layout.gpodnet_podcast_listitem, null);
+ convertView = inflater.inflate(R.layout.gpodnet_podcast_listitem, parent, false);
holder.title = (TextView) convertView.findViewById(R.id.txtvTitle);
holder.description = (TextView) convertView.findViewById(R.id.txtvDescription);
holder.image = (ImageView) convertView.findViewById(R.id.imgvCover);