diff options
Diffstat (limited to 'org.fox.ttrss/src/main/java/org/fox/ttrss/ArticlePager.java')
-rwxr-xr-x | org.fox.ttrss/src/main/java/org/fox/ttrss/ArticlePager.java | 40 |
1 files changed, 12 insertions, 28 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 5db142b4..e0714786 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticlePager.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticlePager.java @@ -27,18 +27,20 @@ import org.fox.ttrss.util.HeadlinesRequest; import java.util.HashMap; -public class ArticlePager extends Fragment { +import icepick.State; + +public class ArticlePager extends StateSavedFragment { private final String TAG = "ArticlePager"; private PagerAdapter m_adapter; private HeadlinesEventListener m_listener; - private Article m_article; - private ArticleList m_articles = new ArticleList(); //m_articles = Application.getInstance().m_loadedArticles; + @State protected Article m_article; + @State protected ArticleList m_articles = new ArticleList(); //m_articles = Application.getInstance().m_loadedArticles; private OnlineActivity m_activity; private String m_searchQuery = ""; - private Feed m_feed; + @State protected Feed m_feed; private SharedPreferences m_prefs; - private int m_firstId = 0; + @State protected int m_firstId = 0; private boolean m_refreshInProgress; private boolean m_lazyLoadDisabled; @@ -108,21 +110,14 @@ public class ArticlePager extends Fragment { View view = inflater.inflate(R.layout.article_pager, container, false); if (savedInstanceState != null) { - m_article = savedInstanceState.getParcelable("article"); - - if (! (m_activity instanceof DetailActivity)) { - m_articles = savedInstanceState.getParcelable("articles"); - } else { + if (m_activity instanceof DetailActivity) { m_articles = ((DetailActivity)m_activity).m_articles; } - - m_feed = savedInstanceState.getParcelable("feed"); - m_firstId = savedInstanceState.getInt("firstId"); } m_adapter = new PagerAdapter(getActivity().getSupportFragmentManager()); - ViewPager pager = (ViewPager) view.findViewById(R.id.article_pager); + ViewPager pager = view.findViewById(R.id.article_pager); int position = m_articles.indexOf(m_article); @@ -130,7 +125,7 @@ public class ArticlePager extends Fragment { pager.setAdapter(m_adapter); - UnderlinePageIndicator indicator = (UnderlinePageIndicator)view.findViewById(R.id.article_pager_indicator); + UnderlinePageIndicator indicator = view.findViewById(R.id.article_pager_indicator); indicator.setViewPager(pager); pager.setCurrentItem(position); @@ -200,7 +195,7 @@ public class ArticlePager extends Fragment { if (isDetached() || !isAdded()) return; if (!append) { - ViewPager pager = (ViewPager) getView().findViewById(R.id.article_pager); + ViewPager pager = getView().findViewById(R.id.article_pager); pager.setCurrentItem(0); m_articles.clear(); @@ -339,17 +334,6 @@ public class ArticlePager extends Fragment { } @Override - public void onSaveInstanceState(Bundle out) { - super.onSaveInstanceState(out); - - out.setClassLoader(getClass().getClassLoader()); - out.putParcelable("article", m_article); - out.putParcelable("articles", m_articles); - out.putParcelable("feed", m_feed); - out.putInt("firstId", m_firstId); - } - - @Override public void onAttach(Activity activity) { super.onAttach(activity); @@ -379,7 +363,7 @@ public class ArticlePager extends Fragment { int position = m_articles.indexOf(m_article); - ViewPager pager = (ViewPager) getView().findViewById(R.id.article_pager); + ViewPager pager = getView().findViewById(R.id.article_pager); pager.setCurrentItem(position); } |