Android Open Source - timesync Time Sync Preferences






From Project

Back to project page timesync.

License

The source code is released under:

Apache License

If you think the Android project timesync 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 me.tatarka.timesync.lib;
/* w  w  w .  j a  va 2s.  c  om*/
import android.content.Context;
import android.content.SharedPreferences;

class TimeSyncPreferences {
    static final String NAME = "me.tatarka.timesync.SHARED_PREFS";
    private static final String SEED = "seed";
    private static final String POWER_CONNECTED = "power_connected";
    private static final String LAST_FAILED_TIME_SPAN = "last_failed_time_span";

    private SharedPreferences prefs;

    TimeSyncPreferences(Context context) {
        prefs = context.getSharedPreferences(NAME, Context.MODE_PRIVATE);
    }

    long getSeed() {
        return prefs.getLong(SEED, 0);
    }

    void setSeed(long seed) {
        prefs.edit().putLong(SEED, seed).commit();
    }

    boolean isPowerConnected() {
        return prefs.getBoolean(POWER_CONNECTED, false);
    }

    void setPowerConnected(boolean value) {
        prefs.edit().putBoolean(POWER_CONNECTED, value).commit();
    }

    long getLastFailedTimeSpan(String name) {
        return prefs.getLong(name + LAST_FAILED_TIME_SPAN, 0);
    }

    void setLastFailedTimeSpan(String name, long timeSpan) {
        prefs.edit().putLong(name + LAST_FAILED_TIME_SPAN, timeSpan).commit();
    }
}




Java Source Code List

me.tatarka.timesync.app.MainActivity.java
me.tatarka.timesync.app.MyApplication.java
me.tatarka.timesync.app.RandomSync.java
me.tatarka.timesync.lib.BooleanFormatException.java
me.tatarka.timesync.lib.EventCalculator.java
me.tatarka.timesync.lib.MathUtil.java
me.tatarka.timesync.lib.ReceiverUtils.java
me.tatarka.timesync.lib.SuperNotCalledException.java
me.tatarka.timesync.lib.TimeSyncBootReceiver.java
me.tatarka.timesync.lib.TimeSyncNetworkReceiver.java
me.tatarka.timesync.lib.TimeSyncParser.java
me.tatarka.timesync.lib.TimeSyncPowerReceiver.java
me.tatarka.timesync.lib.TimeSyncPreferences.java
me.tatarka.timesync.lib.TimeSyncProxy.java
me.tatarka.timesync.lib.TimeSyncService.java
me.tatarka.timesync.lib.TimeSync.java