Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Sep 17, 2024
1 parent 141b986 commit 17ef476
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion V2rayNG/app/src/main/kotlin/com/v2ray/ang/extension/_Ext.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,6 @@ val URLConnection.responseLength: Long
val URI.idnHost: String
get() = host?.replace("[", "")?.replace("]", "").orEmpty()

fun String.removeWhiteSpace(): String = replace("\\s+".toRegex(), "")
fun String.removeWhiteSpace(): String = replace("\\s+".toRegex(), "")

fun String.toLongEx(): Long = toLongOrNull() ?: 0
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.tencent.mmkv.MMKV
import com.v2ray.ang.AngApplication
import com.v2ray.ang.AppConfig
import com.v2ray.ang.R
import com.v2ray.ang.extension.toLongEx
import com.v2ray.ang.service.SubscriptionUpdater
import com.v2ray.ang.util.MmkvManager
import com.v2ray.ang.util.Utils
Expand Down Expand Up @@ -128,7 +129,7 @@ class SettingsActivity : BaseActivity() {
val value = newValue as Boolean
autoUpdateCheck?.isChecked = value
autoUpdateInterval?.isEnabled = value
autoUpdateInterval?.text?.toLong()?.let {
autoUpdateInterval?.text?.toLongEx()?.let {
if (newValue) configureUpdateTask(it) else cancelUpdateTask()
}
true
Expand All @@ -138,9 +139,9 @@ class SettingsActivity : BaseActivity() {

// It must be greater than 15 minutes because WorkManager couldn't run tasks under 15 minutes intervals
nval =
if (TextUtils.isEmpty(nval) || nval.toLong() < 15) AppConfig.SUBSCRIPTION_DEFAULT_UPDATE_INTERVAL else nval
if (TextUtils.isEmpty(nval) || nval.toLongEx() < 15) AppConfig.SUBSCRIPTION_DEFAULT_UPDATE_INTERVAL else nval
autoUpdateInterval?.summary = nval
configureUpdateTask(nval.toLong())
configureUpdateTask(nval.toLongEx())
true
}

Expand Down

0 comments on commit 17ef476

Please sign in to comment.