From 721c98ce98f8220f1d43d2e38591ed8638287174 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 16 Sep 2012 22:36:55 +0400 Subject: [PATCH] fix options menu disappearing on refresh --- src/org/fox/ttrss/FeedCategoriesFragment.java | 2 ++ src/org/fox/ttrss/FeedsActivity.java | 19 ++++++++----------- src/org/fox/ttrss/FeedsFragment.java | 1 + src/org/fox/ttrss/HeadlinesActivity.java | 1 - src/org/fox/ttrss/HeadlinesFragment.java | 1 + src/org/fox/ttrss/OnlineActivity.java | 2 -- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/org/fox/ttrss/FeedCategoriesFragment.java b/src/org/fox/ttrss/FeedCategoriesFragment.java index 9af914b9..92def44a 100644 --- a/src/org/fox/ttrss/FeedCategoriesFragment.java +++ b/src/org/fox/ttrss/FeedCategoriesFragment.java @@ -180,6 +180,8 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe refresh(false); m_activity.initMenu(); + m_activity.setTitle(R.string.app_name); + } @Override diff --git a/src/org/fox/ttrss/FeedsActivity.java b/src/org/fox/ttrss/FeedsActivity.java index 1bc5dc96..b3f4a3da 100644 --- a/src/org/fox/ttrss/FeedsActivity.java +++ b/src/org/fox/ttrss/FeedsActivity.java @@ -67,23 +67,18 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe protected void initMenu() { super.initMenu(); - Log.d(TAG, "initMenu: " + m_menu); - if (m_menu != null && m_sessionId != null) { Fragment ff = getSupportFragmentManager().findFragmentByTag(FRAG_FEEDS); Fragment cf = getSupportFragmentManager().findFragmentByTag(FRAG_CATS); ArticlePager af = (ArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE); - HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES); - Log.d(TAG, "ff/cf/af/hf " + ff + " " + cf + " " + af + " " + hf); + m_menu.setGroupVisible(R.id.menu_group_feeds, (ff != null && ff.isAdded()) || (cf != null && cf.isAdded())); - m_menu.setGroupVisible(R.id.menu_group_feeds, (ff != null && ff.isVisible()) || (cf != null && cf.isVisible())); - - m_menu.setGroupVisible(R.id.menu_group_article, af != null && af.isVisible()); + m_menu.setGroupVisible(R.id.menu_group_article, af != null && af.isAdded()); - m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isVisible() && hf.getSelectedArticles().size() == 0); - m_menu.setGroupVisible(R.id.menu_group_headlines_selection, hf != null && hf.isVisible() && hf.getSelectedArticles().size() != 0); + m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isAdded() && hf.getSelectedArticles().size() == 0); + m_menu.setGroupVisible(R.id.menu_group_headlines_selection, hf != null && hf.isAdded() && hf.getSelectedArticles().size() != 0); MenuItem item = m_menu.findItem(R.id.show_feeds); @@ -92,7 +87,6 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe } else { item.setTitle(R.string.menu_unread_feeds); } - } } @@ -101,6 +95,8 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe FragmentTransaction ft = getSupportFragmentManager() .beginTransaction(); + TinyApplication.getInstance().m_loadedArticles.clear(); + HeadlinesFragment hf = new HeadlinesFragment(feed); if (isSmallScreen()) { @@ -171,7 +167,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe return super.onOptionsItemSelected(item); } } - + @Override protected void loginSuccess() { setLoadingStatus(R.string.blank, false); @@ -188,6 +184,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe @Override public void onResume() { super.onResume(); + initMenu(); } @Override diff --git a/src/org/fox/ttrss/FeedsFragment.java b/src/org/fox/ttrss/FeedsFragment.java index 1153172c..a1eb9794 100644 --- a/src/org/fox/ttrss/FeedsFragment.java +++ b/src/org/fox/ttrss/FeedsFragment.java @@ -205,6 +205,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh refresh(false); m_activity.initMenu(); + m_activity.setTitle(R.string.app_name); } @Override diff --git a/src/org/fox/ttrss/HeadlinesActivity.java b/src/org/fox/ttrss/HeadlinesActivity.java index 6da308ba..e98101cc 100644 --- a/src/org/fox/ttrss/HeadlinesActivity.java +++ b/src/org/fox/ttrss/HeadlinesActivity.java @@ -61,7 +61,6 @@ private final String TAG = this.getClass().getSimpleName(); ft.replace(R.id.article_fragment, af, FRAG_ARTICLE); ft.commit(); - } } } diff --git a/src/org/fox/ttrss/HeadlinesFragment.java b/src/org/fox/ttrss/HeadlinesFragment.java index a312c237..4ca85661 100644 --- a/src/org/fox/ttrss/HeadlinesFragment.java +++ b/src/org/fox/ttrss/HeadlinesFragment.java @@ -308,6 +308,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, notifyUpdated(); } + m_activity.setTitle(m_feed.title); m_activity.initMenu(); } diff --git a/src/org/fox/ttrss/OnlineActivity.java b/src/org/fox/ttrss/OnlineActivity.java index f97c07d7..140b21e5 100644 --- a/src/org/fox/ttrss/OnlineActivity.java +++ b/src/org/fox/ttrss/OnlineActivity.java @@ -738,8 +738,6 @@ public class OnlineActivity extends CommonActivity { protected void initMenu() { - Log.d(TAG, "initMenu:" + m_menu); - if (m_menu != null) { if (m_sessionId != null) { m_menu.setGroupVisible(R.id.menu_group_logged_in, true);