From 4101ecebeed206f639f836fae76be60c39e6670f Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 24 Jun 2012 15:17:26 +0400 Subject: [PATCH] properly deselect active feed when going back in tablet mode other layout-related fixes --- src/org/fox/ttrss/FeedsFragment.java | 3 +- src/org/fox/ttrss/MainActivity.java | 68 +++++++++++-------- .../fox/ttrss/offline/OfflineActivity.java | 3 +- 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/src/org/fox/ttrss/FeedsFragment.java b/src/org/fox/ttrss/FeedsFragment.java index c37aefaf..480d2ccb 100644 --- a/src/org/fox/ttrss/FeedsFragment.java +++ b/src/org/fox/ttrss/FeedsFragment.java @@ -584,7 +584,8 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh } public void setSelectedFeed(Feed feed) { - m_selectedFeed = feed; + m_selectedFeed = feed; + m_adapter.notifyDataSetChanged(); } } diff --git a/src/org/fox/ttrss/MainActivity.java b/src/org/fox/ttrss/MainActivity.java index 46b65771..04a5a725 100644 --- a/src/org/fox/ttrss/MainActivity.java +++ b/src/org/fox/ttrss/MainActivity.java @@ -560,15 +560,18 @@ public class MainActivity extends FragmentActivity implements OnlineServices { private synchronized void refresh() { Date date = new Date(); + + boolean canRefresh = date.getTime() - m_lastRefresh > 5000; - if (m_sessionId != null && date.getTime() - m_lastRefresh > 5000) { + if (m_sessionId != null) { FeedsFragment ff = (FeedsFragment) getSupportFragmentManager() .findFragmentByTag(FRAG_FEEDS); if (ff != null) { Log.d(TAG, "Refreshing feeds..."); - ff.refresh(true); + if (canRefresh) ff.refresh(true); + ff.setSelectedFeed(m_activeFeed); } FeedCategoriesFragment cf = (FeedCategoriesFragment) getSupportFragmentManager() @@ -576,10 +579,11 @@ public class MainActivity extends FragmentActivity implements OnlineServices { if (cf != null) { Log.d(TAG, "Refreshing categories..."); - cf.refresh(true); + if (canRefresh) cf.refresh(true); + cf.setSelectedCategory(m_activeCategory); } - m_lastRefresh = date.getTime(); + if (canRefresh) m_lastRefresh = date.getTime(); } } @@ -1024,6 +1028,8 @@ public class MainActivity extends FragmentActivity implements OnlineServices { ft.replace(R.id.headlines_fragment, new DummyFragment(), ""); ft.commit(); + refresh(); + initMainMenu(); } else if (m_activeCategory != null) { closeCategory(); @@ -2303,40 +2309,44 @@ public class MainActivity extends FragmentActivity implements OnlineServices { } private void closeFeed() { - if (m_smallScreenMode && m_activeFeed != null) { - if (m_activeFeed.is_cat) { - FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - - Fragment headlines = getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES); - FeedCategoriesFragment cats = (FeedCategoriesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_CATS); - - ft.show(cats); - ft.remove(headlines); - - cats.setSelectedCategory(null); - - //ft.replace(R.id.fragment_container, new FeedCategoriesFragment(), FRAG_CATS); - ft.commit(); + if (m_activeFeed != null) { + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + + if (m_smallScreenMode) { + if (m_activeFeed.is_cat) { + + Fragment headlines = getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES); + FeedCategoriesFragment cats = (FeedCategoriesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_CATS); + + ft.show(cats); + ft.remove(headlines); + + //cats.setSelectedCategory(null); + + //ft.replace(R.id.fragment_container, new FeedCategoriesFragment(), FRAG_CATS); + } else { + Fragment headlines = getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES); + FeedsFragment feeds = (FeedsFragment) getSupportFragmentManager().findFragmentByTag(FRAG_FEEDS); + + ft.show(feeds); + ft.remove(headlines); + + //feeds.setSelectedFeed(null); + + } } else { - FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - Fragment headlines = getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES); - FeedsFragment feeds = (FeedsFragment) getSupportFragmentManager().findFragmentByTag(FRAG_FEEDS); - - ft.show(feeds); ft.remove(headlines); - - feeds.setSelectedFeed(null); - - ft.commit(); - } + } + ft.commit(); } - + m_activeFeed = null; refresh(); initMainMenu(); + } @Override diff --git a/src/org/fox/ttrss/offline/OfflineActivity.java b/src/org/fox/ttrss/offline/OfflineActivity.java index 86c51839..9240bd44 100644 --- a/src/org/fox/ttrss/offline/OfflineActivity.java +++ b/src/org/fox/ttrss/offline/OfflineActivity.java @@ -1490,7 +1490,8 @@ public class OfflineActivity extends FragmentActivity implements ft.hide(getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES)); ft.add(R.id.fragment_container, frag, FRAG_ARTICLE); } else { - findViewById(R.id.article_fragment).setVisibility(View.VISIBLE); + findViewById(R.id.feeds_fragment).setVisibility(getOrientation() % 2 != 0 ? View.GONE : View.VISIBLE); + findViewById(R.id.article_fragment).setVisibility(View.VISIBLE); ft.replace(R.id.article_fragment, frag, FRAG_ARTICLE); refreshViews();