package com.dlc.chemical.sp

import android.content.Context
import com.google.gson.Gson
import com.rc.httpcore.vo.response.ConfLogo
import java.lang.Exception

/**
 * info
 *
 * @author ReiChin_
 */
object ConfLogoSp {

    private const val SP_NAME = "lab_conf_logo"
    private const val KEY = "conf_logo_json_data"

    fun saveConfLogo(context: Context, data: ConfLogo) {
        val sp = context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE)
        sp.edit().putString(KEY, Gson().toJson(data)).apply()
    }

    fun loadConfLogo(context: Context): ConfLogo? {
        return try {
            val sp = context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE)
            val jsonData = sp.getString(KEY, null)

            return Gson().fromJson(jsonData, ConfLogo::class.java)
        } catch (e: Exception) {
            e.printStackTrace()
            null
        }
    }

}