offline: position fixes for heading
This commit is contained in:
parent
9ee41fc190
commit
972588b485
@ -9,6 +9,7 @@
|
|||||||
android:targetSdkVersion="21" />
|
android:targetSdkVersion="21" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
|
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
|
||||||
|
@ -37,6 +37,7 @@ public class OfflineFeedCategoriesFragment extends Fragment implements OnItemCli
|
|||||||
private Cursor m_cursor;
|
private Cursor m_cursor;
|
||||||
private OfflineFeedsActivity m_activity;
|
private OfflineFeedsActivity m_activity;
|
||||||
private SwipeRefreshLayout m_swipeLayout;
|
private SwipeRefreshLayout m_swipeLayout;
|
||||||
|
private ListView m_list;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateContextMenu(ContextMenu menu, View v,
|
public void onCreateContextMenu(ContextMenu menu, View v,
|
||||||
@ -45,7 +46,7 @@ public class OfflineFeedCategoriesFragment extends Fragment implements OnItemCli
|
|||||||
getActivity().getMenuInflater().inflate(R.menu.category_menu, menu);
|
getActivity().getMenuInflater().inflate(R.menu.category_menu, menu);
|
||||||
|
|
||||||
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
|
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
|
||||||
Cursor cursor = (Cursor)m_adapter.getItem(info.position);
|
Cursor cursor = (Cursor)getCatAtPosition(info.position);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
menu.setHeaderTitle(cursor.getString(cursor.getColumnIndex("title")));
|
menu.setHeaderTitle(cursor.getString(cursor.getColumnIndex("title")));
|
||||||
@ -139,17 +140,22 @@ public class OfflineFeedCategoriesFragment extends Fragment implements OnItemCli
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ListView list = (ListView)view.findViewById(R.id.feeds);
|
m_list = (ListView)view.findViewById(R.id.feeds);
|
||||||
|
|
||||||
|
if (m_activity.isSmallScreen()) {
|
||||||
|
View layout = inflater.inflate(R.layout.headlines_heading_spacer, m_list, false);
|
||||||
|
m_list.addHeaderView(layout);
|
||||||
|
}
|
||||||
|
|
||||||
m_cursor = createCursor();
|
m_cursor = createCursor();
|
||||||
|
|
||||||
m_adapter = new FeedCategoryListAdapter(getActivity(), R.layout.feeds_row, m_cursor,
|
m_adapter = new FeedCategoryListAdapter(getActivity(), R.layout.feeds_row, m_cursor,
|
||||||
new String[] { "title", "unread" }, new int[] { R.id.title, R.id.unread_counter }, 0);
|
new String[] { "title", "unread" }, new int[] { R.id.title, R.id.unread_counter }, 0);
|
||||||
|
|
||||||
list.setAdapter(m_adapter);
|
m_list.setAdapter(m_adapter);
|
||||||
list.setOnItemClickListener(this);
|
m_list.setOnItemClickListener(this);
|
||||||
list.setEmptyView(view.findViewById(R.id.no_feeds));
|
m_list.setEmptyView(view.findViewById(R.id.no_feeds));
|
||||||
registerForContextMenu(list);
|
registerForContextMenu(m_list);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
@ -313,16 +319,36 @@ public class OfflineFeedCategoriesFragment extends Fragment implements OnItemCli
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getCatIdAtPosition(int position) {
|
public int getCatIdAtPosition(int position) {
|
||||||
Cursor c = (Cursor)m_adapter.getItem(position);
|
|
||||||
|
|
||||||
if (c != null) {
|
/* if (m_list != null) {
|
||||||
int catId = c.getInt(0);
|
Cursor c = (Cursor) m_list.getItemAtPosition(position);
|
||||||
return catId;
|
|
||||||
}
|
if (c != null) {
|
||||||
|
int catId = c.getInt(0);
|
||||||
|
return catId;
|
||||||
|
}
|
||||||
|
} */
|
||||||
|
|
||||||
|
Cursor tmp = getCatAtPosition(position);
|
||||||
|
|
||||||
|
if (tmp != null) {
|
||||||
|
int id = tmp.getInt(0);
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
return -10000;
|
return -10000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Cursor getCatAtPosition(int position) {
|
||||||
|
|
||||||
|
if (m_list != null) {
|
||||||
|
return (Cursor) m_list.getItemAtPosition(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void setSelectedFeedId(int feedId) {
|
public void setSelectedFeedId(int feedId) {
|
||||||
m_selectedCatId = feedId;
|
m_selectedCatId = feedId;
|
||||||
refresh();
|
refresh();
|
||||||
|
@ -46,6 +46,7 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene
|
|||||||
private OfflineFeedsActivity m_activity;
|
private OfflineFeedsActivity m_activity;
|
||||||
private SwipeRefreshLayout m_swipeLayout;
|
private SwipeRefreshLayout m_swipeLayout;
|
||||||
private boolean m_enableParentBtn = false;
|
private boolean m_enableParentBtn = false;
|
||||||
|
private ListView m_list;
|
||||||
|
|
||||||
public void initialize(int catId, boolean enableParentBtn) {
|
public void initialize(int catId, boolean enableParentBtn) {
|
||||||
m_catId = catId;
|
m_catId = catId;
|
||||||
@ -90,7 +91,7 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene
|
|||||||
getActivity().getMenuInflater().inflate(R.menu.feed_menu, menu);
|
getActivity().getMenuInflater().inflate(R.menu.feed_menu, menu);
|
||||||
|
|
||||||
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
|
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
|
||||||
Cursor cursor = (Cursor)m_adapter.getItem(info.position);
|
Cursor cursor = (Cursor)getFeedAtPosition(info.position);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
menu.setHeaderTitle(cursor.getString(cursor.getColumnIndex("title")));
|
menu.setHeaderTitle(cursor.getString(cursor.getColumnIndex("title")));
|
||||||
@ -152,7 +153,12 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ListView list = (ListView)view.findViewById(R.id.feeds);
|
m_list = (ListView)view.findViewById(R.id.feeds);
|
||||||
|
|
||||||
|
if (m_activity.isSmallScreen()) {
|
||||||
|
View layout = inflater.inflate(R.layout.headlines_heading_spacer, m_list, false);
|
||||||
|
m_list.addHeaderView(layout);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_enableParentBtn) {
|
if (m_enableParentBtn) {
|
||||||
View layout = inflater.inflate(R.layout.feeds_goback, container, false);
|
View layout = inflater.inflate(R.layout.feeds_goback, container, false);
|
||||||
@ -167,7 +173,7 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
list.addHeaderView(layout, null, false);
|
m_list.addHeaderView(layout, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_cursor = createCursor();
|
m_cursor = createCursor();
|
||||||
@ -175,10 +181,10 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene
|
|||||||
m_adapter = new FeedListAdapter(getActivity(), R.layout.feeds_row, m_cursor,
|
m_adapter = new FeedListAdapter(getActivity(), R.layout.feeds_row, m_cursor,
|
||||||
new String[] { "title", "unread" }, new int[] { R.id.title, R.id.unread_counter }, 0);
|
new String[] { "title", "unread" }, new int[] { R.id.title, R.id.unread_counter }, 0);
|
||||||
|
|
||||||
list.setAdapter(m_adapter);
|
m_list.setAdapter(m_adapter);
|
||||||
list.setOnItemClickListener(this);
|
m_list.setOnItemClickListener(this);
|
||||||
list.setEmptyView(view.findViewById(R.id.no_feeds));
|
m_list.setEmptyView(view.findViewById(R.id.no_feeds));
|
||||||
registerForContextMenu(list);
|
registerForContextMenu(m_list);
|
||||||
|
|
||||||
m_enableFeedIcons = m_prefs.getBoolean("download_feed_icons", false);
|
m_enableFeedIcons = m_prefs.getBoolean("download_feed_icons", false);
|
||||||
|
|
||||||
@ -374,16 +380,35 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getFeedIdAtPosition(int position) {
|
public int getFeedIdAtPosition(int position) {
|
||||||
Cursor c = (Cursor)m_adapter.getItem(position);
|
/* if (m_list != null) {
|
||||||
|
Cursor c = (Cursor) m_list.getItemAtPosition(position);
|
||||||
|
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
int feedId = c.getInt(0);
|
int feedId = c.getInt(0);
|
||||||
return feedId;
|
return feedId;
|
||||||
}
|
}
|
||||||
|
} */
|
||||||
|
|
||||||
|
Cursor tmp = getFeedAtPosition(position);
|
||||||
|
|
||||||
|
if (tmp != null) {
|
||||||
|
int id = tmp.getInt(0);
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
return -10000;
|
return -10000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Cursor getFeedAtPosition(int position) {
|
||||||
|
|
||||||
|
if (m_list != null) {
|
||||||
|
return (Cursor) m_list.getItemAtPosition(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void setSelectedFeedId(int feedId) {
|
public void setSelectedFeedId(int feedId) {
|
||||||
m_selectedFeedId = feedId;
|
m_selectedFeedId = feedId;
|
||||||
refresh();
|
refresh();
|
||||||
|
@ -70,6 +70,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
private SwipeRefreshLayout m_swipeLayout;
|
private SwipeRefreshLayout m_swipeLayout;
|
||||||
|
|
||||||
private boolean m_compactLayoutMode = false;
|
private boolean m_compactLayoutMode = false;
|
||||||
|
private ListView m_list;
|
||||||
|
|
||||||
public void initialize(int feedId, boolean isCat, boolean compactMode) {
|
public void initialize(int feedId, boolean isCat, boolean compactMode) {
|
||||||
m_feedId = feedId;
|
m_feedId = feedId;
|
||||||
@ -302,12 +303,12 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
|
|
||||||
m_cursor = createCursor();
|
m_cursor = createCursor();
|
||||||
|
|
||||||
ListView list = (ListView)view.findViewById(R.id.headlines_list);
|
m_list = (ListView)view.findViewById(R.id.headlines_list);
|
||||||
|
|
||||||
/* if (!m_compactLayoutMode) {
|
if (m_activity.isSmallScreen()) {
|
||||||
list.setDividerHeight(0);
|
View layout = inflater.inflate(R.layout.headlines_heading_spacer, m_list, false);
|
||||||
list.setDivider(null);
|
m_list.addHeaderView(layout);
|
||||||
} */
|
}
|
||||||
|
|
||||||
if (m_prefs.getBoolean("headlines_mark_read_scroll", false)) {
|
if (m_prefs.getBoolean("headlines_mark_read_scroll", false)) {
|
||||||
WindowManager wm = (WindowManager) m_activity.getSystemService(Context.WINDOW_SERVICE);
|
WindowManager wm = (WindowManager) m_activity.getSystemService(Context.WINDOW_SERVICE);
|
||||||
@ -318,18 +319,17 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
|
|
||||||
layout.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, screenHeight));
|
layout.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, screenHeight));
|
||||||
|
|
||||||
list.addFooterView(layout, null, false);
|
m_list.addFooterView(layout, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
m_adapter = new ArticleListAdapter(getActivity(), R.layout.headlines_row, m_cursor,
|
m_adapter = new ArticleListAdapter(getActivity(), R.layout.headlines_row, m_cursor,
|
||||||
new String[] { "title" }, new int[] { R.id.title }, 0);
|
new String[] { "title" }, new int[] { R.id.title }, 0);
|
||||||
|
|
||||||
list.setAdapter(m_adapter);
|
m_list.setAdapter(m_adapter);
|
||||||
list.setOnItemClickListener(this);
|
m_list.setOnItemClickListener(this);
|
||||||
list.setOnScrollListener(this);
|
m_list.setOnScrollListener(this);
|
||||||
//list.setEmptyView(view.findViewById(R.id.no_headlines));
|
registerForContextMenu(m_list);
|
||||||
registerForContextMenu(list);
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user