From 94173a7db4d046c18fde68c6edf2f6c407b71a8b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 18 Jan 2012 13:19:01 +0300 Subject: [PATCH] fix layout weirdness caused by articlepager on several consequent rotates --- src/org/fox/ttrss/DummyFragment.java | 17 +++++++++++ src/org/fox/ttrss/MainActivity.java | 40 ++++++++++++++------------ src/org/fox/ttrss/OfflineActivity.java | 4 +++ 3 files changed, 43 insertions(+), 18 deletions(-) create mode 100644 src/org/fox/ttrss/DummyFragment.java diff --git a/src/org/fox/ttrss/DummyFragment.java b/src/org/fox/ttrss/DummyFragment.java new file mode 100644 index 00000000..d23af2aa --- /dev/null +++ b/src/org/fox/ttrss/DummyFragment.java @@ -0,0 +1,17 @@ +package org.fox.ttrss; + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +public class DummyFragment extends Fragment { + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + + View view = inflater.inflate(R.layout.article_fragment, container, false); + + return view; + } +} diff --git a/src/org/fox/ttrss/MainActivity.java b/src/org/fox/ttrss/MainActivity.java index df419a41..5fc579af 100644 --- a/src/org/fox/ttrss/MainActivity.java +++ b/src/org/fox/ttrss/MainActivity.java @@ -526,16 +526,14 @@ public class MainActivity extends FragmentActivity implements OnlineServices { .setVisibility(View.GONE); findViewById(R.id.cats_fragment).setVisibility(View.GONE); } else { - //findViewById(R.id.headlines_fragment).setVisibility( - // View.GONE); - - //findViewById(R.id.article_fragment).setVisibility(View.GONE); + findViewById(R.id.headlines_fragment).setVisibility(View.GONE); + findViewById(R.id.article_fragment).setVisibility(View.GONE); if (m_enableCats && m_activeCategory == null) { - findViewById(R.id.feeds_fragment).setVisibility( - View.GONE); findViewById(R.id.cats_fragment).setVisibility( View.VISIBLE); + findViewById(R.id.feeds_fragment).setVisibility( + View.GONE); } else { findViewById(R.id.cats_fragment).setVisibility( View.GONE); @@ -759,8 +757,8 @@ public class MainActivity extends FragmentActivity implements OnlineServices { private void closeCategory() { - findViewById(R.id.feeds_fragment).setVisibility(View.GONE); findViewById(R.id.cats_fragment).setVisibility(View.VISIBLE); + findViewById(R.id.feeds_fragment).setVisibility(View.GONE); m_activeCategory = null; @@ -794,17 +792,16 @@ public class MainActivity extends FragmentActivity implements OnlineServices { } if (m_activeFeed != null && m_activeFeed.is_cat) { + findViewById(R.id.cats_fragment) + .setVisibility(View.VISIBLE); findViewById(R.id.headlines_fragment).setVisibility( View.GONE); - findViewById(R.id.cats_fragment) - .setVisibility(View.VISIBLE); - refreshCategories(); } else { - findViewById(R.id.headlines_fragment).setVisibility( - View.GONE); findViewById(R.id.feeds_fragment).setVisibility( View.VISIBLE); + findViewById(R.id.headlines_fragment).setVisibility( + View.GONE); refreshFeeds(); } @@ -1141,8 +1138,8 @@ public class MainActivity extends FragmentActivity implements OnlineServices { // false); if (m_smallScreenMode) { - findViewById(R.id.article_fragment).setVisibility(View.GONE); findViewById(R.id.headlines_fragment).setVisibility(View.VISIBLE); + findViewById(R.id.article_fragment).setVisibility(View.GONE); } else { findViewById(R.id.article_fragment).setVisibility(View.GONE); @@ -1158,6 +1155,10 @@ public class MainActivity extends FragmentActivity implements OnlineServices { } m_selectedArticle = null; + + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.replace(R.id.article_fragment, new DummyFragment()); + ft.commit(); initMainMenu(); @@ -1407,13 +1408,15 @@ public class MainActivity extends FragmentActivity implements OnlineServices { } public void viewFeed(Feed feed, boolean append) { + Log.d(TAG, "viewFeeed/" + feed.id); + m_activeFeed = feed; initMainMenu(); if (m_smallScreenMode) { - findViewById(R.id.feeds_fragment).setVisibility(View.GONE); findViewById(R.id.headlines_fragment).setVisibility(View.VISIBLE); + findViewById(R.id.feeds_fragment).setVisibility(View.GONE); } else { findViewById(R.id.headlines_fragment).setVisibility(View.VISIBLE); } @@ -1439,8 +1442,8 @@ public class MainActivity extends FragmentActivity implements OnlineServices { Log.d(TAG, "viewCategory"); if (!openAsFeed) { - findViewById(R.id.cats_fragment).setVisibility(View.GONE); findViewById(R.id.feeds_fragment).setVisibility(View.VISIBLE); + findViewById(R.id.cats_fragment).setVisibility(View.GONE); m_activeCategory = cat; @@ -1451,9 +1454,10 @@ public class MainActivity extends FragmentActivity implements OnlineServices { ft.replace(R.id.feeds_fragment, frag); ft.commit(); } else { + findViewById(R.id.headlines_fragment).setVisibility(View.VISIBLE); + if (m_smallScreenMode) findViewById(R.id.cats_fragment).setVisibility(View.GONE); - findViewById(R.id.headlines_fragment).setVisibility(View.VISIBLE); m_activeFeed = new Feed(cat.id, cat.title, true); @@ -1487,12 +1491,12 @@ public class MainActivity extends FragmentActivity implements OnlineServices { } if (m_smallScreenMode) { - findViewById(R.id.headlines_fragment).setVisibility(View.GONE); findViewById(R.id.article_fragment).setVisibility(View.VISIBLE); + findViewById(R.id.headlines_fragment).setVisibility(View.GONE); } else { + findViewById(R.id.article_fragment).setVisibility(View.VISIBLE); findViewById(R.id.feeds_fragment).setVisibility(View.GONE); findViewById(R.id.cats_fragment).setVisibility(View.GONE); - findViewById(R.id.article_fragment).setVisibility(View.VISIBLE); } Fragment frag; diff --git a/src/org/fox/ttrss/OfflineActivity.java b/src/org/fox/ttrss/OfflineActivity.java index 74968893..df63b198 100644 --- a/src/org/fox/ttrss/OfflineActivity.java +++ b/src/org/fox/ttrss/OfflineActivity.java @@ -633,6 +633,10 @@ public class OfflineActivity extends FragmentActivity implements refreshViews(); m_selectedArticleId = 0; + + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.replace(R.id.article_fragment, new DummyFragment()); + ft.commit(); initMainMenu(); }