Prevent NPE if media was not found

This commit is contained in:
Martin Fietz 2016-01-05 01:40:52 +01:00
parent 07d378cffd
commit 2d2cf2f933
1 changed files with 10 additions and 6 deletions

View File

@ -134,12 +134,16 @@ public class DownloadLogAdapter extends BaseAdapter {
}
} else if(holder.typeId == FeedMedia.FEEDFILETYPE_FEEDMEDIA) {
FeedMedia media = DBReader.getFeedMedia(holder.id);
try {
DBTasks.downloadFeedItems(context, media.getItem());
Toast.makeText(context, R.string.status_downloading_label, Toast.LENGTH_SHORT).show();
} catch (DownloadRequestException e) {
e.printStackTrace();
DownloadRequestErrorDialogCreator.newRequestErrorDialog(context, e.getMessage());
if (media != null) {
try {
DBTasks.downloadFeedItems(context, media.getItem());
Toast.makeText(context, R.string.status_downloading_label, Toast.LENGTH_SHORT).show();
} catch (DownloadRequestException e) {
e.printStackTrace();
DownloadRequestErrorDialogCreator.newRequestErrorDialog(context, e.getMessage());
}
} else {
Log.wtf(TAG, "Could not find media for id: " + holder.id);
}
} else {
Log.wtf(TAG, "Unexpected type id: " + holder.typeId);