summaryrefslogtreecommitdiff
path: root/src/de/podfetcher
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2012-06-24 14:41:22 +0200
committerdaniel oeh <daniel.oeh@gmail.com>2012-06-24 14:41:22 +0200
commita63e975d87bd19e5a202cdf6813071b81f8c6ccc (patch)
treedfe3ca8dd11cdfce854ba1a780852f81338ac038 /src/de/podfetcher
parent7cd38e53a7d9a3febb11a4476d13af3bc8d381c0 (diff)
downloadAntennaPod-a63e975d87bd19e5a202cdf6813071b81f8c6ccc.zip
Added support for itunes:image tag, bugfixes
Diffstat (limited to 'src/de/podfetcher')
-rw-r--r--src/de/podfetcher/activity/ItemviewActivity.java10
-rw-r--r--src/de/podfetcher/adapter/FeedItemlistAdapter.java1
-rw-r--r--src/de/podfetcher/syndication/handler/SyndHandler.java7
-rw-r--r--src/de/podfetcher/syndication/namespace/itunes/NSITunes.java45
-rw-r--r--src/de/podfetcher/util/FeedItemMenuHandler.java68
5 files changed, 93 insertions, 38 deletions
diff --git a/src/de/podfetcher/activity/ItemviewActivity.java b/src/de/podfetcher/activity/ItemviewActivity.java
index 3844ee8e0..c237ff717 100644
--- a/src/de/podfetcher/activity/ItemviewActivity.java
+++ b/src/de/podfetcher/activity/ItemviewActivity.java
@@ -87,8 +87,14 @@ public class ItemviewActivity extends SherlockActivity {
txtvTitle.setText(item.getTitle());
String url = "";
try {
- url = URLEncoder.encode(item.getContentEncoded(), "utf-8")
- .replaceAll("\\+", " ");
+ if (item.getContentEncoded() == null) {
+ url = URLEncoder.encode(item.getDescription(), "utf-8")
+ .replaceAll("\\+", " ");
+ } else {
+ url = URLEncoder.encode(item.getContentEncoded(), "utf-8")
+ .replaceAll("\\+", " ");
+ }
+
} catch (UnsupportedEncodingException e) {
url = "Page could not be loaded";
e.printStackTrace();
diff --git a/src/de/podfetcher/adapter/FeedItemlistAdapter.java b/src/de/podfetcher/adapter/FeedItemlistAdapter.java
index c0fb2ce40..21678b244 100644
--- a/src/de/podfetcher/adapter/FeedItemlistAdapter.java
+++ b/src/de/podfetcher/adapter/FeedItemlistAdapter.java
@@ -73,6 +73,7 @@ public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> {
if (item.getMedia() == null) {
holder.encInfo.setVisibility(View.GONE);
} else {
+ holder.encInfo.setVisibility(View.VISIBLE);
if (item.getMedia().isDownloaded()) {
holder.lenSize.setText(Converter.getDurationStringShort(item
.getMedia().getDuration()));
diff --git a/src/de/podfetcher/syndication/handler/SyndHandler.java b/src/de/podfetcher/syndication/handler/SyndHandler.java
index 4951b9561..795e3a24a 100644
--- a/src/de/podfetcher/syndication/handler/SyndHandler.java
+++ b/src/de/podfetcher/syndication/handler/SyndHandler.java
@@ -11,6 +11,7 @@ import de.podfetcher.syndication.namespace.Namespace;
import de.podfetcher.syndication.namespace.SyndElement;
import de.podfetcher.syndication.namespace.atom.NSAtom;
import de.podfetcher.syndication.namespace.content.NSContent;
+import de.podfetcher.syndication.namespace.itunes.NSITunes;
import de.podfetcher.syndication.namespace.rss20.NSRSS20;
/** Superclass for all SAX Handlers which process Syndication formats */
@@ -29,9 +30,6 @@ public class SyndHandler extends DefaultHandler {
@Override
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
- if (localName.equals("image") || qName.equals("image")) {
- Log.d(TAG, "Found image");
- }
Namespace handler = getHandlingNamespace(uri);
if (handler != null) {
SyndElement element = handler.handleElementStart(localName, state,
@@ -83,6 +81,9 @@ public class SyndHandler extends DefaultHandler {
} else if (uri.equals(NSContent.NSURI) && prefix.equals(NSContent.NSTAG)) {
state.namespaces.put(uri, new NSContent());
Log.d(TAG, "Recognized Content namespace");
+ } else if (uri.equals(NSITunes.NSURI) && prefix.equals(NSITunes.NSTAG)) {
+ state.namespaces.put(uri, new NSITunes());
+ Log.d(TAG, "Recognized ITunes namespace");
}
}
diff --git a/src/de/podfetcher/syndication/namespace/itunes/NSITunes.java b/src/de/podfetcher/syndication/namespace/itunes/NSITunes.java
new file mode 100644
index 000000000..a93af978b
--- /dev/null
+++ b/src/de/podfetcher/syndication/namespace/itunes/NSITunes.java
@@ -0,0 +1,45 @@
+package de.podfetcher.syndication.namespace.itunes;
+
+import org.xml.sax.Attributes;
+
+import de.podfetcher.feed.FeedImage;
+import de.podfetcher.syndication.handler.HandlerState;
+import de.podfetcher.syndication.namespace.Namespace;
+import de.podfetcher.syndication.namespace.SyndElement;
+
+public class NSITunes extends Namespace{
+ public static final String NSTAG = "itunes";
+ public static final String NSURI = "http://www.itunes.com/dtds/podcast-1.0.dtd";
+
+ private static final String IMAGE = "image";
+ private static final String IMAGE_TITLE = "image";
+ private static final String IMAGE_HREF = "href";
+
+
+ @Override
+ public SyndElement handleElementStart(String localName, HandlerState state,
+ Attributes attributes) {
+ if (localName.equals(IMAGE) && state.getFeed().getImage() == null) {
+ FeedImage image = new FeedImage();
+ image.setTitle(IMAGE_TITLE);
+ image.setDownload_url(attributes.getValue(IMAGE_HREF));
+ state.getFeed().setImage(image);
+ }
+
+ return new SyndElement(localName, this);
+ }
+
+ @Override
+ public void handleCharacters(HandlerState state, char[] ch, int start,
+ int length) {
+
+
+ }
+
+ @Override
+ public void handleElementEnd(String localName, HandlerState state) {
+
+
+ }
+
+}
diff --git a/src/de/podfetcher/util/FeedItemMenuHandler.java b/src/de/podfetcher/util/FeedItemMenuHandler.java
index a159256ea..7f5690ad9 100644
--- a/src/de/podfetcher/util/FeedItemMenuHandler.java
+++ b/src/de/podfetcher/util/FeedItemMenuHandler.java
@@ -14,55 +14,57 @@ import de.podfetcher.storage.DownloadRequester;
/** Handles interactions with the FeedItemMenu. */
public class FeedItemMenuHandler {
private FeedItemMenuHandler() {
-
+
}
- // TODO Fix crash when media is null
+
public static boolean onPrepareMenu(Menu menu, FeedItem selectedItem) {
FeedManager manager = FeedManager.getInstance();
-
- if (selectedItem.getMedia().isDownloaded()) {
- menu.findItem(R.id.play_item).setVisible(true);
- menu.findItem(R.id.remove_item).setVisible(true);
- } else if (selectedItem.getMedia().getFile_url() == null) {
- menu.findItem(R.id.download_item).setVisible(true);
- menu.findItem(R.id.stream_item).setVisible(true);
- } else {
- menu.findItem(R.id.cancel_download_item).setVisible(true);
+
+ if (selectedItem.getMedia() != null) {
+ if (selectedItem.getMedia().isDownloaded()) {
+ menu.findItem(R.id.play_item).setVisible(true);
+ menu.findItem(R.id.remove_item).setVisible(true);
+ } else if (selectedItem.getMedia().getFile_url() == null) {
+ menu.findItem(R.id.download_item).setVisible(true);
+ menu.findItem(R.id.stream_item).setVisible(true);
+ } else {
+ menu.findItem(R.id.cancel_download_item).setVisible(true);
+ }
+
+ if (manager.isInQueue(selectedItem)) {
+ menu.findItem(R.id.remove_from_queue_item).setVisible(true);
+ } else {
+ menu.findItem(R.id.add_to_queue_item).setVisible(true);
+ }
}
-
+
if (selectedItem.isRead()) {
menu.findItem(R.id.mark_unread_item).setVisible(true);
} else {
menu.findItem(R.id.mark_read_item).setVisible(true);
}
-
- if (manager.isInQueue(selectedItem)) {
- menu.findItem(R.id.remove_from_queue_item).setVisible(true);
- } else {
- menu.findItem(R.id.add_to_queue_item).setVisible(true);
- }
+
return true;
}
-
- public static boolean onMenuItemClicked(Context context, MenuItem item, FeedItem selectedItem) {
+
+ public static boolean onMenuItemClicked(Context context, MenuItem item,
+ FeedItem selectedItem) {
DownloadRequester requester = DownloadRequester.getInstance();
FeedManager manager = FeedManager.getInstance();
switch (item.getItemId()) {
case R.id.download_item:
- requester.downloadMedia(context,
- selectedItem.getMedia());
+ requester.downloadMedia(context, selectedItem.getMedia());
break;
case R.id.play_item:
- manager.playMedia(context,
- selectedItem.getMedia(), true, true, false);
+ manager.playMedia(context, selectedItem.getMedia(), true, true,
+ false);
break;
case R.id.remove_item:
- manager.deleteFeedMedia(context,
- selectedItem.getMedia());
+ manager.deleteFeedMedia(context, selectedItem.getMedia());
break;
case R.id.cancel_download_item:
- requester.cancelDownload(context, selectedItem
- .getMedia().getDownloadId());
+ requester.cancelDownload(context, selectedItem.getMedia()
+ .getDownloadId());
break;
case R.id.mark_read_item:
manager.markItemRead(context, selectedItem, true);
@@ -77,17 +79,17 @@ public class FeedItemMenuHandler {
manager.removeQueueItem(context, selectedItem);
break;
case R.id.stream_item:
- manager.playMedia(context, selectedItem.getMedia(), true, true, true);
+ manager.playMedia(context, selectedItem.getMedia(), true, true,
+ true);
}
// Refresh menu state
-
+
return true;
}
-
+
public static boolean onCreateMenu(MenuInflater inflater, Menu menu) {
inflater.inflate(R.menu.feeditem, menu);
return true;
}
-
-
+
}