package com.develop.common.utils

import android.app.Activity
import com.azhon.appupdate.listener.OnDownloadListener
import com.azhon.appupdate.manager.DownloadManager
import com.develop.base.R

object UpdateUtil {

    fun updateApp(
        activity: Activity,
        apkUrl: String,
        downloadListener: OnDownloadListener
    ) {
        val manager = DownloadManager.Builder(activity).run {
            apkUrl(apkUrl)
            smallIcon(com.develop.common.R.drawable.ic_icon6)
            apkName("foodCooking.apk")
            onDownloadListener(downloadListener)
            build()
        }
        manager.download()
    }

    private fun getApkName(url: String): String {
        return url.subSequence(url.lastIndexOf("/"), url.length).toString()
    }
}