offline: workaround against crashes in fragment refreshes

This commit is contained in:
Andrew Dolgov 2013-06-03 10:19:12 +04:00
parent caef01010f
commit 124c791ab8
3 changed files with 28 additions and 16 deletions

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.fox.ttrss" package="org.fox.ttrss"
android:versionCode="183" android:versionCode="184"
android:versionName="1.8.3" > android:versionName="1.8.4" >
<uses-sdk <uses-sdk
android:minSdkVersion="8" android:minSdkVersion="8"

View File

@ -121,13 +121,19 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene
} }
public void refresh() { public void refresh() {
if (m_cursor != null && !m_cursor.isClosed()) m_cursor.close(); try {
if (!isAdded()) return;
m_cursor = createCursor();
if (m_cursor != null && !m_cursor.isClosed()) m_cursor.close();
if (m_cursor != null) {
m_adapter.changeCursor(m_cursor); m_cursor = createCursor();
m_adapter.notifyDataSetChanged();
if (m_cursor != null && m_adapter != null) {
m_adapter.changeCursor(m_cursor);
m_adapter.notifyDataSetChanged();
}
} catch (NullPointerException e) {
e.printStackTrace();
} }
} }

View File

@ -256,13 +256,19 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
} }
public void refresh() { public void refresh() {
if (m_cursor != null && !m_cursor.isClosed()) m_cursor.close(); try {
if (!isAdded()) return;
m_cursor = createCursor();
if (m_cursor != null && !m_cursor.isClosed()) m_cursor.close();
if (m_cursor != null) {
m_adapter.changeCursor(m_cursor); m_cursor = createCursor();
m_adapter.notifyDataSetChanged();
if (m_cursor != null && m_adapter != null) {
m_adapter.changeCursor(m_cursor);
m_adapter.notifyDataSetChanged();
}
} catch (NullPointerException e) {
e.printStackTrace();
} }
} }