2012-09-16 17:59:03 +00:00
|
|
|
package org.fox.ttrss;
|
|
|
|
|
2012-11-30 06:08:00 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2012-09-17 08:45:52 +00:00
|
|
|
import org.fox.ttrss.types.Article;
|
2012-09-16 17:59:03 +00:00
|
|
|
import org.fox.ttrss.types.ArticleList;
|
|
|
|
import org.fox.ttrss.types.Feed;
|
|
|
|
|
|
|
|
import android.app.Application;
|
2012-11-30 06:08:00 +00:00
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Parcelable;
|
2012-09-16 17:59:03 +00:00
|
|
|
|
2012-09-17 19:20:59 +00:00
|
|
|
public class GlobalState extends Application {
|
|
|
|
private static GlobalState m_singleton;
|
2012-09-16 17:59:03 +00:00
|
|
|
|
2012-09-16 18:13:32 +00:00
|
|
|
public ArticleList m_loadedArticles = new ArticleList();
|
|
|
|
public Feed m_activeFeed;
|
2012-09-19 09:02:13 +00:00
|
|
|
public Article m_activeArticle;
|
2012-09-17 19:20:59 +00:00
|
|
|
public int m_selectedArticleId;
|
2012-09-19 09:44:35 +00:00
|
|
|
public boolean m_unreadOnly = true;
|
|
|
|
public boolean m_unreadArticlesOnly = true;
|
2012-09-19 09:55:01 +00:00
|
|
|
public String m_sessionId;
|
|
|
|
public int m_apiLevel;
|
2012-09-19 12:07:11 +00:00
|
|
|
public boolean m_canUseProgress;
|
2012-09-16 17:59:03 +00:00
|
|
|
|
2012-09-17 19:20:59 +00:00
|
|
|
public static GlobalState getInstance(){
|
2012-09-16 17:59:03 +00:00
|
|
|
return m_singleton;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public final void onCreate() {
|
|
|
|
super.onCreate();
|
|
|
|
m_singleton = this;
|
2012-09-19 09:02:13 +00:00
|
|
|
}
|
2012-11-30 06:08:00 +00:00
|
|
|
|
|
|
|
public void save(Bundle out) {
|
|
|
|
out.putParcelableArrayList("gs:loadedArticles", m_loadedArticles);
|
|
|
|
out.putParcelable("gs:activeFeed", m_activeFeed);
|
|
|
|
out.putParcelable("gs:activeArticle", m_activeArticle);
|
|
|
|
out.putString("gs:sessionId", m_sessionId);
|
2012-11-30 16:21:31 +00:00
|
|
|
out.putInt("gs:apiLevel", m_apiLevel);
|
|
|
|
out.putBoolean("gs:canUseProgress", m_canUseProgress);
|
|
|
|
out.putInt("gs:selectedArticleId", m_selectedArticleId);
|
2012-11-30 06:08:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void load(Bundle in) {
|
|
|
|
if (m_loadedArticles.size() == 0 && in != null) {
|
|
|
|
ArrayList<Parcelable> list = in.getParcelableArrayList("gs:loadedArticles");
|
|
|
|
|
|
|
|
for (Parcelable p : list) {
|
|
|
|
m_loadedArticles.add((Article)p);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_activeFeed = (Feed) in.getParcelable("gs:activeFeed");
|
|
|
|
m_activeArticle = (Article) in.getParcelable("gs:activeArticle");
|
|
|
|
m_sessionId = in.getString("gs:sessionId");
|
2012-11-30 16:21:31 +00:00
|
|
|
m_apiLevel = in.getInt("gs:apiLevel");
|
|
|
|
m_canUseProgress = in.getBoolean("gs:canUseProgress");
|
|
|
|
m_selectedArticleId = in.getInt("gs:selectedArticleId");
|
2012-11-30 06:08:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2012-09-16 17:59:03 +00:00
|
|
|
}
|