package com.phlx.anchorcollect_p.data.local;



import com.phlx.anchorcollect_p.Configs;

import me.goldze.mvvmhabit.utils.SPUtils;


public class LocalDataSourceImpl implements LocalDataSource {
    private volatile static LocalDataSourceImpl INSTANCE = null;

    public static LocalDataSourceImpl getInstance() {
        if (INSTANCE == null) {
            synchronized (LocalDataSourceImpl.class) {
                if (INSTANCE == null) {
                    INSTANCE = new LocalDataSourceImpl();
                }
            }
        }
        return INSTANCE;
    }

    public static void destroyInstance() {
        INSTANCE = null;
    }

    @Override
    public void saveUserName(String userName) {
        SPUtils.getInstance().put(Configs.SP_USER_NAME, userName);
    }

    @Override
    public void savePassword(String password) {
        SPUtils.getInstance().put(Configs.SP_USER_PASSWORD, password);
    }

    @Override
    public void savePhone(String phone) {
        SPUtils.getInstance().put(Configs.SP_USER_PHONE, phone);
    }

    @Override
    public void saveEmail(String email) {
        SPUtils.getInstance().put(Configs.SP_USER_EMAIL, email);
    }

    @Override
    public void saveFrequencyConfig(String frequencyConfig) {
        SPUtils.getInstance().put(Configs.SP_FREQUENCY_CONFIG, frequencyConfig);
    }


    @Override
    public void saveToken(String token) {
        SPUtils.getInstance().put("token", token);
    }

    @Override
    public String getUserName() {
        return SPUtils.getInstance().getString(Configs.SP_USER_NAME, "");
    }

    @Override
    public String getPassword() {
        return SPUtils.getInstance().getString(Configs.SP_USER_PASSWORD, "");
    }

    @Override
    public String getPhone() {
        return null;
    }

    @Override
    public String getEmail() {
        return null;
    }

    @Override
    public String getFrequencyConfig() {
        return null;
    }

    @Override
    public String getToken() {
        return SPUtils.getInstance().getString("token", "");
    }

}
