From ac3dbd593a0a764835bb371cdb31354406e75e02 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 9 Oct 2012 09:54:43 +0400 Subject: [PATCH] check if fragment is attached in fragment asynctasks --- src/org/fox/ttrss/ArticlePager.java | 2 ++ src/org/fox/ttrss/FeedCategoriesFragment.java | 2 ++ src/org/fox/ttrss/FeedsFragment.java | 6 ++++++ src/org/fox/ttrss/HeadlinesFragment.java | 2 ++ src/org/fox/ttrss/OnlineActivity.java | 4 +++- 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/org/fox/ttrss/ArticlePager.java b/src/org/fox/ttrss/ArticlePager.java index a7ea5ff8..3eec0355 100644 --- a/src/org/fox/ttrss/ArticlePager.java +++ b/src/org/fox/ttrss/ArticlePager.java @@ -144,6 +144,8 @@ public class ArticlePager extends Fragment { @Override protected void onPostExecute(JsonElement result) { + if (isDetached()) return; + m_activity.setProgressBarVisibility(false); super.onPostExecute(result); diff --git a/src/org/fox/ttrss/FeedCategoriesFragment.java b/src/org/fox/ttrss/FeedCategoriesFragment.java index 9512da08..0b7922c1 100644 --- a/src/org/fox/ttrss/FeedCategoriesFragment.java +++ b/src/org/fox/ttrss/FeedCategoriesFragment.java @@ -255,6 +255,8 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe @Override protected void onPostExecute(JsonElement result) { + if (isDetached()) return; + m_activity.setProgressBarVisibility(false); if (result != null) { diff --git a/src/org/fox/ttrss/FeedsFragment.java b/src/org/fox/ttrss/FeedsFragment.java index a3de1c80..a6dcf056 100644 --- a/src/org/fox/ttrss/FeedsFragment.java +++ b/src/org/fox/ttrss/FeedsFragment.java @@ -343,6 +343,8 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh ApiRequest req = new ApiRequest(getActivity().getApplicationContext()) { protected void onPostExecute(JsonElement result) { + if (isDetached()) return; + if (result != null) { try { @@ -399,6 +401,8 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh @Override protected void onPostExecute(JsonElement result) { + if (isDetached()) return; + m_activity.setProgressBarVisibility(false); if (result != null) { @@ -632,6 +636,8 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh } protected void onPostExecute(Integer result) { + if (isDetached()) return; + m_adapter.notifyDataSetInvalidated(); } diff --git a/src/org/fox/ttrss/HeadlinesFragment.java b/src/org/fox/ttrss/HeadlinesFragment.java index f4557fd6..7379c099 100644 --- a/src/org/fox/ttrss/HeadlinesFragment.java +++ b/src/org/fox/ttrss/HeadlinesFragment.java @@ -368,6 +368,8 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, @Override protected void onPostExecute(JsonElement result) { + if (isDetached()) return; + m_activity.setProgressBarVisibility(false); super.onPostExecute(result); diff --git a/src/org/fox/ttrss/OnlineActivity.java b/src/org/fox/ttrss/OnlineActivity.java index 636535e4..13f92a3f 100644 --- a/src/org/fox/ttrss/OnlineActivity.java +++ b/src/org/fox/ttrss/OnlineActivity.java @@ -545,7 +545,9 @@ public class OnlineActivity extends CommonActivity { ApiRequest req = new ApiRequest(getApplicationContext()) { protected void onPostExecute(JsonElement result) { - hf.refresh(false); + if (hf.isAdded()) { + hf.refresh(false); + } } };