package com.yidianling.ydlcommon.custom.player.util

import android.content.Context
import android.text.TextUtils
import com.yidianling.ydlcommon.custom.player.Config

/**
 * 工具类
 * Created by hgw on 2018/3/31.
 */
object UtilH {

    /**
     * 保存播放进度
     */
    fun saveProgress(context: Context?,url : String?,progress : Int){
        if (TextUtils.isEmpty(url))return
        var shared = context?.getSharedPreferences(Config.HMusicProgress,Context.MODE_PRIVATE)
        var edit = shared?.edit()
        edit?.putInt(url,progress)
        edit?.commit()
    }

    /**
     * 获取进度
     */
    fun getProgress(context: Context?,url : String?):Int{
        if (TextUtils.isEmpty(url))return 0
        var shared = context?.getSharedPreferences(Config.HMusicProgress,Context.MODE_PRIVATE)
        return shared?.getInt(url,0)?:0
    }
}