Files
assistant-android/app/src/main/java/com/gh/download/DownloadWorkManager.kt
2022-10-09 16:43:26 +08:00

32 lines
1.1 KiB
Kotlin
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.gh.download
object DownloadWorkManager {
private const val TAG_DOWNLOAD = "tag_download"
@JvmStatic
fun addWorker() {
// cancelWorker()
//
// // 可用存储空间少于 5G ,不使用 WorkManager避免各种因为存储空间造成的问题
// if (FileUtils.isMounted() && FileUtils.getFreeSpaceByPath(Environment.getExternalStorageDirectory().absolutePath) < 1024F * 5) return
//
// // 每 15 分钟检查一下是否需要重试下载
// val builder = PeriodicWorkRequest.Builder(
// DownloadWorker::class.java,
// PeriodicWorkRequest.MIN_PERIODIC_INTERVAL_MILLIS,
// TimeUnit.MILLISECONDS)
//
// val workerRequest = builder
// .addTag(TAG_DOWNLOAD)
// .build()
//
// tryWithDefaultCatch { WorkManager.getInstance(HaloApp.getInstance().applicationContext).enqueue(workerRequest) }
}
@JvmStatic
fun cancelWorker() {
// tryWithDefaultCatch { WorkManager.getInstance(HaloApp.getInstance().applicationContext).cancelAllWorkByTag(TAG_DOWNLOAD) }
}
}