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"?>
<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"

View File

@ -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();
}
}

View File

@ -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();
}
}