From 07e7f0c13952f01e3b323a330eb345f0fc1ef5fe Mon Sep 17 00:00:00 2001 From: cubemaze Date: Thu, 11 May 2023 15:00:59 +0800 Subject: [PATCH] fix: subscription --- .../github/kr328/clash/service/ProfileManager.kt | 8 ++++---- .../github/kr328/clash/service/ProfileProcessor.kt | 14 +++++--------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/service/src/main/java/com/github/kr328/clash/service/ProfileManager.kt b/service/src/main/java/com/github/kr328/clash/service/ProfileManager.kt index d79ea6cd..fa10fd9a 100644 --- a/service/src/main/java/com/github/kr328/clash/service/ProfileManager.kt +++ b/service/src/main/java/com/github/kr328/clash/service/ProfileManager.kt @@ -159,16 +159,16 @@ class ProfileManager(private val context: Context) : IProfileManager, for (flag in flags) { val info = flag.split("=") when { - info[0].contains("upload") -> upload = + info[0].contains("upload") && info[1].isNotEmpty() -> upload = BigDecimal(info[1]).longValueExact() - info[0].contains("download") -> download = + info[0].contains("download") && info[1].isNotEmpty() -> download = BigDecimal(info[1]).longValueExact() - info[0].contains("total") -> total = + info[0].contains("total") && info[1].isNotEmpty() -> total = BigDecimal(info[1]).longValueExact() - info[0].contains("expire") -> { + info[0].contains("expire") && info[1].isNotEmpty() -> { if (info[1].isNotEmpty()) { expire = (info[1].toDouble()*1000).toLong() } diff --git a/service/src/main/java/com/github/kr328/clash/service/ProfileProcessor.kt b/service/src/main/java/com/github/kr328/clash/service/ProfileProcessor.kt index 9375aca9..360db1f9 100644 --- a/service/src/main/java/com/github/kr328/clash/service/ProfileProcessor.kt +++ b/service/src/main/java/com/github/kr328/clash/service/ProfileProcessor.kt @@ -87,21 +87,17 @@ object ProfileProcessor { for (flag in flags) { val info = flag.split("=") when { - info[0].contains("upload") -> upload = + info[0].contains("upload") && info[1].isNotEmpty() -> upload = info[1].toLong() - info[0].contains("download") -> download = + info[0].contains("download") && info[1].isNotEmpty() -> download = info[1].toLong() - info[0].contains("total") -> total = + info[0].contains("total") && info[1].isNotEmpty() -> total = info[1].toLong() - info[0].contains("expire") -> { - if (info[1].isNotEmpty()) { - expire = - (info[1].toDouble() * 1000).toLong() - } - } + info[0].contains("expire") && info[1].isNotEmpty() -> expire = + (info[1].toDouble() * 1000).toLong() } } }