package com.app.sounds.prank.party.upload

import android.content.Context
import android.content.SharedPreferences
import com.app.sounds.prank.party.PartyApp


object SaveUtils {


    val IS_POST = "is_post"
    private var shared: SharedPreferences? = null

    var isPost: Boolean
        get() = queryBoolean(
            IS_POST,
            false
        )
        set(value) {
            saveBoolean(IS_POST, value)
        }



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

    }


    fun saveBoolean(key: String, value: Boolean) {
        getShared().edit()
            .putBoolean(key, value).apply()
    }

    fun queryBoolean(key: String, defaultValue: Boolean): Boolean {
        return getShared()
            .getBoolean(key, defaultValue)
    }




}