summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-06-03 10:19:12 +0400
committerAndrew Dolgov <[email protected]>2013-06-03 10:19:12 +0400
commit124c791ab8f2617a07bba69f570bd84ddb18110e (patch)
tree55439452790bcedad9ae2d8d080bc5f7038cb3c6
parentcaef01010f8dce0580eecb6a89f9f5772349373b (diff)
offline: workaround against crashes in fragment refreshes
-rw-r--r--AndroidManifest.xml4
-rw-r--r--src/org/fox/ttrss/offline/OfflineFeedsFragment.java20
-rw-r--r--src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java20
3 files changed, 28 insertions, 16 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 55bba895..5ff53a96 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.fox.ttrss"
- android:versionCode="183"
- android:versionName="1.8.3" >
+ android:versionCode="184"
+ android:versionName="1.8.4" >
<uses-sdk
android:minSdkVersion="8"
diff --git a/src/org/fox/ttrss/offline/OfflineFeedsFragment.java b/src/org/fox/ttrss/offline/OfflineFeedsFragment.java
index a2231485..839f22df 100644
--- a/src/org/fox/ttrss/offline/OfflineFeedsFragment.java
+++ b/src/org/fox/ttrss/offline/OfflineFeedsFragment.java
@@ -121,13 +121,19 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene
}
public void refresh() {
- if (m_cursor != null && !m_cursor.isClosed()) m_cursor.close();
-
- m_cursor = createCursor();
-
- if (m_cursor != null) {
- m_adapter.changeCursor(m_cursor);
- m_adapter.notifyDataSetChanged();
+ try {
+ if (!isAdded()) return;
+
+ if (m_cursor != null && !m_cursor.isClosed()) m_cursor.close();
+
+ m_cursor = createCursor();
+
+ if (m_cursor != null && m_adapter != null) {
+ m_adapter.changeCursor(m_cursor);
+ m_adapter.notifyDataSetChanged();
+ }
+ } catch (NullPointerException e) {
+ e.printStackTrace();
}
}
diff --git a/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java b/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java
index 9ee61684..0eeeee6f 100644
--- a/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java
+++ b/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java
@@ -256,13 +256,19 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
}
public void refresh() {
- if (m_cursor != null && !m_cursor.isClosed()) m_cursor.close();
-
- m_cursor = createCursor();
-
- if (m_cursor != null) {
- m_adapter.changeCursor(m_cursor);
- m_adapter.notifyDataSetChanged();
+ try {
+ if (!isAdded()) return;
+
+ if (m_cursor != null && !m_cursor.isClosed()) m_cursor.close();
+
+ m_cursor = createCursor();
+
+ if (m_cursor != null && m_adapter != null) {
+ m_adapter.changeCursor(m_cursor);
+ m_adapter.notifyDataSetChanged();
+ }
+ } catch (NullPointerException e) {
+ e.printStackTrace();
}
}