fix crashes in offline mode because of unbound swipelayout
This commit is contained in:
parent
5d5d925b3e
commit
1510e7985e
@ -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="242"
|
||||
android:versionName="1.43" >
|
||||
android:versionCode="243"
|
||||
android:versionName="1.44" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="8"
|
||||
|
@ -12,6 +12,7 @@ import android.preference.PreferenceManager;
|
||||
import android.provider.BaseColumns;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.widget.SimpleCursorAdapter;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.util.Log;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
@ -35,6 +36,7 @@ public class OfflineFeedCategoriesFragment extends Fragment implements OnItemCli
|
||||
private int m_selectedCatId;
|
||||
private Cursor m_cursor;
|
||||
private OfflineFeedsActivity m_activity;
|
||||
private SwipeRefreshLayout m_swipeLayout;
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v,
|
||||
@ -66,6 +68,10 @@ public class OfflineFeedCategoriesFragment extends Fragment implements OnItemCli
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
if (!isAdded()) return;
|
||||
|
||||
if (m_swipeLayout != null) m_swipeLayout.setRefreshing(true);
|
||||
|
||||
if (m_cursor != null && !m_cursor.isClosed()) m_cursor.close();
|
||||
|
||||
m_cursor = createCursor();
|
||||
@ -73,6 +79,7 @@ public class OfflineFeedCategoriesFragment extends Fragment implements OnItemCli
|
||||
if (m_cursor != null && m_adapter != null) {
|
||||
m_adapter.changeCursor(m_cursor);
|
||||
m_adapter.notifyDataSetChanged();
|
||||
if (m_swipeLayout != null) m_swipeLayout.setRefreshing(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,6 +142,22 @@ public class OfflineFeedCategoriesFragment extends Fragment implements OnItemCli
|
||||
|
||||
View view = inflater.inflate(R.layout.feeds_fragment, container, false);
|
||||
|
||||
m_swipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.feeds_swipe_container);
|
||||
|
||||
m_swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
|
||||
if (!m_activity.isCompatMode()) {
|
||||
m_swipeLayout.setColorScheme(android.R.color.holo_green_dark,
|
||||
android.R.color.holo_red_dark,
|
||||
android.R.color.holo_blue_dark,
|
||||
android.R.color.holo_orange_dark);
|
||||
}
|
||||
|
||||
ListView list = (ListView)view.findViewById(R.id.feeds);
|
||||
|
||||
m_cursor = createCursor();
|
||||
|
@ -17,6 +17,7 @@ import android.preference.PreferenceManager;
|
||||
import android.provider.BaseColumns;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.widget.SimpleCursorAdapter;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.util.Log;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
@ -43,6 +44,7 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene
|
||||
private boolean m_enableFeedIcons;
|
||||
private Cursor m_cursor;
|
||||
private OfflineFeedsActivity m_activity;
|
||||
private SwipeRefreshLayout m_swipeLayout;
|
||||
|
||||
public void initialize(int catId) {
|
||||
m_catId = catId;
|
||||
@ -124,6 +126,8 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene
|
||||
try {
|
||||
if (!isAdded()) return;
|
||||
|
||||
if (m_swipeLayout != null) m_swipeLayout.setRefreshing(true);
|
||||
|
||||
if (m_cursor != null && !m_cursor.isClosed()) m_cursor.close();
|
||||
|
||||
m_cursor = createCursor();
|
||||
@ -131,6 +135,7 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene
|
||||
if (m_cursor != null && m_adapter != null) {
|
||||
m_adapter.changeCursor(m_cursor);
|
||||
m_adapter.notifyDataSetChanged();
|
||||
if (m_swipeLayout != null) m_swipeLayout.setRefreshing(false);
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
@ -147,6 +152,22 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene
|
||||
|
||||
View view = inflater.inflate(R.layout.feeds_fragment, container, false);
|
||||
|
||||
m_swipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.feeds_swipe_container);
|
||||
|
||||
m_swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
|
||||
if (!m_activity.isCompatMode()) {
|
||||
m_swipeLayout.setColorScheme(android.R.color.holo_green_dark,
|
||||
android.R.color.holo_red_dark,
|
||||
android.R.color.holo_blue_dark,
|
||||
android.R.color.holo_orange_dark);
|
||||
}
|
||||
|
||||
ListView list = (ListView)view.findViewById(R.id.feeds);
|
||||
|
||||
m_cursor = createCursor();
|
||||
|
Loading…
Reference in New Issue
Block a user