pull/1879/head
kunfei 3 years ago
parent d4761bd992
commit 4a17a40378
  1. 5
      app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt
  2. 5
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt
  3. 3
      app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt
  4. 3
      app/src/main/java/io/legado/app/ui/widget/checkbox/SmoothCheckBox.kt
  5. 9
      app/src/main/java/io/legado/app/utils/RegexExtensions.kt

@ -32,6 +32,7 @@ import io.legado.app.utils.*
import kotlinx.coroutines.Dispatchers.Main import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import splitties.init.appCtx import splitties.init.appCtx
import kotlin.collections.set
class BackupConfigFragment : PreferenceFragment(), class BackupConfigFragment : PreferenceFragment(),
SharedPreferences.OnSharedPreferenceChangeListener { SharedPreferences.OnSharedPreferenceChangeListener {
@ -209,7 +210,9 @@ class BackupConfigFragment : PreferenceFragment(),
return super.onPreferenceTreeClick(preference) return super.onPreferenceTreeClick(preference)
} }
/**
* 备份忽略设置
*/
private fun backupIgnore() { private fun backupIgnore() {
val checkedItems = BooleanArray(BackupConfig.ignoreKeys.size) { val checkedItems = BooleanArray(BackupConfig.ignoreKeys.size) {
BackupConfig.ignoreConfig[BackupConfig.ignoreKeys[it]] ?: false BackupConfig.ignoreConfig[BackupConfig.ignoreKeys[it]] ?: false

@ -8,6 +8,7 @@ import android.view.KeyEvent
import android.view.MenuItem import android.view.MenuItem
import android.view.ViewGroup import android.view.ViewGroup
import androidx.activity.viewModels import androidx.activity.viewModels
import androidx.core.view.postDelayed
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter import androidx.fragment.app.FragmentStatePagerAdapter
@ -87,9 +88,9 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
upVersion() upVersion()
//自动更新书籍 //自动更新书籍
if (AppConfig.autoRefreshBook) { if (AppConfig.autoRefreshBook) {
binding.viewPagerMain.postDelayed({ binding.viewPagerMain.postDelayed(1000) {
viewModel.upAllBookToc() viewModel.upAllBookToc()
}, 1000) }
} }
binding.viewPagerMain.postDelayed({ binding.viewPagerMain.postDelayed({
viewModel.postLoad() viewModel.postLoad()

@ -3,6 +3,7 @@ package io.legado.app.ui.welcome
import android.content.Intent import android.content.Intent
import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.BitmapDrawable
import android.os.Bundle import android.os.Bundle
import androidx.core.view.postDelayed
import io.legado.app.base.BaseActivity import io.legado.app.base.BaseActivity
import io.legado.app.constant.PreferKey import io.legado.app.constant.PreferKey
import io.legado.app.constant.Theme import io.legado.app.constant.Theme
@ -26,7 +27,7 @@ open class WelcomeActivity : BaseActivity<ActivityWelcomeBinding>() {
if (intent.flags and Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT != 0) { if (intent.flags and Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT != 0) {
finish() finish()
} else { } else {
binding.root.postDelayed({ startMainActivity() }, 600) binding.root.postDelayed(600) { startMainActivity() }
} }
} }

@ -7,6 +7,7 @@ import android.util.AttributeSet
import android.view.View import android.view.View
import android.view.animation.LinearInterpolator import android.view.animation.LinearInterpolator
import android.widget.Checkable import android.widget.Checkable
import androidx.core.view.postDelayed
import io.legado.app.R import io.legado.app.R
import io.legado.app.lib.theme.ThemeStore import io.legado.app.lib.theme.ThemeStore
import io.legado.app.utils.dpToPx import io.legado.app.utils.dpToPx
@ -244,7 +245,7 @@ class SmoothCheckBox @JvmOverloads constructor(
} }
// invalidate // invalidate
if (mDrewDistance < mLeftLineDistance + mRightLineDistance) { if (mDrewDistance < mLeftLineDistance + mRightLineDistance) {
postDelayed({ this.postInvalidate() }, 10) postDelayed(10) { this.postInvalidate() }
} }
} }

@ -1,5 +1,6 @@
package io.legado.app.utils package io.legado.app.utils
import androidx.core.os.postDelayed
import io.legado.app.exception.RegexTimeoutException import io.legado.app.exception.RegexTimeoutException
import io.legado.app.help.CrashHandler import io.legado.app.help.CrashHandler
import kotlinx.coroutines.suspendCancellableCoroutine import kotlinx.coroutines.suspendCancellableCoroutine
@ -23,20 +24,20 @@ suspend fun CharSequence.replace(regex: Regex, replacement: String, timeout: Lon
block.resumeWithException(e) block.resumeWithException(e)
} }
} }
mainHandler.postDelayed({ mainHandler.postDelayed(timeout) {
if (thread.isAlive) { if (thread.isAlive) {
val timeoutMsg = "替换超时,3秒后还未结束将重启应用\n替换规则$regex\n替换内容:${this}" val timeoutMsg = "替换超时,3秒后还未结束将重启应用\n替换规则$regex\n替换内容:${this}"
val exception = RegexTimeoutException(timeoutMsg) val exception = RegexTimeoutException(timeoutMsg)
block.cancel(exception) block.cancel(exception)
appCtx.longToastOnUi(timeoutMsg) appCtx.longToastOnUi(timeoutMsg)
CrashHandler.saveCrashInfo2File(exception) CrashHandler.saveCrashInfo2File(exception)
mainHandler.postDelayed({ mainHandler.postDelayed(3000) {
if (thread.isAlive) { if (thread.isAlive) {
appCtx.restart() appCtx.restart()
} }
}, 3000) }
} }
}, timeout) }
} }
} }

Loading…
Cancel
Save