[optimize] Architecture is shifting towards Hilt comprehensively
This commit is contained in:
@@ -47,7 +47,7 @@ object ApiClient {
|
||||
private val dnsEventListener = object : EventListener() {
|
||||
override fun dnsEnd(call: okhttp3.Call, domainName: String, inetAddressList: List<InetAddress>) {
|
||||
super.dnsEnd(call, domainName, inetAddressList)
|
||||
val ipAddresses = inetAddressList.joinToString(", ") { it.hostAddress }
|
||||
val ipAddresses = inetAddressList.joinToString(", ") { it.hostAddress ?: "" }
|
||||
Log.d("OkHttp_DNS", "Domain '$domainName' resolved to IPs: [$ipAddresses]")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ class FetchManager @Inject constructor(
|
||||
|
||||
fun startVideoDownload(video: Video)
|
||||
{
|
||||
val path = File(context.filesDir, "videos/${video.klass}/${video.id}")
|
||||
val path = File(context.filesDir, "videos/${video.klass}/${video.id}/video.mp4")
|
||||
val request = Request(video.getVideo(), path.path).apply {
|
||||
extras = Extras(mapOf("name" to video.video.name, "id" to video.id, "class" to video.klass))
|
||||
}
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
package com.acitelight.aether.service
|
||||
|
||||
import android.content.Context
|
||||
import com.acitelight.aether.model.BookMark
|
||||
import com.acitelight.aether.model.Comic
|
||||
import com.acitelight.aether.model.ComicResponse
|
||||
import com.acitelight.aether.model.Video
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
|
||||
object MediaManager
|
||||
@Singleton
|
||||
class MediaManager @Inject constructor(
|
||||
|
||||
)
|
||||
{
|
||||
var token: String = "null"
|
||||
|
||||
@@ -34,27 +41,11 @@ object MediaManager
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun listVideos(klass: String, filter: List<String>, callback: (Video) -> Unit)
|
||||
{
|
||||
val j = ApiClient.api!!.queryVideoClasses(klass, token)
|
||||
for(it in j)
|
||||
{
|
||||
if(filter.contains(it))
|
||||
continue
|
||||
try {
|
||||
callback(queryVideo(klass, it)!!)
|
||||
}catch (e: Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun queryVideo(klass: String, id: String): Video?
|
||||
{
|
||||
try {
|
||||
val j = ApiClient.api!!.queryVideo(klass, id, token)
|
||||
return Video(klass = klass, id = id, token=token, j)
|
||||
return Video(klass = klass, id = id, token=token, isLocal = false, video = j)
|
||||
}catch (e: Exception)
|
||||
{
|
||||
return null
|
||||
@@ -65,7 +56,7 @@ object MediaManager
|
||||
{
|
||||
try {
|
||||
val j = ApiClient.api!!.queryVideoBulk(klass, id, token)
|
||||
return j.zip(id).map {Video(klass = klass, id = it.second, token=token, it.first)}
|
||||
return j.zip(id).map {Video(klass = klass, id = it.second, token=token, isLocal = false, video = it.first)}
|
||||
}catch (e: Exception)
|
||||
{
|
||||
return null
|
||||
|
||||
@@ -14,8 +14,13 @@ import kotlinx.serialization.json.*
|
||||
import java.io.File
|
||||
import java.io.FileNotFoundException
|
||||
import java.io.IOException
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
object RecentManager
|
||||
@Singleton
|
||||
class RecentManager @Inject constructor(
|
||||
private val mediaManager: MediaManager
|
||||
)
|
||||
{
|
||||
private val mutex = Mutex()
|
||||
|
||||
@@ -56,7 +61,7 @@ object RecentManager
|
||||
|
||||
for(it in gr)
|
||||
{
|
||||
val v = MediaManager.queryVideoBulk(it.key, it.value.map { it.id })
|
||||
val v = mediaManager.queryVideoBulk(it.key, it.value.map { it.id })
|
||||
if(v != null)
|
||||
for(j in v)
|
||||
{
|
||||
@@ -86,7 +91,7 @@ object RecentManager
|
||||
|
||||
recent.removeAt(index)
|
||||
}
|
||||
recent.add(0, MediaManager.queryVideoBulk(video.klass, listOf(video.id))!![0])
|
||||
recent.add(0, mediaManager.queryVideoBulk(video.klass, listOf(video.id))!![0])
|
||||
|
||||
|
||||
if(recent.size >= 21)
|
||||
|
||||
Reference in New Issue
Block a user