Use mca 1.8.0beta01

This commit is contained in:
tarsin committed 2022-12-11 08:11:16 +08:00
1 parent 452c0f2846
commit a677d95d34
2 files changed
+31 -22

No files matched your search

+1 -1
View File
@@ -181,7 +181,7 @@ dependencies {
implementation 'androidx.viewpager2:viewpager2:1.1.0-beta01' implementation 'androidx.viewpager2:viewpager2:1.1.0-beta01'
implementation 'com.drakeet.drawer:drawer:1.0.3' implementation 'com.drakeet.drawer:drawer:1.0.3'
implementation 'com.google.android.material:material:1.8.0-SNAPSHOT' implementation 'com.google.android.material:material:1.8.0-beta01'
implementation 'com.squareup.okhttp3:okhttp-bom:5.0.0-alpha.10' implementation 'com.squareup.okhttp3:okhttp-bom:5.0.0-alpha.10'
implementation 'com.squareup.okhttp3:okhttp' implementation 'com.squareup.okhttp3:okhttp'
@@ -52,10 +52,14 @@ import com.hippo.ehviewer.ui.EhActivity
import com.hippo.scene.SceneApplication import com.hippo.scene.SceneApplication
import com.hippo.util.BitmapUtils import com.hippo.util.BitmapUtils
import com.hippo.util.ExceptionUtils import com.hippo.util.ExceptionUtils
import com.hippo.util.IoThreadPoolExecutor
import com.hippo.util.ReadableTime import com.hippo.util.ReadableTime
import com.hippo.yorozuya.FileUtils import com.hippo.yorozuya.FileUtils
import com.hippo.yorozuya.IntIdGenerator import com.hippo.yorozuya.IntIdGenerator
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import okhttp3.Cache import okhttp3.Cache
import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
@@ -81,6 +85,7 @@ class EhApplication : SceneApplication() {
mActivityList.forEach { it.recreate() } mActivityList.forEach { it.recreate() }
} }
@OptIn(DelicateCoroutinesApi::class)
@SuppressLint("StaticFieldLeak") @SuppressLint("StaticFieldLeak")
override fun onCreate() { override fun onCreate() {
ProcessLifecycleOwner.get().lifecycle.addObserver(EhlifecycleObserver()) ProcessLifecycleOwner.get().lifecycle.addObserver(EhlifecycleObserver())
@@ -112,33 +117,37 @@ class EhApplication : SceneApplication() {
AppCompatDelegate.setApplicationLocales(LocaleListCompat.create(Settings.getLocale())) AppCompatDelegate.setApplicationLocales(LocaleListCompat.create(Settings.getLocale()))
AppCompatDelegate.setDefaultNightMode(Settings.getTheme()) AppCompatDelegate.setDefaultNightMode(Settings.getTheme())
IoThreadPoolExecutor.getInstance().execute { GlobalScope.launch {
try { withContext(Dispatchers.IO) {
val downloadLocation = Settings.getDownloadLocation() try {
if (Settings.getMediaScan()) { val downloadLocation = Settings.getDownloadLocation()
CommonOperations.removeNoMediaFile(downloadLocation) if (Settings.getMediaScan()) {
} else { CommonOperations.removeNoMediaFile(downloadLocation)
CommonOperations.ensureNoMediaFile(downloadLocation) } else {
CommonOperations.ensureNoMediaFile(downloadLocation)
}
} catch (t: Throwable) {
t.printStackTrace()
ExceptionUtils.throwIfFatal(t)
} }
} catch (t: Throwable) {
t.printStackTrace()
ExceptionUtils.throwIfFatal(t)
}
// Clear temp files // Clear temp files
try { try {
clearTempDir() clearTempDir()
} catch (t: Throwable) { } catch (t: Throwable) {
t.printStackTrace() t.printStackTrace()
ExceptionUtils.throwIfFatal(t) ExceptionUtils.throwIfFatal(t)
}
} }
} }
GlobalScope.launch {
theDawnOfNewDay()
}
mIdGenerator.setNextId(Settings.getInt(KEY_GLOBAL_STUFF_NEXT_ID, 0)) mIdGenerator.setNextId(Settings.getInt(KEY_GLOBAL_STUFF_NEXT_ID, 0))
initialized = true initialized = true
theDawnOfNewDay()
} }
private fun theDawnOfNewDay() { private suspend fun theDawnOfNewDay() {
if (!Settings.getRequestNews()) { if (!Settings.getRequestNews()) {
return return
} }
@@ -150,7 +159,7 @@ class EhApplication : SceneApplication() {
EhCookieStore.KEY_IPD_PASS_HASH EhCookieStore.KEY_IPD_PASS_HASH
) )
) { ) {
IoThreadPoolExecutor.getInstance().execute { withContext(Dispatchers.IO) {
val referer = EhUrl.REFERER_E val referer = EhUrl.REFERER_E
val request = EhRequestBuilder(EhUrl.HOST_E + "news.php", referer).build() val request = EhRequestBuilder(EhUrl.HOST_E + "news.php", referer).build()
val call = okHttpClient.newCall(request) val call = okHttpClient.newCall(request)