package ai.pai.lensman.db;

import android.content.Context;
import android.content.SharedPreferences;

import ai.pai.lensman.App;

public class Preferences {

    private SharedPreferences mPrefs;
    private static Preferences instance;
    private static final String NullStr = "";

    private Preferences() {
        mPrefs = App.getAppContext().getSharedPreferences("prefs", Context.MODE_PRIVATE);
    }

    public static synchronized Preferences getInstance() {

        if (instance == null) {
            instance = new Preferences();
        }
        return instance;
    }


    public void setLastRunDate(String date) {
        mPrefs.edit().putString("lastRunDate", date).commit();
    }

    public String getLastRunDate() {
        return mPrefs.getString("lastRunDate", "1970-01-01");
    }

    public void setUserName(String userName){
        mPrefs.edit().putString("userName",userName).commit();
    }

    public String getUserName(){
        return mPrefs.getString("userName",NullStr);
    }

    public void setLensManId(String lensManId){
        mPrefs.edit().putString("lensManId",lensManId).commit();
    }

    public String getLensManId(){
        return mPrefs.getString("lensManId",NullStr);
    }

    public String getWXCode(){
        return mPrefs.getString("wxcode", NullStr);
    }

    public void setWXCode(String wxCode){
        mPrefs.edit().putString("wxcode",wxCode).commit();
    }

    public void clearPrefs(){
        mPrefs.edit().clear().commit();
    }
}
