diff --git a/app/src/main/java/com/hippo/ehviewer/EhApplication.kt b/app/src/main/java/com/hippo/ehviewer/EhApplication.kt index c0473d61d..30667da28 100644 --- a/app/src/main/java/com/hippo/ehviewer/EhApplication.kt +++ b/app/src/main/java/com/hippo/ehviewer/EhApplication.kt @@ -110,36 +110,43 @@ class EhApplication : SceneApplication(), DefaultLifecycleObserver, ImageLoaderF EhDB.initialize(this) BitmapUtils.initialize(this) EhTagDatabase.update() - AppCompatDelegate.setDefaultNightMode(Settings.getTheme()) - launchIO { - try { - val downloadLocation = Settings.getDownloadLocation() - if (Settings.getMediaScan()) { - CommonOperations.removeNoMediaFile(downloadLocation) - } else { - CommonOperations.ensureNoMediaFile(downloadLocation) - } - } catch (t: Throwable) { - t.printStackTrace() - ExceptionUtils.throwIfFatal(t) + launchIO { + downloadManager } - - // Clear temp files - try { - clearTempDir() - } catch (t: Throwable) { - t.printStackTrace() - ExceptionUtils.throwIfFatal(t) + launchIO { + cleanupDownload() + } + launchIO { + theDawnOfNewDay() } - } - launchIO { - theDawnOfNewDay() } mIdGenerator.setNextId(Settings.getInt(KEY_GLOBAL_STUFF_NEXT_ID, 0)) } + private fun cleanupDownload() { + try { + val downloadLocation = Settings.getDownloadLocation() + if (Settings.getMediaScan()) { + CommonOperations.removeNoMediaFile(downloadLocation) + } else { + CommonOperations.ensureNoMediaFile(downloadLocation) + } + } catch (t: Throwable) { + t.printStackTrace() + ExceptionUtils.throwIfFatal(t) + } + + // Clear temp files + try { + clearTempDir() + } catch (t: Throwable) { + t.printStackTrace() + ExceptionUtils.throwIfFatal(t) + } + } + private fun theDawnOfNewDay() { if (!Settings.getRequestNews()) { return