DownloadRequester now throws an exception if request is invalid

This commit is contained in:
daniel oeh 2012-09-23 16:40:44 +02:00
parent aeed5871e4
commit 92feabbb5d
18 changed files with 341 additions and 117 deletions

View File

@ -78,6 +78,7 @@
<string name="download_error_malformed_url">Malformed URL</string>
<string name="download_error_io_error">IO Error</string>
<string name="download_error_device_not_found">External storage unavailable</string>
<string name="download_error_request_error">Request error</string>
<string name="downloads_left">\u0020Downloads left</string>
<string name="download_notification_title">Downloading podcast data</string>
<string name="download_report_content">%1$d downloads succeeded, %2$d failed</string>
@ -85,6 +86,7 @@
<string name="download_type_feed">Feed</string>
<string name="download_type_media">Media file</string>
<string name="download_type_image">Image</string>
<string name="download_request_error_dialog_message_prefix">An error occurred when trying to download the file:\u0020</string>
<!-- Mediaplayer messages -->
<string name="player_error_msg">Error!</string>

View File

@ -20,6 +20,7 @@ import com.actionbarsherlock.view.MenuItem;
import de.danoeh.antennapod.AppConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.feed.Feed;
import de.danoeh.antennapod.storage.DownloadRequestException;
import de.danoeh.antennapod.storage.DownloadRequester;
import de.danoeh.antennapod.util.ConnectionTester;
import de.danoeh.antennapod.util.DownloadError;
@ -123,11 +124,17 @@ public class AddFeedActivity extends SherlockActivity {
@Override
public void onConnectionSuccessful() {
try {
requester.downloadFeed(AddFeedActivity.this, feed);
if (progDialog.isShowing()) {
progDialog.dismiss();
finish();
}
} catch (DownloadRequestException e) {
e.printStackTrace();
onConnectionFailure(DownloadError.ERROR_REQUEST_ERROR);
}
}
@Override

View File

@ -13,8 +13,10 @@ import com.actionbarsherlock.view.MenuItem;
import de.danoeh.antennapod.AppConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.asynctask.FeedImageLoader;
import de.danoeh.antennapod.dialog.DownloadRequestErrorDialogCreator;
import de.danoeh.antennapod.feed.Feed;
import de.danoeh.antennapod.feed.FeedManager;
import de.danoeh.antennapod.storage.DownloadRequestException;
import de.danoeh.antennapod.util.LangUtils;
import de.danoeh.antennapod.util.menuhandler.FeedMenuHandler;
@ -97,7 +99,13 @@ public class FeedInfoActivity extends SherlockActivity {
finish();
return true;
default:
try {
return FeedMenuHandler.onOptionsItemClicked(this, item, feed);
} catch (DownloadRequestException e) {
e.printStackTrace();
DownloadRequestErrorDialogCreator.newRequestErrorDialog(this, e.getMessage());
}
return super.onOptionsItemSelected(item);
}
}
}

View File

