package com.mime.dualscreenview.common

import android.content.Context
import android.content.SharedPreferences
import com.mime.dualscreenview.webcontents.contentsinfo.Booktoki
import com.mime.dualscreenview.webcontents.contentsinfo.NewtokiOne

object PrefManager {
    private val mainName = "Main_Pref_"
    private val domainKey = "Last_Domain_"
    private lateinit var main : SharedPreferences
    fun init(context: Context) {
            main = context.getSharedPreferences(mainName,Context.MODE_PRIVATE)
    }

    fun save(key : String, value : String?) {
        main.edit().putString(key,value).apply()
    }
    fun load(key : String) : String? {
        return main.getString(key, "")
    }

    fun getLastDomain() : String {
        return main.getString(domainKey, NewtokiOne.getLastedDoamin()) ?: NewtokiOne.getLastedDoamin()
    }
    fun putLastDomain(domain : String) {
        Blog.LOGE("domain >>> ${domain}")
        main.edit().putString(domainKey,domain).apply()
    }
}