package com.base.locationsharewhite.utils

object SpStringUtils {

    private val TAG = "SpStringUtils"

    const val VIEWER_NICKNAME_KEY = "viewer_nickname_key"//可以看我的人
    const val VIEWING_NICKNAME_KEY = "viewing_nickname_key"//我可以看的人
    const val _DEVICE_NICKNAME_ = "_device_nickname_"

    fun getSpStringList(key: String): List<String> {
        val sp = AppPreferences.getInstance().getString(key, "")
        return if (sp.equals("")) {
            listOf()
        } else {
            sp.split("|||")
        }
    }

    fun addSpString(key: String, value: String) {
        LogEx.logDebug(TAG, "key=$key value=$value")
        val list = getSpStringList(key).toMutableList()
        list.add(value)
        val string = list.joinToString(separator = "|||")
        AppPreferences.getInstance().put(key, string)
    }

    fun deleteSpString(key: String, value: String) {
        val list = getSpStringList(key).toMutableList()
        list.remove(value)
        val string = list.joinToString(separator = "|||")
        AppPreferences.getInstance().put(key, string)
    }

}