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,14 +121,20 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene
} }
public void refresh() { public void refresh() {
try {
if (!isAdded()) return;
if (m_cursor != null && !m_cursor.isClosed()) m_cursor.close(); if (m_cursor != null && !m_cursor.isClosed()) m_cursor.close();
m_cursor = createCursor(); m_cursor = createCursor();
if (m_cursor != null) { if (m_cursor != null && m_adapter != null) {
m_adapter.changeCursor(m_cursor); m_adapter.changeCursor(m_cursor);
m_adapter.notifyDataSetChanged(); m_adapter.notifyDataSetChanged();
} }
} catch (NullPointerException e) {
e.printStackTrace();
}
} }
@Override @Override

View File

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