[update] New Icon& UI Theme
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.acitelight.aether.service
|
||||
|
||||
import android.content.Context
|
||||
import com.acitelight.aether.Screen
|
||||
import com.acitelight.aether.model.Video
|
||||
import com.acitelight.aether.service.ApiClient.createOkHttp
|
||||
import com.tonyodev.fetch2.Download
|
||||
import com.tonyodev.fetch2.Fetch
|
||||
@@ -8,8 +10,10 @@ import com.tonyodev.fetch2.FetchConfiguration
|
||||
import com.tonyodev.fetch2.FetchListener
|
||||
import com.tonyodev.fetch2.Request
|
||||
import com.tonyodev.fetch2.Status
|
||||
import com.tonyodev.fetch2core.Extras
|
||||
import com.tonyodev.fetch2okhttp.OkHttpDownloader
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import java.io.File
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@@ -76,10 +80,26 @@ class FetchManager @Inject constructor(
|
||||
} ?: callback?.invoke()
|
||||
}
|
||||
|
||||
|
||||
// enqueue helper if needed
|
||||
fun enqueue(request: Request, onEnqueued: ((Request) -> Unit)? = null, onError: ((com.tonyodev.fetch2.Error) -> Unit)? = null) {
|
||||
private fun enqueue(request: Request, onEnqueued: ((Request) -> Unit)? = null, onError: ((com.tonyodev.fetch2.Error) -> Unit)? = null) {
|
||||
if (fetch == null) init()
|
||||
fetch?.enqueue(request, { r -> onEnqueued?.invoke(r) }, { e -> onError?.invoke(e) })
|
||||
}
|
||||
|
||||
private fun getVideosDirectory() {
|
||||
val appFilesDir = context.filesDir
|
||||
val videosDir = File(appFilesDir, "videos")
|
||||
|
||||
if (!videosDir.exists()) {
|
||||
val created = videosDir.mkdirs()
|
||||
}
|
||||
}
|
||||
|
||||
fun startVideoDownload(video: Video)
|
||||
{
|
||||
val path = File(context.filesDir, "videos/${video.klass}/${video.id}")
|
||||
val request = Request(video.getVideo(), path.path).apply {
|
||||
extras = Extras(mapOf("name" to video.video.name, "id" to video.id, "class" to video.klass))
|
||||
}
|
||||
enqueue(request)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user