Android Open Source - mac-hopper Store






From Project

Back to project page mac-hopper.

License

The source code is released under:

MIT License

If you think the Android project mac-hopper 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 uk.co.danhawkes.machopper;
//from  w w w. ja  v a  2s .com
import uk.co.danhawkes.machopper.mac.Mac;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class Store {

  private static final String SP_SCHEDULED_TIME = "scheduledAlarmTime";
  private static final String SP_SCHEDULED_INTERVAL = "scheduledAlarmInterval";
  private static final String KEY_REAL_MAC = "realMac";
  private static final String KEY_CURRENT_MAC = "currentMac";
  private final SharedPreferences preferences;

  public Store(Context context) {
    this.preferences = context.getSharedPreferences(Store.class.getSimpleName(),
        Context.MODE_PRIVATE);
  }

  public Mac loadRealMac() {
    return loadMac(KEY_REAL_MAC);
  }

  public void saveRealMac(Mac mac) {
    saveMac(KEY_REAL_MAC, mac);
  }

  public Mac loadCurrentMac() {
    return loadMac(KEY_CURRENT_MAC);
  }

  public void saveCurrentMac(Mac mac) {
    saveMac(KEY_CURRENT_MAC, mac);
  }

  private Mac loadMac(String keyName) {
    String s = preferences.getString(keyName, null);
    if (s != null) {
      return Mac.fromString(s);
    }
    return null;
  }

  private void saveMac(String keyName, Mac mac) {
    preferences.edit().putString(keyName, mac.toString()).commit();
  }

  public void saveScheduledAlarmTime(long time) {
    preferences.edit().putLong(SP_SCHEDULED_TIME, time).commit();
  }

  public long loadScheduledAlarmTime() {
    return preferences.getLong(SP_SCHEDULED_TIME, 0);
  }

  public void saveScheduledAlarmTimeAndInterval(long time, long interval) {
    Editor edit = preferences.edit();
    edit.putLong(SP_SCHEDULED_TIME, time);
    edit.putLong(SP_SCHEDULED_INTERVAL, interval);
    edit.commit();
  }

  public long loadScheduledAlarmInterval() {
    return preferences.getLong(SP_SCHEDULED_INTERVAL, 0);
  }
}




Java Source Code List

uk.co.danhawkes.machopper.AlarmUtils.java
uk.co.danhawkes.machopper.AppSingleton.java
uk.co.danhawkes.machopper.Application.java
uk.co.danhawkes.machopper.Logger.java
uk.co.danhawkes.machopper.Store.java
uk.co.danhawkes.machopper.mac.MacChangeBroadcastReceiver.java
uk.co.danhawkes.machopper.mac.MacUtils.java
uk.co.danhawkes.machopper.mac.Mac.java
uk.co.danhawkes.machopper.ui.CountdownFragment.java
uk.co.danhawkes.machopper.ui.HelpDialogFragment.java
uk.co.danhawkes.machopper.ui.LogFragment.java
uk.co.danhawkes.machopper.ui.MainActivity.java
uk.co.danhawkes.machopper.ui.preferences.ContactPreference.java
uk.co.danhawkes.machopper.ui.preferences.DonatePreference.java
uk.co.danhawkes.machopper.ui.preferences.PreferenceActivity.java
uk.co.danhawkes.machopper.ui.preferences.PreferenceFragment.java
uk.co.danhawkes.machopper.ui.preferences.TimePreference.java
uk.co.danhawkes.machopper.ui.preferences.UiUtils.java