From 8dc231e8cc8d798704c4fea6fb8595f3bb005a47 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 11 Feb 2015 21:25:27 +0300 Subject: [PATCH] fix crash when opening context menu on feed/cats fragments w/ header (2) --- .../main/java/org/fox/ttrss/FeedCategoriesFragment.java | 8 +++++++- .../src/main/java/org/fox/ttrss/FeedsFragment.java | 4 +--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java index c6275e7b..c01467c3 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java @@ -190,7 +190,13 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe } public FeedCategory getCategoryAtPosition(int position) { - return m_adapter.getItem(position); + try { + return (FeedCategory) m_list.getItemAtPosition(position); + } catch (NullPointerException e) { + return null; + } catch (IndexOutOfBoundsException e) { + return null; + } } @Override diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsFragment.java index 58560ad9..d6ddf7c9 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsFragment.java @@ -856,9 +856,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh public Feed getFeedAtPosition(int position) { try { - ListView list = (ListView) getView().findViewById(R.id.feeds); - - return (Feed) list.getItemAtPosition(position); + return (Feed) m_list.getItemAtPosition(position); } catch (NullPointerException e) { return null; } catch (IndexOutOfBoundsException e) {