Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Setting.java « hexeditorwatchface « clusterrr « com « java « main « src « app - github.com/ClusterM/wear-os-hex-editor-watchface.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cc386bbbbc0ec4871ddf30a35690183ee58b96e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.clusterrr.hexeditorwatchface;

import android.content.SharedPreferences;

public class Setting {
    private SharedPreferences mPrefs;
    private String mName;
    private String[] mValueNames;
    private String mKey;
    private int mDefaultValue;

    public Setting(SharedPreferences prefs, String name, String[] valueNames, String key, int defaultValue) {
        mPrefs = prefs;
        mName = name;
        mValueNames = valueNames.clone();
        mKey = key;
        mDefaultValue = defaultValue;
    }

    public String getName() { return mName; }
    public String[] getValueNames() { return mValueNames.clone(); }
    public String getValueName(int i) { return mValueNames[i]; }
    public int getValueCount() { return mValueNames.length; }
    public String getValueName() { return mValueNames[mPrefs.getInt(mKey, mDefaultValue)]; }
    public int getValue(int i) { return mPrefs.getInt(mKey, mDefaultValue); }
    public void setValue(int i, int value) { mPrefs.edit().putInt(mKey, value).apply(); }
}