mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2024-12-22 06:22:00 +01:00
Added support for itunes:image tag, bugfixes
This commit is contained in:
parent
7cd38e53a7
commit
a63e975d87
@ -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();
|
||||
|
@ -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()));
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
45
src/de/podfetcher/syndication/namespace/itunes/NSITunes.java
Normal file
45
src/de/podfetcher/syndication/namespace/itunes/NSITunes.java
Normal file
@ -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) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user