From 51dcfe817f1da62c3dd4a76dda9a1aafbf146c2e Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 1 Jun 2017 23:51:56 +0300 Subject: [PATCH] experimental: track selected feed/cat in phone mode --- .../org/fox/ttrss/FeedCategoriesFragment.java | 13 +++++-------- .../main/java/org/fox/ttrss/FeedsFragment.java | 15 +++++++++++---- .../main/java/org/fox/ttrss/MasterActivity.java | 9 ++++++--- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java index 3764e1c5..45568c92 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java @@ -425,7 +425,7 @@ public class FeedCategoriesFragment extends BaseFeedlistFragment implements OnIt public int getItemViewType(int position) { FeedCategory cat = items.get(position); - if (!m_activity.isSmallScreen() && m_selectedCat != null && cat.id == m_selectedCat.id) { + if (/*!m_activity.isSmallScreen() &&*/ m_selectedCat != null && cat.id == m_selectedCat.id) { return VIEW_SELECTED; } else { return VIEW_NORMAL; @@ -509,6 +509,9 @@ public class FeedCategoriesFragment extends BaseFeedlistFragment implements OnIt FeedCategory cat = (FeedCategory)list.getItemAtPosition(position); + m_selectedCat = null; + m_adapter.notifyDataSetChanged(); + if (cat != null) { if (cat.id < 0) { m_activity.onCatSelected(cat, false); @@ -516,9 +519,6 @@ public class FeedCategoriesFragment extends BaseFeedlistFragment implements OnIt m_activity.onCatSelected(cat); } - m_selectedCat = cat; - - m_adapter.notifyDataSetChanged(); } } } @@ -530,9 +530,6 @@ public class FeedCategoriesFragment extends BaseFeedlistFragment implements OnIt m_adapter.notifyDataSetChanged(); } } - - public FeedCategory getSelectedCategory() { - return m_selectedCat; - } + } diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsFragment.java index 2ef34593..dad91460 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsFragment.java @@ -458,9 +458,8 @@ public class FeedsFragment extends BaseFeedlistFragment implements OnItemClickLi } } - m_selectedFeed = feed; - - m_adapter.notifyDataSetChanged(); + //m_selectedFeed = feed; + //m_adapter.notifyDataSetChanged(); } } @@ -508,7 +507,7 @@ public class FeedsFragment extends BaseFeedlistFragment implements OnItemClickLi public int getItemViewType(int position) { Feed feed = items.get(position); - if (!m_activity.isSmallScreen() && m_selectedFeed != null && feed.id == m_selectedFeed.id) { + if (/*!m_activity.isSmallScreen() &&*/ m_selectedFeed != null && feed.id == m_selectedFeed.id) { return VIEW_SELECTED; } else { return VIEW_NORMAL; @@ -645,4 +644,12 @@ public class FeedsFragment extends BaseFeedlistFragment implements OnItemClickLi return null; } } + + public void setSelectedfeed(Feed feed) { + m_selectedFeed = feed; + + if (m_adapter != null) { + m_adapter.notifyDataSetChanged(); + } + } } diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/MasterActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/MasterActivity.java index 7ebce816..ee9cd729 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/MasterActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/MasterActivity.java @@ -242,7 +242,11 @@ public class MasterActivity extends OnlineActivity implements HeadlinesEventList public void onFeedSelected(Feed feed, final boolean selectedByUser) { - //ImageLoader.getInstance().clearMemoryCache(); + FeedsFragment ff = (FeedsFragment) getSupportFragmentManager().findFragmentByTag(FRAG_FEEDS); + + if (ff != null && ff.isAdded()) { + ff.setSelectedfeed(feed); + } FragmentTransaction ft = getSupportFragmentManager() .beginTransaction(); @@ -256,7 +260,6 @@ public class MasterActivity extends OnlineActivity implements HeadlinesEventList m_feedIsSelected = true; m_userFeedSelected = selectedByUser; - //m_feedWasSelected = true; if (m_drawerLayout != null) { m_drawerLayout.closeDrawers(); @@ -277,7 +280,7 @@ public class MasterActivity extends OnlineActivity implements HeadlinesEventList if (!openAsFeed) { - if (fc != null) { + if (fc != null && fc.isAdded()) { fc.setSelectedCategory(null); }