AppLocalImpl.kt 1.18 KB
Newer Older
ydl committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
package com.yidianling.user.mine.data

import android.content.Context
import android.content.SharedPreferences
import com.ydl.ydlcommon.base.BaseApp

/**
 * author : Zhangwenchao
 * e-mail : zhangwch@yidianling.com
 * time   : 2018/04/27
 */
internal class AppLocalImpl private constructor(): AppLocal {

    companion object {
        fun getInstance(): AppLocalImpl {
            return Holder.INSTANCE
        }

        private val APP = "app"
        private val RED_POCKET_TIME = "red_pocket_time"
        private val UPDATE = "update"
    }


    override fun getRedPocketTime(): Long {
        return getAppSP().getLong(RED_POCKET_TIME, 0)
    }

    override fun putRedPocketTime(time: Long) {
        getAppSP().edit().putLong(RED_POCKET_TIME, time).apply()
    }

    override fun hasUpdate(): Boolean {
        return getAppSP().getBoolean(UPDATE, false)
    }

    override fun putUpdate(update: Boolean) {
        getAppSP().edit().putBoolean(UPDATE, update).apply()
    }

    private fun getAppSP(): SharedPreferences {
        return BaseApp.getApp().getSharedPreferences(APP, Context.MODE_PRIVATE)
    }



    private object Holder {
        internal val INSTANCE = AppLocalImpl()
    }

}