fix options menu disappearing on refresh

This commit is contained in:
Andrew Dolgov 2012-09-16 22:36:55 +04:00
parent c580d8225a
commit 721c98ce98
6 changed files with 12 additions and 14 deletions

View File

@ -180,6 +180,8 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
refresh(false); refresh(false);
m_activity.initMenu(); m_activity.initMenu();
m_activity.setTitle(R.string.app_name);
} }
@Override @Override

View File

@ -67,23 +67,18 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
protected void initMenu() { protected void initMenu() {
super.initMenu(); super.initMenu();
Log.d(TAG, "initMenu: " + m_menu);
if (m_menu != null && m_sessionId != null) { if (m_menu != null && m_sessionId != null) {
Fragment ff = getSupportFragmentManager().findFragmentByTag(FRAG_FEEDS); Fragment ff = getSupportFragmentManager().findFragmentByTag(FRAG_FEEDS);
Fragment cf = getSupportFragmentManager().findFragmentByTag(FRAG_CATS); Fragment cf = getSupportFragmentManager().findFragmentByTag(FRAG_CATS);
ArticlePager af = (ArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE); ArticlePager af = (ArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);
HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES); 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.isAdded());
m_menu.setGroupVisible(R.id.menu_group_article, af != null && af.isVisible()); 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);
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);
MenuItem item = m_menu.findItem(R.id.show_feeds); MenuItem item = m_menu.findItem(R.id.show_feeds);
@ -92,7 +87,6 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
} else { } else {
item.setTitle(R.string.menu_unread_feeds); item.setTitle(R.string.menu_unread_feeds);
} }
} }
} }
@ -101,6 +95,8 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
FragmentTransaction ft = getSupportFragmentManager() FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction(); .beginTransaction();
TinyApplication.getInstance().m_loadedArticles.clear();
HeadlinesFragment hf = new HeadlinesFragment(feed); HeadlinesFragment hf = new HeadlinesFragment(feed);
if (isSmallScreen()) { if (isSmallScreen()) {
@ -188,6 +184,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
initMenu();
} }
@Override @Override

View File

@ -205,6 +205,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
refresh(false); refresh(false);
m_activity.initMenu(); m_activity.initMenu();
m_activity.setTitle(R.string.app_name);
} }
@Override @Override

View File

@ -61,7 +61,6 @@ private final String TAG = this.getClass().getSimpleName();
ft.replace(R.id.article_fragment, af, FRAG_ARTICLE); ft.replace(R.id.article_fragment, af, FRAG_ARTICLE);
ft.commit(); ft.commit();
} }
} }
} }

View File

@ -308,6 +308,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
notifyUpdated(); notifyUpdated();
} }
m_activity.setTitle(m_feed.title);
m_activity.initMenu(); m_activity.initMenu();
} }

View File

@ -738,8 +738,6 @@ public class OnlineActivity extends CommonActivity {
protected void initMenu() { protected void initMenu() {
Log.d(TAG, "initMenu:" + m_menu);
if (m_menu != null) { if (m_menu != null) {
if (m_sessionId != null) { if (m_sessionId != null) {
m_menu.setGroupVisible(R.id.menu_group_logged_in, true); m_menu.setGroupVisible(R.id.menu_group_logged_in, true);