package com.input.board.appskey.keyboard.firebase;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;


public class Sp {
    private static String spName = "AD_SHOW";
    private static Sp instance;
    //默认的广告展示间隔时间20s
    private static final long DEFAULT_SHOW_INTERVAL = 1000 * 30L;
    private SharedPreferences.Editor editor;

    private SharedPreferences preferences;

    private Sp(Application context) {
        preferences = context.getSharedPreferences(spName, Context.MODE_PRIVATE);
        editor = preferences.edit();
    }


    public static Sp getInstance(Application context) {
        if (instance == null) {
            instance = new Sp(context);
        }
        return instance;
    }


    public Sp putLong(String key, long value) {
        editor.putLong(key, value);
        return this;
    }

    public boolean commit() {
        return editor.commit();
    }

    public long getLongValue(String key) {
        return preferences.getLong(key, DEFAULT_SHOW_INTERVAL);
    }
}
