package com.hd.live.wall.wallpapers.utils

import android.content.Context
import android.content.SharedPreferences
import com.hd.live.wall.wallpapers.LiveApp

object Store {

    val KEY_CURRENT_WAPPPAPER_PATH = "wallpaper_path"
    val DB_INIT_DATAT = "init_db_data"

    private var shared: SharedPreferences? = null

    var video_path: String
        get() = queryString(
            KEY_CURRENT_WAPPPAPER_PATH,
            ""
        )
        set(value) {
            saveString(KEY_CURRENT_WAPPPAPER_PATH, value)
        }
    var dbinit: String
        get() = queryString(
            DB_INIT_DATAT,
            "0"
        )
        set(value) {
            saveString(DB_INIT_DATAT, value)
        }

    private fun getShared(): SharedPreferences {
        if (shared == null) {
            shared = LiveApp.getApplication().getSharedPreferences("", Context.MODE_PRIVATE)
        }
        return shared!!

    }





    fun saveString(key: String, value: String) {
        getShared().edit()
            .putString(key, value).apply()
    }

    fun queryString(key: String, defaultValue: String): String {
        return getShared()
            .getString(key, defaultValue).orEmpty()
    }

}