@ -17,11 +17,13 @@ import com.actionbarsherlock.view.Window;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.asynctask.FeedRemover;
import de.danoeh.antennapod.dialog.ConfirmationDialog;
import de.danoeh.antennapod.dialog.DownloadRequestErrorDialogCreator;
import de.danoeh.antennapod.feed.Feed;
import de.danoeh.antennapod.feed.FeedManager;
import de.danoeh.antennapod.fragment.ExternalPlayerFragment;
import de.danoeh.antennapod.fragment.FeedlistFragment;
import de.danoeh.antennapod.fragment.ItemlistFragment;
import de.danoeh.antennapod.storage.DownloadRequestException;
import de.danoeh.antennapod.util.StorageUtils;
import de.danoeh.antennapod.util.menuhandler.FeedMenuHandler;
@ -89,6 +91,7 @@ public class FeedItemlistActivity extends SherlockFragmentActivity {
@SuppressLint("NewApi")
@Override
public boolean onOptionsItemSelected(MenuItem item) {
try {
if (FeedMenuHandler.onOptionsItemClicked(this, item, feed)) {
filf.getListAdapter().notifyDataSetChanged();
} else {
@ -124,6 +127,10 @@ public class FeedItemlistActivity extends SherlockFragmentActivity {
break;
}
}
} catch (DownloadRequestException e) {
e.printStackTrace();
DownloadRequestErrorDialogCreator.newRequestErrorDialog(this, e.getMessage());
}
return true;
}

View File

@ -17,12 +17,14 @@ import com.actionbarsherlock.view.Window;
import de.danoeh.antennapod.AppConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.dialog.DownloadRequestErrorDialogCreator;
import de.danoeh.antennapod.feed.Feed;
import de.danoeh.antennapod.feed.FeedItem;
import de.danoeh.antennapod.feed.FeedManager;
import de.danoeh.antennapod.fragment.FeedlistFragment;
import de.danoeh.antennapod.fragment.ItemDescriptionFragment;
import de.danoeh.antennapod.fragment.ItemlistFragment;
import de.danoeh.antennapod.storage.DownloadRequestException;
import de.danoeh.antennapod.util.StorageUtils;
import de.danoeh.antennapod.util.menuhandler.FeedItemMenuHandler;
@ -104,6 +106,7 @@ public class ItemviewActivity extends SherlockFragmentActivity {
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
try {
if (!FeedItemMenuHandler.onMenuItemClicked(this, menuItem, item)) {
switch (menuItem.getItemId()) {
case android.R.id.home:
@ -111,6 +114,10 @@ public class ItemviewActivity extends SherlockFragmentActivity {
break;
}
}
} catch (DownloadRequestException e) {
e.printStackTrace();
DownloadRequestErrorDialogCreator.newRequestErrorDialog(this, e.getMessage());
}
invalidateOptionsMenu();
return true;
}

View File

@ -19,9 +19,11 @@ import com.actionbarsherlock.view.MenuItem;
import de.danoeh.antennapod.AppConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.dialog.DownloadRequestErrorDialogCreator;
import de.danoeh.antennapod.dialog.TimeDialog;
import de.danoeh.antennapod.feed.FeedManager;
import de.danoeh.antennapod.feed.FeedMedia;
import de.danoeh.antennapod.storage.DownloadRequestException;
import de.danoeh.antennapod.util.Converter;
import de.danoeh.antennapod.util.MediaPlayerError;
import de.danoeh.antennapod.util.PlaybackController;
@ -210,8 +212,10 @@ public abstract class MediaplayerActivity extends SherlockFragmentActivity
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
Intent intent = new Intent(MediaplayerActivity.this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
Intent intent = new Intent(MediaplayerActivity.this,
MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
break;
case R.id.disable_sleeptimer_item:
@ -259,8 +263,14 @@ public abstract class MediaplayerActivity extends SherlockFragmentActivity
}
default:
return FeedItemMenuHandler.onMenuItemClicked(this, item, controller
.getMedia().getItem());
try {
return FeedItemMenuHandler.onMenuItemClicked(this, item,
controller.getMedia().getItem());
} catch (DownloadRequestException e) {
e.printStackTrace();
DownloadRequestErrorDialogCreator.newRequestErrorDialog(this,
e.getMessage());
}
}
return true;
}

View File

@ -23,11 +23,13 @@ import com.actionbarsherlock.view.MenuItem;
import de.danoeh.antennapod.AppConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.adapter.MiroGuideItemlistAdapter;
import de.danoeh.antennapod.dialog.DownloadRequestErrorDialogCreator;
import de.danoeh.antennapod.feed.Feed;
import de.danoeh.antennapod.feed.FeedManager;
import de.danoeh.antennapod.miroguide.con.MiroGuideException;
import de.danoeh.antennapod.miroguide.con.MiroGuideService;
import de.danoeh.antennapod.miroguide.model.MiroGuideChannel;
import de.danoeh.antennapod.storage.DownloadRequestException;
import de.danoeh.antennapod.storage.DownloadRequester;
/**
@ -154,8 +156,13 @@ public class MiroGuideChannelViewActivity extends SherlockActivity {
startActivity(new Intent(Intent.ACTION_VIEW, uri));
return true;
case R.id.add_feed:
try {
DownloadRequester.getInstance().downloadFeed(this,
new Feed(channel.getDownloadUrl(), new Date(), channel.getName()));
} catch (DownloadRequestException e) {
e.printStackTrace();
DownloadRequestErrorDialogCreator.newRequestErrorDialog(this, e.getMessage());
}
Toast toast = Toast.makeText(this, R.string.miro_feed_added,
Toast.LENGTH_LONG);
toast.show();

View File

@ -10,6 +10,7 @@ import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.OpmlImportActivity;
import de.danoeh.antennapod.feed.Feed;
import de.danoeh.antennapod.opml.OpmlElement;
import de.danoeh.antennapod.storage.DownloadRequestException;
import de.danoeh.antennapod.storage.DownloadRequester;
/** Queues items for download in the background. */
@ -18,23 +19,17 @@ public class OpmlFeedQueuer extends AsyncTask<Void, Void, Void> {
private ProgressDialog progDialog;
private int[] selection;
public OpmlFeedQueuer(Context context, int[] selection) {
super();
this.context = context;
this.selection = selection;
}
@Override
protected void onPostExecute(Void result) {
progDialog.dismiss();
}
@Override
protected void onPreExecute() {
progDialog = new ProgressDialog(context);
@ -44,15 +39,19 @@ public class OpmlFeedQueuer extends AsyncTask<Void, Void, Void> {
progDialog.show();
}
@Override
protected Void doInBackground(Void... params) {
DownloadRequester requester = DownloadRequester.getInstance();
for (int idx = 0; idx < selection.length; idx++) {
OpmlElement element = OpmlImportActivity.getReadElements().get(selection[idx]);
Feed feed = new Feed(element.getXmlUrl(), new Date(), element.getText());
OpmlElement element = OpmlImportActivity.getReadElements().get(
selection[idx]);
Feed feed = new Feed(element.getXmlUrl(), new Date(),
element.getText());
try {
requester.downloadFeed(context.getApplicationContext(), feed);
} catch (DownloadRequestException e) {
e.printStackTrace();
}
}
return null;
}

View File

@ -0,0 +1,31 @@
package de.danoeh.antennapod.dialog;
import de.danoeh.antennapod.R;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
/** Creates Alert Dialogs if a DownloadRequestException has happened. */
public class DownloadRequestErrorDialogCreator {
private DownloadRequestErrorDialogCreator() {
}
public static void newRequestErrorDialog(Context context,
String errorMessage) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setNeutralButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
})
.setTitle(R.string.download_error_request_error)
.setMessage(
context.getString(R.string.download_request_error_dialog_message_prefix)
+ errorMessage);
builder.create().show();
}
}

