From e2b195e5ede61cfbd304b736caea6c5f8e1f5234 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 19 Jul 2013 13:07:27 +0400 Subject: [PATCH] fix crash if sdcard is unmounted and feed icons are enabled (closes #749) --- AndroidManifest.xml | 4 ++-- src/org/fox/ttrss/FeedsFragment.java | 20 +++++++++++-------- .../ttrss/offline/OfflineFeedsFragment.java | 20 +++++++++++-------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 078d80d5..ba97a464 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="192" + android:versionName="1.8.12" > 0 ? R.drawable.ic_rss : R.drawable.ic_rss_bw); } - } else { + } catch (NullPointerException e) { icon.setImageResource(feed.unread > 0 ? R.drawable.ic_rss : R.drawable.ic_rss_bw); } diff --git a/src/org/fox/ttrss/offline/OfflineFeedsFragment.java b/src/org/fox/ttrss/offline/OfflineFeedsFragment.java index 839f22df..98996858 100644 --- a/src/org/fox/ttrss/offline/OfflineFeedsFragment.java +++ b/src/org/fox/ttrss/offline/OfflineFeedsFragment.java @@ -297,15 +297,19 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene if (m_enableFeedIcons) { - File storage = Environment.getExternalStorageDirectory(); - - File iconFile = new File(storage.getAbsolutePath() + ICON_PATH + cursor.getInt(cursor.getColumnIndex(BaseColumns._ID)) + ".ico"); - if (iconFile.exists()) { - Bitmap bmpOrig = BitmapFactory.decodeFile(iconFile.getAbsolutePath()); - if (bmpOrig != null) { - icon.setImageBitmap(bmpOrig); + try { + File storage = Environment.getExternalStorageDirectory(); + + File iconFile = new File(storage.getAbsolutePath() + ICON_PATH + cursor.getInt(cursor.getColumnIndex(BaseColumns._ID)) + ".ico"); + if (iconFile.exists()) { + Bitmap bmpOrig = BitmapFactory.decodeFile(iconFile.getAbsolutePath()); + if (bmpOrig != null) { + icon.setImageBitmap(bmpOrig); + } + } else { + icon.setImageResource(cursor.getInt(cursor.getColumnIndex("unread")) > 0 ? R.drawable.ic_rss : R.drawable.ic_rss_bw); } - } else { + } catch (NullPointerException e) { icon.setImageResource(cursor.getInt(cursor.getColumnIndex("unread")) > 0 ? R.drawable.ic_rss : R.drawable.ic_rss_bw); }