Skip to content

Commit

Permalink
fix: more combining shit
Browse files Browse the repository at this point in the history
  • Loading branch information
rebelonion committed Apr 29, 2024
1 parent a7589a0 commit ed0e06d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 26 deletions.
37 changes: 13 additions & 24 deletions app/src/main/java/ani/dantotsu/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ import eu.kanade.tachiyomi.data.notification.Notifications
import eu.kanade.tachiyomi.extension.anime.AnimeExtensionManager
import eu.kanade.tachiyomi.extension.manga.MangaExtensionManager
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import logcat.AndroidLogcatLogger
Expand Down Expand Up @@ -57,6 +59,7 @@ class App : MultiDexApplication() {

val mFTActivityLifecycleCallbacks = FTActivityLifecycleCallbacks()

@OptIn(DelicateCoroutinesApi::class)
override fun onCreate() {
super.onCreate()

Expand Down Expand Up @@ -98,43 +101,29 @@ class App : MultiDexApplication() {
LogcatLogger.install(AndroidLogcatLogger(LogPriority.VERBOSE))
}

animeExtensionManager = Injekt.get()
mangaExtensionManager = Injekt.get()
novelExtensionManager = Injekt.get()
torrentAddonManager = Injekt.get()
downloadAddonManager = Injekt.get()

val animeScope = CoroutineScope(Dispatchers.Default)
animeScope.launch {
GlobalScope.launch {
animeExtensionManager = Injekt.get()
mangaExtensionManager = Injekt.get()
novelExtensionManager = Injekt.get()
torrentAddonManager = Injekt.get()
downloadAddonManager = Injekt.get()
animeExtensionManager.findAvailableExtensions()
Logger.log("Anime Extensions: ${animeExtensionManager.installedExtensionsFlow.first()}")
AnimeSources.init(animeExtensionManager.installedExtensionsFlow)
}
val mangaScope = CoroutineScope(Dispatchers.Default)
mangaScope.launch {
mangaExtensionManager.findAvailableExtensions()
Logger.log("Manga Extensions: ${mangaExtensionManager.installedExtensionsFlow.first()}")
MangaSources.init(mangaExtensionManager.installedExtensionsFlow)
}
val novelScope = CoroutineScope(Dispatchers.Default)
novelScope.launch {
novelExtensionManager.findAvailableExtensions()
Logger.log("Novel Extensions: ${novelExtensionManager.installedExtensionsFlow.first()}")
NovelSources.init(novelExtensionManager.installedExtensionsFlow)
}
val addonScope = CoroutineScope(Dispatchers.Default)
addonScope.launch {
torrentAddonManager.init()
downloadAddonManager.init()
}
val commentsScope = CoroutineScope(Dispatchers.Default)
commentsScope.launch {
CommentsAPI.fetchAuthToken()
}

val useAlarmManager = PrefManager.getVal<Boolean>(PrefName.UseAlarmManager)
val scheduler = TaskScheduler.create(this, useAlarmManager)
scheduler.scheduleAllTasks(this)
val useAlarmManager = PrefManager.getVal<Boolean>(PrefName.UseAlarmManager)
val scheduler = TaskScheduler.create(this@App, useAlarmManager)
scheduler.scheduleAllTasks(this@App)
}
}

private fun setupNotificationChannels() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class DownloadAddonManager(
override var name: String = "Download Addon"
override var type = AddonType.DOWNLOAD

private val _isInitialized = MutableLiveData<Boolean>().apply { value = false }
private val _isInitialized = MutableLiveData<Boolean>().apply { postValue(false) }
val isInitialized: LiveData<Boolean> = _isInitialized

private var error: String? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TorrentAddonManager(
override var type: AddonType = AddonType.TORRENT
var torrentHash: String? = null

private val _isInitialized = MutableLiveData<Boolean>().apply { value = false }
private val _isInitialized = MutableLiveData<Boolean>().apply { postValue(false) }
val isInitialized: LiveData<Boolean> = _isInitialized

private var error: String? = null
Expand Down

0 comments on commit ed0e06d

Please sign in to comment.