From ff63819a65d47536332655947eeb92013a940f8e Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 24 Jun 2012 23:34:16 +0400 Subject: [PATCH] minor code cleanup --- src/org/fox/ttrss/FeedCategoriesFragment.java | 2 +- src/org/fox/ttrss/FeedsFragment.java | 2 +- src/org/fox/ttrss/HeadlinesFragment.java | 10 +-- src/org/fox/ttrss/MainActivity.java | 62 +++++++++---------- src/org/fox/ttrss/OnlineServices.java | 13 ++-- .../fox/ttrss/offline/OfflineActivity.java | 4 +- 6 files changed, 44 insertions(+), 49 deletions(-) diff --git a/src/org/fox/ttrss/FeedCategoriesFragment.java b/src/org/fox/ttrss/FeedCategoriesFragment.java index ac75bdba..3316fb6a 100644 --- a/src/org/fox/ttrss/FeedCategoriesFragment.java +++ b/src/org/fox/ttrss/FeedCategoriesFragment.java @@ -144,7 +144,7 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe out.putParcelable("cats", m_cats); } - public void setLoadingStatus(int status, boolean showProgress) { + private void setLoadingStatus(int status, boolean showProgress) { if (getView() != null) { TextView tv = (TextView)getView().findViewById(R.id.loading_message); diff --git a/src/org/fox/ttrss/FeedsFragment.java b/src/org/fox/ttrss/FeedsFragment.java index 18c2fb8c..01d60609 100644 --- a/src/org/fox/ttrss/FeedsFragment.java +++ b/src/org/fox/ttrss/FeedsFragment.java @@ -245,7 +245,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh } } - public void setLoadingStatus(int status, boolean showProgress) { + private void setLoadingStatus(int status, boolean showProgress) { if (getView() != null) { TextView tv = (TextView)getView().findViewById(R.id.loading_message); diff --git a/src/org/fox/ttrss/HeadlinesFragment.java b/src/org/fox/ttrss/HeadlinesFragment.java index 56b7edd1..d4adf744 100644 --- a/src/org/fox/ttrss/HeadlinesFragment.java +++ b/src/org/fox/ttrss/HeadlinesFragment.java @@ -180,7 +180,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, article.unread = false; m_onlineServices.saveArticleUnread(article); } else { - m_onlineServices.openArticle(article, 0); + m_onlineServices.onArticleSelected(article); } m_activeArticle = article; @@ -252,7 +252,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, out.putCharSequence("searchQuery", m_searchQuery); } - public void setLoadingStatus(int status, boolean showProgress) { + private void setLoadingStatus(int status, boolean showProgress) { if (getView() != null) { TextView tv = (TextView)getView().findViewById(R.id.loading_message); @@ -589,7 +589,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, m_selectedArticles.remove(article); } - m_onlineServices.initMainMenu(); + m_onlineServices.onArticleListSelectionChange(m_selectedArticles); Log.d(TAG, "num selected: " + m_selectedArticles.size()); } @@ -602,13 +602,13 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, - public void notifyUpdated() { + /* public void notifyUpdated() { m_adapter.notifyDataSetChanged(); Article article = m_onlineServices.getSelectedArticle(); setActiveArticle(article); - } + } */ public ArticleList getAllArticles() { return m_articles; diff --git a/src/org/fox/ttrss/MainActivity.java b/src/org/fox/ttrss/MainActivity.java index 1a966507..38589338 100644 --- a/src/org/fox/ttrss/MainActivity.java +++ b/src/org/fox/ttrss/MainActivity.java @@ -332,7 +332,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices { HeadlinesFragment frag = (HeadlinesFragment) getSupportFragmentManager() .findFragmentByTag(FRAG_HEADLINES); if (frag != null) { - frag.notifyUpdated(); + frag.setActiveArticle(m_selectedArticle); } } @@ -997,7 +997,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices { if (selected.size() > 0) { selected.clear(); initMainMenu(); - hf.notifyUpdated(); + updateHeadlines(); } } } @@ -1201,7 +1201,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices { for (Article a : articles) a.unread = false; - hf.notifyUpdated(); + updateHeadlines(); ApiRequest req = new ApiRequest(getApplicationContext()); @@ -1231,7 +1231,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices { if (m_selectedArticle != null) { m_selectedArticle.marked = !m_selectedArticle.marked; saveArticleMarked(m_selectedArticle); - //updateHeadlines(); + updateHeadlines(); } return true; case R.id.selection_select_none: @@ -1246,7 +1246,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices { a.unread = !a.unread; toggleArticlesUnread(selected); - hf.notifyUpdated(); + updateHeadlines(); } refresh(); } @@ -1260,7 +1260,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices { a.marked = !a.marked; toggleArticlesMarked(selected); - hf.notifyUpdated(); + updateHeadlines(); } } return true; @@ -1273,7 +1273,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices { a.published = !a.published; toggleArticlesPublished(selected); - hf.notifyUpdated(); + updateHeadlines(); } } return true; @@ -1297,7 +1297,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices { } if (tmp.size() > 0) { toggleArticlesUnread(tmp); - hf.notifyUpdated(); + updateHeadlines(); } } } @@ -1471,7 +1471,6 @@ public class MainActivity extends FragmentActivity implements OnlineServices { } @SuppressLint({ "NewApi", "NewApi", "NewApi" }) - @Override public void initMainMenu() { if (m_menu != null) { @@ -1893,8 +1892,13 @@ public class MainActivity extends FragmentActivity implements OnlineServices { initMainMenu(); } + + @Override + public void onArticleSelected(Article article) { + openArticle(article); + } - public void openArticle(Article article, int compatAnimation) { + public void openArticle(Article article) { m_selectedArticle = article; if (article.unread) { @@ -1904,13 +1908,6 @@ public class MainActivity extends FragmentActivity implements OnlineServices { initMainMenu(); - HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager() - .findFragmentByTag(FRAG_HEADLINES); - - if (hf != null) { - hf.setActiveArticle(article); - } - Fragment frag; if (m_smallScreenMode || m_prefs.getBoolean("tablet_article_swipe", false)) { @@ -2105,13 +2102,13 @@ public class MainActivity extends FragmentActivity implements OnlineServices { a.marked = !a.marked; toggleArticlesMarked(selected); - hf.notifyUpdated(); + updateHeadlines(); } else { Article article = hf.getArticleAtPosition(info.position); if (article != null) { article.marked = !article.marked; saveArticleMarked(article); - hf.notifyUpdated(); + updateHeadlines(); } } } @@ -2125,13 +2122,13 @@ public class MainActivity extends FragmentActivity implements OnlineServices { a.published = !a.published; toggleArticlesPublished(selected); - hf.notifyUpdated(); + updateHeadlines(); } else { Article article = hf.getArticleAtPosition(info.position); if (article != null) { article.published = !article.published; saveArticlePublished(article); - hf.notifyUpdated(); + updateHeadlines(); } } } @@ -2145,13 +2142,13 @@ public class MainActivity extends FragmentActivity implements OnlineServices { a.unread = !a.unread; toggleArticlesUnread(selected); - hf.notifyUpdated(); + updateHeadlines(); } else { Article article = hf.getArticleAtPosition(info.position); if (article != null) { article.unread = !article.unread; saveArticleUnread(article); - hf.notifyUpdated(); + updateHeadlines(); } } } @@ -2177,7 +2174,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices { } if (tmp.size() > 0) { toggleArticlesUnread(tmp); - hf.notifyUpdated(); + updateHeadlines(); } } } @@ -2194,8 +2191,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices { } } - @Override - public Article getRelativeArticle(Article article, RelativeArticle ra) { + private Article getRelativeArticle(Article article, RelativeArticle ra) { HeadlinesFragment frag = (HeadlinesFragment) getSupportFragmentManager() .findFragmentByTag(FRAG_HEADLINES); if (frag != null) { @@ -2249,7 +2245,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices { next.unread = false; saveArticleUnread(next); } else { - openArticle(next, 0); + openArticle(next); } } } @@ -2277,7 +2273,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices { prev.unread = false; saveArticleUnread(prev); } else { - openArticle(prev, 0); + openArticle(prev); } } } @@ -2319,11 +2315,6 @@ public class MainActivity extends FragmentActivity implements OnlineServices { toast.show(); } - private void _closeFeed() { - if (m_activeFeed != null) { - } - } - @Override public void restart() { Intent refresh = new Intent(MainActivity.this, MainActivity.class); @@ -2331,4 +2322,9 @@ public class MainActivity extends FragmentActivity implements OnlineServices { startActivity(refresh); finish(); } + + @Override + public void onArticleListSelectionChange(ArticleList selection) { + initMainMenu(); + } } \ No newline at end of file diff --git a/src/org/fox/ttrss/OnlineServices.java b/src/org/fox/ttrss/OnlineServices.java index e8521b77..330751a2 100644 --- a/src/org/fox/ttrss/OnlineServices.java +++ b/src/org/fox/ttrss/OnlineServices.java @@ -1,31 +1,30 @@ package org.fox.ttrss; import org.fox.ttrss.types.Article; +import org.fox.ttrss.types.ArticleList; import org.fox.ttrss.types.Feed; import org.fox.ttrss.types.FeedCategory; public interface OnlineServices { public enum RelativeArticle { BEFORE, AFTER }; - public Article getSelectedArticle(); public void saveArticleUnread(final Article article); public void saveArticleMarked(final Article article); public void saveArticlePublished(final Article article); - public void openArticle(Article article, int compatAnimation); - public Article getRelativeArticle(Article article, RelativeArticle ra); + public void setSelectedArticle(Article article); + public boolean getUnreadArticlesOnly(); public void onCatSelected(FeedCategory cat); public void onFeedSelected(Feed feed); + public void onArticleSelected(Article article); + public void onArticleListSelectionChange(ArticleList selection); - public void initMainMenu(); - //public void login(); + //public void initMainMenu(); public void restart(); public String getSessionId(); - public boolean getUnreadArticlesOnly(); public boolean isSmallScreen(); public boolean getUnreadOnly(); public int getApiLevel(); - public void setSelectedArticle(Article article); public int getOrientation(); public void copyToClipboard(String str); diff --git a/src/org/fox/ttrss/offline/OfflineActivity.java b/src/org/fox/ttrss/offline/OfflineActivity.java index ad243f16..3a11b87e 100644 --- a/src/org/fox/ttrss/offline/OfflineActivity.java +++ b/src/org/fox/ttrss/offline/OfflineActivity.java @@ -1461,12 +1461,12 @@ public class OfflineActivity extends FragmentActivity implements initMainMenu(); - OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment) getSupportFragmentManager() + /* OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment) getSupportFragmentManager() .findFragmentByTag(FRAG_HEADLINES); if (hf != null) { hf.setActiveArticleId(articleId); - } + } */ SQLiteStatement stmt = getWritableDb().compileStatement( "UPDATE articles SET unread = 0 " + "WHERE " + BaseColumns._ID