Android Open Source - SandB-Android Main Prefs






From Project

Back to project page SandB-Android.

License

The source code is released under:

GNU General Public License

If you think the Android project SandB-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package edu.grinnell.sandb;
/* w  w w .  ja v a 2 s. c o  m*/
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.PreferenceManager;

//store persistent info on when the list was last updated
public class MainPrefs {

  /* SharedPreferences */
  private static SharedPreferences mPrefs = null;
  
  private static final String AUTO_REFRESH = "auto_refresh";
  private static final String LAST_UPDATED = "last_updated";
  private static final String FIRST_RUN = "first_run";
  public boolean autoRefresh;
  public long lastUpdated;
  public boolean firstRun;
  
  public MainPrefs (Context context) {
    if (mPrefs == null)
      mPrefs = PreferenceManager.getDefaultSharedPreferences(context);    
    refresh();
  }
  
  public void refresh() {
    autoRefresh = mPrefs.getBoolean(AUTO_REFRESH, true);
    lastUpdated = mPrefs.getLong(LAST_UPDATED, 0);
    firstRun = mPrefs.getBoolean(FIRST_RUN, true);
  }
  
  public void setLastUpdated(long v) {
    Editor e = mPrefs.edit();
    e.putLong(LAST_UPDATED, v);
    e.commit();
  }
  public void setFirstRun(boolean v) {
    Editor e = mPrefs.edit();
    e.putBoolean(FIRST_RUN, v);
    e.commit();
  }
}




Java Source Code List

edu.grinnell.sandb.ArticleDetailActivity.java
edu.grinnell.sandb.ArticleDetailFragment.java
edu.grinnell.sandb.ArticleListAdapter.java
edu.grinnell.sandb.ArticleListFragment.java
edu.grinnell.sandb.CommentListAdapter.java
edu.grinnell.sandb.CommentListFragment.java
edu.grinnell.sandb.ImagePagerActivity.java
edu.grinnell.sandb.MainActivity.java
edu.grinnell.sandb.MainPrefs.java
edu.grinnell.sandb.ScarletAndBlackApplication.java
edu.grinnell.sandb.Utility.java
edu.grinnell.sandb.comments.CommentStorageHelper.java
edu.grinnell.sandb.comments.CommentTable.java
edu.grinnell.sandb.comments.Comment.java
edu.grinnell.sandb.data.ArticleStorageHelper.java
edu.grinnell.sandb.data.ArticleTable.java
edu.grinnell.sandb.data.Article.java
edu.grinnell.sandb.img.BodyImageGetter.java
edu.grinnell.sandb.img.ImageStorageHelper.java
edu.grinnell.sandb.img.ImageTable.java
edu.grinnell.sandb.img.Image.java
edu.grinnell.sandb.img.UniversalLoaderUtility.java
edu.grinnell.sandb.xmlpull.CommentParseTask.java
edu.grinnell.sandb.xmlpull.XmlCheckAgeTask.java
edu.grinnell.sandb.xmlpull.XmlFetchTask.java
edu.grinnell.sandb.xmlpull.XmlParseTask.java
edu.grinnell.sandb.xmlpull.XmlPullReceiver.java
edu.grinnell.sandb.xmlpull.XmlPullService.java