View File

@ -22,8 +22,10 @@ import de.danoeh.antennapod.AppConfig;
import de.danoeh.antennapod.PodcastApp;
import de.danoeh.antennapod.asynctask.DownloadStatus;
import de.danoeh.antennapod.service.PlaybackService;
import de.danoeh.antennapod.storage.DownloadRequestException;
import de.danoeh.antennapod.storage.DownloadRequester;
import de.danoeh.antennapod.storage.PodDBAdapter;
import de.danoeh.antennapod.util.DownloadError;
import de.danoeh.antennapod.util.FeedtitleComparator;
import de.danoeh.antennapod.util.comparator.DownloadStatusComparator;
import de.danoeh.antennapod.util.comparator.FeedItemPubdateComparator;
@ -305,7 +307,17 @@ public class FeedManager {
@Override
protected Void doInBackground(Void... params) {
for (Feed feed : feeds) {
try {
refreshFeed(context, feed);
} catch (DownloadRequestException e) {
e.printStackTrace();
addDownloadStatus(
context,
new DownloadStatus(feed, feed
.getHumanReadableIdentifier(),
DownloadError.ERROR_REQUEST_ERROR,
false, e.getMessage()));
}
}
return null;
}
@ -327,10 +339,16 @@ public class FeedManager {
public void notifyInvalidImageFile(Context context, FeedImage image) {
Log.i(TAG,
"The feedmanager was notified about an invalid image download. It will now try to redownload the image file");
try {
requester.downloadImage(context, image);
} catch (DownloadRequestException e) {
e.printStackTrace();
Log.w(TAG, "Failed to download invalid feed image");
}
}
public void refreshFeed(Context context, Feed feed) {
public void refreshFeed(Context context, Feed feed)
throws DownloadRequestException {
requester.downloadFeed(context, new Feed(feed.getDownload_url(),
new Date(), feed.getTitle()));
}
@ -370,11 +388,17 @@ public class FeedManager {
public void downloadAllItemsInQueue(final Context context) {
if (!queue.isEmpty()) {
downloadFeedItem(context, queue.toArray(new FeedItem[queue.size()]));
try {
downloadFeedItem(context,
queue.toArray(new FeedItem[queue.size()]));
} catch (DownloadRequestException e) {
e.printStackTrace();
}
}
}
public void downloadFeedItem(final Context context, FeedItem... items) {
public void downloadFeedItem(final Context context, FeedItem... items)
throws DownloadRequestException {
boolean autoQueue = PreferenceManager.getDefaultSharedPreferences(
context.getApplicationContext()).getBoolean(
PodcastApp.PREF_AUTO_QUEUE, true);
@ -384,7 +408,21 @@ public class FeedManager {
if (item.getMedia() != null
&& !requester.isDownloadingFile(item.getMedia())
&& !item.getMedia().isDownloaded()) {
if (items.length > 1) {
try {
requester.downloadMedia(context, item.getMedia());
} catch (DownloadRequestException e) {
e.printStackTrace();
addDownloadStatus(context,
new DownloadStatus(item.getMedia(), item
.getMedia()
.getHumanReadableIdentifier(),
DownloadError.ERROR_REQUEST_ERROR,
false, e.getMessage()));
}
} else {
requester.downloadMedia(context, item.getMedia());
}
addToQueue.add(item);
}
}

View File

@ -29,9 +29,11 @@ import de.danoeh.antennapod.activity.FeedItemlistActivity;
import de.danoeh.antennapod.adapter.FeedlistAdapter;
import de.danoeh.antennapod.asynctask.FeedRemover;
import de.danoeh.antennapod.dialog.ConfirmationDialog;
import de.danoeh.antennapod.dialog.DownloadRequestErrorDialogCreator;
import de.danoeh.antennapod.feed.Feed;
import de.danoeh.antennapod.feed.FeedManager;
import de.danoeh.antennapod.service.download.DownloadService;
import de.danoeh.antennapod.storage.DownloadRequestException;
import de.danoeh.antennapod.storage.DownloadRequester;
import de.danoeh.antennapod.util.menuhandler.FeedMenuHandler;
@ -159,30 +161,41 @@ public class FeedlistFragment extends SherlockFragment implements
@SuppressLint("NewApi")
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
if (FeedMenuHandler.onOptionsItemClicked(getSherlockActivity(), item,
selectedFeed)) {
try {
if (FeedMenuHandler.onOptionsItemClicked(getSherlockActivity(),
item, selectedFeed)) {
fla.notifyDataSetChanged();
} else {
switch (item.getItemId()) {
case R.id.remove_item:
final FeedRemover remover = new FeedRemover(getSherlockActivity(), selectedFeed) {
final FeedRemover remover = new FeedRemover(
getSherlockActivity(), selectedFeed) {
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
fla.notifyDataSetChanged();
}
};
ConfirmationDialog conDialog = new ConfirmationDialog(getActivity(), R.string.remove_feed_label, R.string.feed_delete_confirmation_msg){
ConfirmationDialog conDialog = new ConfirmationDialog(
getActivity(), R.string.remove_feed_label,
R.string.feed_delete_confirmation_msg) {
@Override
public void onConfirmButtonPressed(DialogInterface dialog) {
public void onConfirmButtonPressed(
DialogInterface dialog) {
dialog.dismiss();
remover.executeAsync();
}};
}
};
conDialog.createNewDialog().show();
break;
}
}
} catch (DownloadRequestException e) {
e.printStackTrace();
DownloadRequestErrorDialogCreator.newRequestErrorDialog(
getActivity(), e.getMessage());
}
mode.finish();
return true;
}

View File

@ -23,10 +23,12 @@ import de.danoeh.antennapod.AppConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.ItemviewActivity;
import de.danoeh.antennapod.adapter.FeedItemlistAdapter;
import de.danoeh.antennapod.dialog.DownloadRequestErrorDialogCreator;
import de.danoeh.antennapod.feed.Feed;
import de.danoeh.antennapod.feed.FeedItem;
import de.danoeh.antennapod.feed.FeedManager;
import de.danoeh.antennapod.service.download.DownloadService;
import de.danoeh.antennapod.storage.DownloadRequestException;
import de.danoeh.antennapod.storage.DownloadRequester;
import de.danoeh.antennapod.util.menuhandler.FeedItemMenuHandler;
@ -231,8 +233,15 @@ public class ItemlistFragment extends SherlockListFragment implements
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
boolean handled = FeedItemMenuHandler.onMenuItemClicked(
boolean handled = false;
try {
handled = FeedItemMenuHandler.onMenuItemClicked(
getSherlockActivity(), item, selectedItem);
} catch (DownloadRequestException e) {
e.printStackTrace();
DownloadRequestErrorDialogCreator.newRequestErrorDialog(
getActivity(), e.getMessage());
}
if (handled) {
fila.notifyDataSetChanged();
}

View File

@ -51,6 +51,7 @@ import de.danoeh.antennapod.feed.FeedFile;
import de.danoeh.antennapod.feed.FeedImage;
import de.danoeh.antennapod.feed.FeedManager;
import de.danoeh.antennapod.feed.FeedMedia;
import de.danoeh.antennapod.storage.DownloadRequestException;
import de.danoeh.antennapod.storage.DownloadRequester;
import de.danoeh.antennapod.syndication.handler.FeedHandler;
import de.danoeh.antennapod.syndication.handler.UnsupportedFeedtypeException;
@ -561,8 +562,18 @@ public class DownloadService extends Service {
if (AppConfig.DEBUG)
Log.d(TAG, "Feed has image; Downloading....");
savedFeed.getImage().setFeed(savedFeed);
try {
requester.downloadImage(DownloadService.this,
savedFeed.getImage());
} catch (DownloadRequestException e) {
e.printStackTrace();
manager.addDownloadStatus(DownloadService.this,
new DownloadStatus(savedFeed.getImage(),
savedFeed.getImage()
.getHumanReadableIdentifier(),
DownloadError.ERROR_REQUEST_ERROR,
false, e.getMessage()));
}
}
} catch (SAXException e) {
@ -693,7 +704,8 @@ public class DownloadService extends Service {
}
if (media.getItem().getChapters() == null) {
ChapterUtils.readID3ChaptersFromFeedMediaFileUrl(media.getItem());
ChapterUtils.readID3ChaptersFromFeedMediaFileUrl(media
.getItem());
if (media.getItem().getChapters() != null) {
chaptersRead = true;
}

View File

@ -0,0 +1,25 @@
package de.danoeh.antennapod.storage;
/**
* Thrown by the DownloadRequester if a download request contains invalid data
* or something went wrong while processing the request.
*/
public class DownloadRequestException extends Exception {
public DownloadRequestException() {
super();
}
public DownloadRequestException(String detailMessage, Throwable throwable) {
super(detailMessage, throwable);
}
public DownloadRequestException(String detailMessage) {
super(detailMessage);
}
public DownloadRequestException(Throwable throwable) {
super(throwable);
}
}

View File

@ -78,21 +78,45 @@ public class DownloadRequester {
}
}
public void downloadFeed(Context context, Feed feed) {
public void downloadFeed(Context context, Feed feed)
throws DownloadRequestException {
if (feedFileValid(feed)) {
download(context, feed, new File(getFeedfilePath(context),
getFeedfileName(feed)));
}
}
public void downloadImage(Context context, FeedImage image) {
public void downloadImage(Context context, FeedImage image)
throws DownloadRequestException {
if (feedFileValid(image)) {
download(context, image, new File(getImagefilePath(context),
getImagefileName(image)));
}
}
public void downloadMedia(Context context, FeedMedia feedmedia) {
public void downloadMedia(Context context, FeedMedia feedmedia) throws DownloadRequestException {
if (feedFileValid(feedmedia)) {
download(context, feedmedia,
new File(getMediafilePath(context, feedmedia),
getMediafilename(feedmedia)));
}
}
/**
* Throws a DownloadRequestException if the feedfile or the download url of
* the feedfile is null.
*
* @throws DownloadRequestException
*/
private boolean feedFileValid(FeedFile f) throws DownloadRequestException {
if (f == null) {
throw new DownloadRequestException("Feedfile was null");
} else if (f.getDownload_url() == null) {
throw new DownloadRequestException("File has no download URL");
} else {
return true;
}
}
/**
* Cancels a running download.
@ -158,7 +182,8 @@ public class DownloadRequester {
/** Remove an object from the downloads-list of the requester. */
public void removeDownload(FeedFile f) {
if (downloads.remove(f.getDownload_url()) == null) {
Log.e(TAG, "Could not remove object with url " + f.getDownload_url());
Log.e(TAG,
"Could not remove object with url " + f.getDownload_url());
}
}
@ -167,29 +192,46 @@ public class DownloadRequester {
return downloads.size();
}
public String getFeedfilePath(Context context) {
return context.getExternalFilesDir(FEED_DOWNLOADPATH).toString() + "/";
public String getFeedfilePath(Context context)
throws DownloadRequestException {
return getExternalFilesDirOrThrowException(context, FEED_DOWNLOADPATH)
.toString() + "/";
}
public String getFeedfileName(Feed feed) {
return "feed-" + NumberGenerator.generateLong(feed.getDownload_url());
}
public String getImagefilePath(Context context) {
return context.getExternalFilesDir(IMAGE_DOWNLOADPATH).toString() + "/";
public String getImagefilePath(Context context)
throws DownloadRequestException {
return getExternalFilesDirOrThrowException(context, IMAGE_DOWNLOADPATH)
.toString() + "/";
}
public String getImagefileName(FeedImage image) {
return "image-" + NumberGenerator.generateLong(image.getDownload_url());
}
public String getMediafilePath(Context context, FeedMedia media) {
File externalStorage = context.getExternalFilesDir(MEDIA_DOWNLOADPATH
+ NumberGenerator.generateLong(media.getItem().getFeed()
.getTitle()) + "/");
public String getMediafilePath(Context context, FeedMedia media)
throws DownloadRequestException {
File externalStorage = getExternalFilesDirOrThrowException(
context,
MEDIA_DOWNLOADPATH
+ NumberGenerator.generateLong(media.getItem()
.getFeed().getTitle()) + "/");
return externalStorage.toString();
}
private File getExternalFilesDirOrThrowException(Context context,
String type) throws DownloadRequestException {
File result = context.getExternalFilesDir(type);
if (result == null) {
throw new DownloadRequestException(
"Failed to access external storage");
}
return result;
}
public String getMediafilename(FeedMedia media) {
return URLUtil.guessFileName(media.getDownload_url(), null,
media.getMime_type());

View File

@ -16,6 +16,7 @@ public class DownloadError {
public static final int ERROR_HTTP_DATA_ERROR = 9;
public static final int ERROR_NOT_ENOUGH_SPACE = 10;
public static final int ERROR_UNKNOWN_HOST = 11;
public static final int ERROR_REQUEST_ERROR = 12;
/** Get a human-readable string for a specific error code. */
public static String getErrorString(Context context, int code) {
@ -45,6 +46,9 @@ public class DownloadError {
case ERROR_UNKNOWN_HOST:
resId = R.string.download_error_unknown_host;
break;
case ERROR_REQUEST_ERROR:
resId = R.string.download_error_request_error;
break;
default:
resId = R.string.download_error_error_unknown;
}

View File

@ -13,6 +13,7 @@ import de.danoeh.antennapod.R;
import de.danoeh.antennapod.asynctask.FlattrClickWorker;
import de.danoeh.antennapod.feed.FeedItem;
import de.danoeh.antennapod.feed.FeedManager;
import de.danoeh.antennapod.storage.DownloadRequestException;
import de.danoeh.antennapod.storage.DownloadRequester;
import de.danoeh.antennapod.util.ShareUtils;
@ -64,7 +65,7 @@ public class FeedItemMenuHandler {
}
public static boolean onMenuItemClicked(Context context, MenuItem item,
FeedItem selectedItem) {
FeedItem selectedItem) throws DownloadRequestException {
DownloadRequester requester = DownloadRequester.getInstance();
FeedManager manager = FeedManager.getInstance();
switch (item.getItemId()) {

View File

@ -16,6 +16,7 @@ import de.danoeh.antennapod.asynctask.FlattrClickWorker;
import de.danoeh.antennapod.feed.Feed;
import de.danoeh.antennapod.feed.FeedManager;
import de.danoeh.antennapod.service.download.DownloadService;
import de.danoeh.antennapod.storage.DownloadRequestException;
import de.danoeh.antennapod.storage.DownloadRequester;
import de.danoeh.antennapod.util.ShareUtils;
@ -51,9 +52,10 @@ public class FeedMenuHandler {
return true;
}
/** NOTE: This method does not handle clicks on the 'remove feed' - item. */
/** NOTE: This method does not handle clicks on the 'remove feed' - item.
* @throws DownloadRequestException */
public static boolean onOptionsItemClicked(Context context, MenuItem item,
Feed selectedFeed) {
Feed selectedFeed) throws DownloadRequestException {
FeedManager manager = FeedManager.getInstance();
switch (item.getItemId()) {
case R.id.show_info_item: