properly restore state when going back from headlinesactivity
This commit is contained in:
parent
306a0bf4c9
commit
c580d8225a
@ -39,11 +39,6 @@
|
||||
|
||||
<group android:id="@+id/menu_group_headlines" >
|
||||
|
||||
<item
|
||||
android:id="@+id/go_offline"
|
||||
android:icon="@drawable/ic_menu_cloud"
|
||||
android:title="@string/go_offline"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/search"
|
||||
android:actionViewClass="android.widget.SearchView"
|
||||
|
@ -123,7 +123,7 @@ public class ArticlePager extends Fragment {
|
||||
|
||||
m_onlineServices = (HeadlinesEventListener)activity;
|
||||
|
||||
m_articles = TinyApplication.getInstance().m_articles;
|
||||
m_articles = TinyApplication.getInstance().m_loadedArticles;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -135,6 +135,13 @@ private final String TAG = this.getClass().getSimpleName();
|
||||
@Override
|
||||
public void onArticleSelected(Article article, boolean open) {
|
||||
|
||||
if (article.unread) {
|
||||
article.unread = false;
|
||||
saveArticleUnread(article);
|
||||
}
|
||||
|
||||
//TinyApplication.getInstance().m_activeArticle = article;
|
||||
|
||||
if (open) {
|
||||
FragmentTransaction ft = getSupportFragmentManager()
|
||||
.beginTransaction();
|
||||
@ -145,11 +152,14 @@ private final String TAG = this.getClass().getSimpleName();
|
||||
|
||||
ft.replace(R.id.article_fragment, frag, FRAG_ARTICLE);
|
||||
//ft.addToBackStack(null);
|
||||
|
||||
hf.notifyUpdated();
|
||||
|
||||
ft.commit();
|
||||
} else {
|
||||
HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
||||
if (hf != null) hf.setActiveArticle(article);
|
||||
hf.setActiveArticle(article);
|
||||
|
||||
initMenu();
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
private SharedPreferences m_prefs;
|
||||
|
||||
private ArticleListAdapter m_adapter;
|
||||
private ArticleList m_articles = TinyApplication.getInstance().m_articles;
|
||||
private ArticleList m_articles = TinyApplication.getInstance().m_loadedArticles;
|
||||
private ArticleList m_selectedArticles = new ArticleList();
|
||||
private HeadlinesEventListener m_listener;
|
||||
|
||||
@ -295,9 +295,17 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
if (m_articles.size() == 0 || !m_feed.equals(TinyApplication.getInstance().m_feed)) {
|
||||
/* if (TinyApplication.getInstance().m_activeArticle != null) {
|
||||
m_activeArticle = TinyApplication.getInstance().m_activeArticle;
|
||||
notifyUpdated();
|
||||
TinyApplication.getInstance().m_activeArticle = null;
|
||||
} */
|
||||
|
||||
if (m_articles.size() == 0 || !m_feed.equals(TinyApplication.getInstance().m_activeFeed)) {
|
||||
refresh(false);
|
||||
TinyApplication.getInstance().m_feed = m_feed;
|
||||
TinyApplication.getInstance().m_activeFeed = m_feed;
|
||||
} else {
|
||||
notifyUpdated();
|
||||
}
|
||||
|
||||
m_activity.initMenu();
|
||||
@ -329,7 +337,11 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
m_listener.onArticleSelected(article);
|
||||
}
|
||||
|
||||
m_activeArticle = article;
|
||||
// only set active article when it makes sense (in HeadlinesActivity)
|
||||
if (getActivity().findViewById(R.id.article_fragment) != null) {
|
||||
m_activeArticle = article;
|
||||
}
|
||||
|
||||
m_adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.fox.ttrss;
|
||||
|
||||
import org.fox.ttrss.types.Article;
|
||||
import org.fox.ttrss.types.ArticleList;
|
||||
import org.fox.ttrss.types.Feed;
|
||||
|
||||
@ -9,9 +8,8 @@ import android.app.Application;
|
||||
public class TinyApplication extends Application {
|
||||
private static TinyApplication m_singleton;
|
||||
|
||||
public ArticleList m_articles = new ArticleList();
|
||||
public Feed m_feed;
|
||||
public Article m_selectedArticle;
|
||||
public ArticleList m_loadedArticles = new ArticleList();
|
||||
public Feed m_activeFeed;
|
||||
|
||||
public static TinyApplication getInstance(){
|
||||
return m_singleton;
|
||||
|
Loading…
Reference in New Issue
Block a user