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