fix layout weirdness caused by articlepager on several consequent

rotates
This commit is contained in:
Andrew Dolgov 2012-01-18 13:19:01 +03:00
parent 6488af111c
commit 94173a7db4
3 changed files with 43 additions and 18 deletions

View File

@ -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;
}
}

View File

@ -526,16 +526,14 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
.setVisibility(View.GONE); .setVisibility(View.GONE);
findViewById(R.id.cats_fragment).setVisibility(View.GONE); findViewById(R.id.cats_fragment).setVisibility(View.GONE);
} else { } else {
//findViewById(R.id.headlines_fragment).setVisibility( findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
// View.GONE); findViewById(R.id.article_fragment).setVisibility(View.GONE);
//findViewById(R.id.article_fragment).setVisibility(View.GONE);
if (m_enableCats && m_activeCategory == null) { if (m_enableCats && m_activeCategory == null) {
findViewById(R.id.feeds_fragment).setVisibility(
View.GONE);
findViewById(R.id.cats_fragment).setVisibility( findViewById(R.id.cats_fragment).setVisibility(
View.VISIBLE); View.VISIBLE);
findViewById(R.id.feeds_fragment).setVisibility(
View.GONE);
} else { } else {
findViewById(R.id.cats_fragment).setVisibility( findViewById(R.id.cats_fragment).setVisibility(
View.GONE); View.GONE);
@ -759,8 +757,8 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
private void closeCategory() { private void closeCategory() {
findViewById(R.id.feeds_fragment).setVisibility(View.GONE);
findViewById(R.id.cats_fragment).setVisibility(View.VISIBLE); findViewById(R.id.cats_fragment).setVisibility(View.VISIBLE);
findViewById(R.id.feeds_fragment).setVisibility(View.GONE);
m_activeCategory = null; m_activeCategory = null;
@ -794,17 +792,16 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
} }
if (m_activeFeed != null && m_activeFeed.is_cat) { if (m_activeFeed != null && m_activeFeed.is_cat) {
findViewById(R.id.headlines_fragment).setVisibility(
View.GONE);
findViewById(R.id.cats_fragment) findViewById(R.id.cats_fragment)
.setVisibility(View.VISIBLE); .setVisibility(View.VISIBLE);
refreshCategories();
} else {
findViewById(R.id.headlines_fragment).setVisibility( findViewById(R.id.headlines_fragment).setVisibility(
View.GONE); View.GONE);
refreshCategories();
} else {
findViewById(R.id.feeds_fragment).setVisibility( findViewById(R.id.feeds_fragment).setVisibility(
View.VISIBLE); View.VISIBLE);
findViewById(R.id.headlines_fragment).setVisibility(
View.GONE);
refreshFeeds(); refreshFeeds();
} }
@ -1141,8 +1138,8 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
// false); // false);
if (m_smallScreenMode) { if (m_smallScreenMode) {
findViewById(R.id.article_fragment).setVisibility(View.GONE);
findViewById(R.id.headlines_fragment).setVisibility(View.VISIBLE); findViewById(R.id.headlines_fragment).setVisibility(View.VISIBLE);
findViewById(R.id.article_fragment).setVisibility(View.GONE);
} else { } else {
findViewById(R.id.article_fragment).setVisibility(View.GONE); findViewById(R.id.article_fragment).setVisibility(View.GONE);
@ -1159,6 +1156,10 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
m_selectedArticle = null; m_selectedArticle = null;
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.article_fragment, new DummyFragment());
ft.commit();
initMainMenu(); initMainMenu();
if (!m_enableCats || m_activeCategory != null) if (!m_enableCats || m_activeCategory != null)
@ -1407,13 +1408,15 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
} }
public void viewFeed(Feed feed, boolean append) { public void viewFeed(Feed feed, boolean append) {
Log.d(TAG, "viewFeeed/" + feed.id);
m_activeFeed = feed; m_activeFeed = feed;
initMainMenu(); initMainMenu();
if (m_smallScreenMode) { if (m_smallScreenMode) {
findViewById(R.id.feeds_fragment).setVisibility(View.GONE);
findViewById(R.id.headlines_fragment).setVisibility(View.VISIBLE); findViewById(R.id.headlines_fragment).setVisibility(View.VISIBLE);
findViewById(R.id.feeds_fragment).setVisibility(View.GONE);
} else { } else {
findViewById(R.id.headlines_fragment).setVisibility(View.VISIBLE); findViewById(R.id.headlines_fragment).setVisibility(View.VISIBLE);
} }
@ -1439,8 +1442,8 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
Log.d(TAG, "viewCategory"); Log.d(TAG, "viewCategory");
if (!openAsFeed) { if (!openAsFeed) {
findViewById(R.id.cats_fragment).setVisibility(View.GONE);
findViewById(R.id.feeds_fragment).setVisibility(View.VISIBLE); findViewById(R.id.feeds_fragment).setVisibility(View.VISIBLE);
findViewById(R.id.cats_fragment).setVisibility(View.GONE);
m_activeCategory = cat; m_activeCategory = cat;
@ -1451,9 +1454,10 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
ft.replace(R.id.feeds_fragment, frag); ft.replace(R.id.feeds_fragment, frag);
ft.commit(); ft.commit();
} else { } else {
findViewById(R.id.headlines_fragment).setVisibility(View.VISIBLE);
if (m_smallScreenMode) if (m_smallScreenMode)
findViewById(R.id.cats_fragment).setVisibility(View.GONE); 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); m_activeFeed = new Feed(cat.id, cat.title, true);
@ -1487,12 +1491,12 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
} }
if (m_smallScreenMode) { if (m_smallScreenMode) {
findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
findViewById(R.id.article_fragment).setVisibility(View.VISIBLE); findViewById(R.id.article_fragment).setVisibility(View.VISIBLE);
findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
} else { } else {
findViewById(R.id.article_fragment).setVisibility(View.VISIBLE);
findViewById(R.id.feeds_fragment).setVisibility(View.GONE); findViewById(R.id.feeds_fragment).setVisibility(View.GONE);
findViewById(R.id.cats_fragment).setVisibility(View.GONE); findViewById(R.id.cats_fragment).setVisibility(View.GONE);
findViewById(R.id.article_fragment).setVisibility(View.VISIBLE);
} }
Fragment frag; Fragment frag;

View File

@ -634,6 +634,10 @@ public class OfflineActivity extends FragmentActivity implements
m_selectedArticleId = 0; m_selectedArticleId = 0;
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.article_fragment, new DummyFragment());
ft.commit();
initMainMenu(); initMainMenu();
} }