From 56e0d4bf65ebd35c57bf6c4608b19ff85ca85cbc Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 4 Nov 2014 17:50:14 +0300 Subject: [PATCH] replace manual initmenu calls with invalidateoptionsmenu now that it is available pre-HC --- .../main/java/org/fox/ttrss/ArticlePager.java | 2 +- .../org/fox/ttrss/FeedCategoriesFragment.java | 2 +- .../main/java/org/fox/ttrss/FeedsActivity.java | 10 +++++----- .../main/java/org/fox/ttrss/FeedsFragment.java | 2 +- .../java/org/fox/ttrss/HeadlinesActivity.java | 6 +++--- .../java/org/fox/ttrss/HeadlinesFragment.java | 2 +- .../java/org/fox/ttrss/OnlineActivity.java | 18 +++++++++--------- .../org/fox/ttrss/offline/OfflineActivity.java | 6 +++--- .../ttrss/offline/OfflineFeedsActivity.java | 8 ++------ .../offline/OfflineHeadlinesActivity.java | 4 +--- .../offline/OfflineHeadlinesFragment.java | 4 ++-- 11 files changed, 29 insertions(+), 35 deletions(-) diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticlePager.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticlePager.java index 87ca61dd..3015eec0 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticlePager.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticlePager.java @@ -279,7 +279,7 @@ public class ArticlePager extends Fragment { GlobalState.getInstance().m_activeFeed = m_feed; } - m_activity.initMenu(); + m_activity.invalidateOptionsMenu(); if (!m_activity.isCompatMode() && m_prefs.getBoolean("dim_status_bar", false)) { getView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); 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 5ec0ba60..740d43b9 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java @@ -257,7 +257,7 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe refresh(false); - m_activity.initMenu(); + m_activity.invalidateOptionsMenu(); } @Override diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsActivity.java index 10c4623b..49c482ab 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsActivity.java @@ -353,7 +353,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe return true; case R.id.show_feeds: setUnreadOnly(!getUnreadOnly()); - initMenu(); + invalidateOptionsMenu(); refresh(); return true; case R.id.update_feeds: @@ -373,7 +373,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe @Override protected void loginSuccess(boolean refresh) { - initMenu(); + invalidateOptionsMenu(); if (refresh) refresh(); } @@ -390,12 +390,12 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe @Override public void onResume() { super.onResume(); - initMenu(); + invalidateOptionsMenu(); } @Override public void onArticleListSelectionChange(ArticleList m_selectedArticles) { - initMenu(); + invalidateOptionsMenu(); } public void openFeedArticles(Feed feed) { @@ -428,7 +428,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe overridePendingTransition(R.anim.right_slide_in, 0); } else { - initMenu(); + invalidateOptionsMenu(); } } 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 75b6eb94..a5b0a37a 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsFragment.java @@ -350,7 +350,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh refresh(false); - m_activity.initMenu(); + m_activity.invalidateOptionsMenu(); } @Override diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesActivity.java index 4a04526f..fb68247d 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesActivity.java @@ -151,7 +151,7 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL protected void loginSuccess(boolean refresh) { Log.d(TAG, "loginSuccess"); - initMenu(); + invalidateOptionsMenu(); if (refresh) refresh(); } @@ -221,7 +221,7 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL @Override public void onArticleListSelectionChange(ArticleList m_selectedArticles) { - initMenu(); + invalidateOptionsMenu(); } @Override @@ -267,7 +267,7 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL GlobalState.getInstance().m_activeArticle = article; - initMenu(); + invalidateOptionsMenu(); } diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java index 93e6a8e7..646ac11e 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java @@ -377,7 +377,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, notifyUpdated(); } - m_activity.initMenu(); + m_activity.invalidateOptionsMenu(); } @Override diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java index 4d4cbc22..2d1a0a84 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java @@ -113,7 +113,7 @@ public class OnlineActivity extends CommonActivity { ArticleList selected = hf.getSelectedArticles(); if (selected.size() > 0) { selected.clear(); - initMenu(); + invalidateOptionsMenu(); hf.notifyUpdated(); } } @@ -908,7 +908,7 @@ public class OnlineActivity extends CommonActivity { break; } dialog.cancel(); - initMenu(); + invalidateOptionsMenu(); } }); @@ -934,7 +934,7 @@ public class OnlineActivity extends CommonActivity { ArticleList selected = hf.getSelectedArticles(); if (selected.size() > 0) { selected.clear(); - initMenu(); + invalidateOptionsMenu(); hf.notifyUpdated(); } } @@ -949,7 +949,7 @@ public class OnlineActivity extends CommonActivity { toggleArticlesUnread(selected); hf.notifyUpdated(); - initMenu(); + invalidateOptionsMenu(); } } return true; @@ -963,7 +963,7 @@ public class OnlineActivity extends CommonActivity { toggleArticlesMarked(selected); hf.notifyUpdated(); - initMenu(); + invalidateOptionsMenu(); } } return true; @@ -977,7 +977,7 @@ public class OnlineActivity extends CommonActivity { toggleArticlesPublished(selected); hf.notifyUpdated(); - initMenu(); + invalidateOptionsMenu(); } } return true; @@ -1008,7 +1008,7 @@ public class OnlineActivity extends CommonActivity { if (tmp.size() > 0) { toggleArticlesUnread(tmp); hf.notifyUpdated(); - initMenu(); + invalidateOptionsMenu(); } } } @@ -1331,7 +1331,7 @@ public class OnlineActivity extends CommonActivity { ApiRequest req = new ApiRequest(getApplicationContext()) { protected void onPostExecute(JsonElement result) { //toast(article.marked ? R.string.notify_article_marked : R.string.notify_article_unmarked); - initMenu(); + invalidateOptionsMenu(); } }; @@ -1354,7 +1354,7 @@ public class OnlineActivity extends CommonActivity { ApiRequest req = new ApiRequest(getApplicationContext()) { protected void onPostExecute(JsonElement result) { //toast(article.published ? R.string.notify_article_published : R.string.notify_article_unpublished); - initMenu(); + invalidateOptionsMenu(); } }; diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineActivity.java index fa0eb1b8..56e95400 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineActivity.java @@ -171,7 +171,7 @@ public class OfflineActivity extends CommonActivity { setContentView(R.layout.login); - initMenu(); + invalidateOptionsMenu(); Intent intent = getIntent(); @@ -389,7 +389,7 @@ public class OfflineActivity extends CommonActivity { int which) { selectArticles(ohf.getFeedId(), ohf.getFeedIsCat(), which); - initMenu(); + invalidateOptionsMenu(); refresh(); dialog.cancel(); @@ -788,7 +788,7 @@ public class OfflineActivity extends CommonActivity { ohf.refresh(); } - initMenu(); + invalidateOptionsMenu(); } public void catchupFeed(int feedId, boolean isCat) { diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineFeedsActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineFeedsActivity.java index 9337e521..b82f2486 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineFeedsActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineFeedsActivity.java @@ -104,8 +104,6 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead ft.commit(); } - - initMenu(); } protected void onPostCreate(Bundle savedInstanceState) { @@ -184,7 +182,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead return true; case R.id.show_feeds: setUnreadOnly(!getUnreadOnly()); - initMenu(); + invalidateOptionsMenu(); refresh(); return true; default: @@ -323,7 +321,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead stmt.close(); } - initMenu(); + invalidateOptionsMenu(); if (open) { OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES); @@ -340,8 +338,6 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead } else { refresh(); } - - initMenu(); } diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesActivity.java index 18bf63cd..51cfefeb 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesActivity.java @@ -116,8 +116,6 @@ public class OfflineHeadlinesActivity extends OfflineActivity implements Offline } } - - initMenu(); } protected void onPostCreate(Bundle savedInstanceState) { @@ -172,7 +170,7 @@ public class OfflineHeadlinesActivity extends OfflineActivity implements Offline GlobalState.getInstance().m_selectedArticleId = articleId; - initMenu(); + invalidateOptionsMenu(); 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 245be57b..324f57fb 100644 --- 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 @@ -245,7 +245,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis refresh(); - m_activity.initMenu(); + m_activity.invalidateOptionsMenu(); } public void refresh() { @@ -658,7 +658,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis refresh(); - m_activity.initMenu(); + m_activity.invalidateOptionsMenu(); } });