package com.wall.photography.wallpaper.util;

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

import com.wall.photography.wallpaper.MyApp;
import com.wall.photography.wallpaper.topon.AdManager;

public class Sp {
    private static String spName = "AD_SHOW";
    private static Sp instance;
    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, AdManager.VALUE_SHOW_INTERVAL);
    }
}
