diff options
author | Andrew Dolgov <[email protected]> | 2015-02-10 16:04:23 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2015-02-10 16:16:56 +0300 |
commit | c00b9e724ef53796fe5cb576cf125a8b15500fc1 (patch) | |
tree | 45c42e387b99370b0bc50d1becd82a254a24c855 /org.fox.ttrss/src | |
parent | 7604bb30e51f7716356e4124915567c4c9a30987 (diff) |
properly restore fragment states on resume/rotate
Diffstat (limited to 'org.fox.ttrss/src')
4 files changed, 13 insertions, 5 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 40bc4c97..76703b0d 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 @@ -80,6 +80,7 @@ public class ArticlePager extends Fragment { if (savedInstanceState != null) { m_article = savedInstanceState.getParcelable("article"); + m_articles = ((HeadlinesActivity)m_activity).m_articles; m_feed = savedInstanceState.getParcelable("feed"); } 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 4e81d26f..42f9d912 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 @@ -478,7 +478,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { - if (requestCode == HEADLINES_REQUEST) { + if (requestCode == HEADLINES_REQUEST && data != null) { //GlobalState.getInstance().m_activeArticle = null; //ArrayList<Article> tmp = data.getParcelableArrayListExtra("articles"); 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 52811172..6a25db7f 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 @@ -20,7 +20,7 @@ import org.fox.ttrss.types.Feed; public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventListener { private final String TAG = this.getClass().getSimpleName(); - private ArticleList m_articles = new ArticleList(); + protected ArticleList m_articles = new ArticleList(); protected SharedPreferences m_prefs; private Article m_activeArticle; @@ -49,8 +49,7 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL } if (savedInstanceState != null) { - // - + m_articles = savedInstanceState.getParcelable("articles"); } else { Intent i = getIntent(); @@ -145,6 +144,8 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL @Override public void onSaveInstanceState(Bundle out) { super.onSaveInstanceState(out); + + out.putParcelable("articles", m_articles); GlobalState.getInstance().save(out); } 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 6733b363..25a5dee8 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 @@ -301,7 +301,13 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, if (savedInstanceState != null) { m_feed = savedInstanceState.getParcelable("feed"); - m_articles = savedInstanceState.getParcelable("articles"); + + if (! (m_activity instanceof HeadlinesActivity)) { + m_articles = savedInstanceState.getParcelable("articles"); + } else { + m_articles = ((HeadlinesActivity)m_activity).m_articles; + } + m_activeArticle = savedInstanceState.getParcelable("activeArticle"); m_selectedArticles = savedInstanceState.getParcelable("selectedArticles"); m_searchQuery = (String) savedInstanceState.getCharSequence("searchQuery"); |