From 2d2cf2f933207b0230dce14d9fdd95ed4ae6fba2 Mon Sep 17 00:00:00 2001 From: Martin Fietz Date: Tue, 5 Jan 2016 01:40:52 +0100 Subject: [PATCH] Prevent NPE if media was not found --- .../antennapod/adapter/DownloadLogAdapter.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java index 9d7a509cf..582538fb8 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java @@ -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);