diff options
author | Andrew Dolgov <[email protected]> | 2015-05-11 12:42:38 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2015-05-11 12:42:38 +0300 |
commit | 972588b485874e2eb1b28fc43a26276911a1cad6 (patch) | |
tree | 041350a5966dea14b9499b64d9d939e7b13756ae /org.fox.ttrss/src/main/java | |
parent | 9ee41fc19034b8619fa46db3d6a02acb002011bf (diff) |
offline: position fixes for heading
Diffstat (limited to 'org.fox.ttrss/src/main/java')
3 files changed, 93 insertions, 42 deletions
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineFeedCategoriesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineFeedCategoriesFragment.java index af6b0943..a26b14a5 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineFeedCategoriesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineFeedCategoriesFragment.java @@ -37,6 +37,7 @@ public class OfflineFeedCategoriesFragment extends Fragment implements OnItemCli private Cursor m_cursor; private OfflineFeedsActivity m_activity; private SwipeRefreshLayout m_swipeLayout; + private ListView m_list; @Override 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); AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; - Cursor cursor = (Cursor)m_adapter.getItem(info.position); + Cursor cursor = (Cursor)getCatAtPosition(info.position); if (cursor != null) 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_adapter = new FeedCategoryListAdapter(getActivity(), R.layout.feeds_row, m_cursor, new String[] { "title", "unread" }, new int[] { R.id.title, R.id.unread_counter }, 0); - list.setAdapter(m_adapter); - list.setOnItemClickListener(this); - list.setEmptyView(view.findViewById(R.id.no_feeds)); - registerForContextMenu(list); + m_list.setAdapter(m_adapter); + m_list.setOnItemClickListener(this); + m_list.setEmptyView(view.findViewById(R.id.no_feeds)); + registerForContextMenu(m_list); return view; } @@ -313,16 +319,36 @@ public class OfflineFeedCategoriesFragment extends Fragment implements OnItemCli } public int getCatIdAtPosition(int position) { - Cursor c = (Cursor)m_adapter.getItem(position); - - if (c != null) { - int catId = c.getInt(0); - return catId; - } - + + /* if (m_list != null) { + Cursor c = (Cursor) m_list.getItemAtPosition(position); + + 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; } - + + public Cursor getCatAtPosition(int position) { + + if (m_list != null) { + return (Cursor) m_list.getItemAtPosition(position); + } + + return null; + } + public void setSelectedFeedId(int feedId) { m_selectedCatId = feedId; refresh(); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineFeedsFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineFeedsFragment.java index 4dd2f1c3..3bb35d69 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineFeedsFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineFeedsFragment.java @@ -46,6 +46,7 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene private OfflineFeedsActivity m_activity; private SwipeRefreshLayout m_swipeLayout; private boolean m_enableParentBtn = false; + private ListView m_list; public void initialize(int catId, boolean enableParentBtn) { m_catId = catId; @@ -90,7 +91,7 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene getActivity().getMenuInflater().inflate(R.menu.feed_menu, menu); AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; - Cursor cursor = (Cursor)m_adapter.getItem(info.position); + Cursor cursor = (Cursor)getFeedAtPosition(info.position); if (cursor != null) 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) { 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(); @@ -175,10 +181,10 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene 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); - list.setAdapter(m_adapter); - list.setOnItemClickListener(this); - list.setEmptyView(view.findViewById(R.id.no_feeds)); - registerForContextMenu(list); + m_list.setAdapter(m_adapter); + m_list.setOnItemClickListener(this); + m_list.setEmptyView(view.findViewById(R.id.no_feeds)); + registerForContextMenu(m_list); 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) { - Cursor c = (Cursor)m_adapter.getItem(position); - - if (c != null) { - int feedId = c.getInt(0); - return feedId; - } - + /* if (m_list != null) { + Cursor c = (Cursor) m_list.getItemAtPosition(position); + + if (c != null) { + int feedId = c.getInt(0); + return feedId; + } + } */ + + Cursor tmp = getFeedAtPosition(position); + + if (tmp != null) { + int id = tmp.getInt(0); + + return id; + } + return -10000; } - + + public Cursor getFeedAtPosition(int position) { + + if (m_list != null) { + return (Cursor) m_list.getItemAtPosition(position); + } + + return null; + } + public void setSelectedFeedId(int feedId) { m_selectedFeedId = feedId; refresh(); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java index 8c0b26b5..b47e184e 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java @@ -70,6 +70,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis private SwipeRefreshLayout m_swipeLayout; private boolean m_compactLayoutMode = false; + private ListView m_list; public void initialize(int feedId, boolean isCat, boolean compactMode) { m_feedId = feedId; @@ -302,12 +303,12 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis m_cursor = createCursor(); - ListView list = (ListView)view.findViewById(R.id.headlines_list); + m_list = (ListView)view.findViewById(R.id.headlines_list); - /* if (!m_compactLayoutMode) { - list.setDividerHeight(0); - list.setDivider(null); - } */ + if (m_activity.isSmallScreen()) { + View layout = inflater.inflate(R.layout.headlines_heading_spacer, m_list, false); + m_list.addHeaderView(layout); + } if (m_prefs.getBoolean("headlines_mark_read_scroll", false)) { 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)); - list.addFooterView(layout, null, false); + m_list.addFooterView(layout, null, false); } m_adapter = new ArticleListAdapter(getActivity(), R.layout.headlines_row, m_cursor, new String[] { "title" }, new int[] { R.id.title }, 0); - list.setAdapter(m_adapter); - list.setOnItemClickListener(this); - list.setOnScrollListener(this); - //list.setEmptyView(view.findViewById(R.id.no_headlines)); - registerForContextMenu(list); + m_list.setAdapter(m_adapter); + m_list.setOnItemClickListener(this); + m_list.setOnScrollListener(this); + registerForContextMenu(m_list); return view; } @@ -821,7 +821,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis int id = c.getInt(0); return id; } */ - + return (int) m_adapter.getItemId(position); } |