From a154230bca5035cbba7b3d470c17ef7edafe0f57 Mon Sep 17 00:00:00 2001 From: Kr328 <39107975+Kr328@users.noreply.github.com> Date: Tue, 10 Dec 2019 22:28:43 +0800 Subject: [PATCH] fix some bugs --- app/build.gradle | 4 ++-- .../main/java/com/github/kr328/clash/MainApplication.kt | 7 +++---- .../main/java/com/github/kr328/clash/ProfilesActivity.kt | 3 ++- app/src/main/java/com/github/kr328/clash/ProxyActivity.kt | 2 +- app/src/main/java/com/github/kr328/clash/TileService.kt | 3 +++ .../java/com/github/kr328/clash/core/model/ProxyPacket.kt | 4 ++-- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 8b502fa..8840242 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,8 +13,8 @@ android { applicationId "com.github.kr328.clash" minSdkVersion 24 targetSdkVersion 29 - versionCode 10015 - versionName "1.0.15-alpha" + versionCode 10016 + versionName "1.0.16-alpha" } buildTypes { release { diff --git a/app/src/main/java/com/github/kr328/clash/MainApplication.kt b/app/src/main/java/com/github/kr328/clash/MainApplication.kt index ee2987a..2a1983b 100644 --- a/app/src/main/java/com/github/kr328/clash/MainApplication.kt +++ b/app/src/main/java/com/github/kr328/clash/MainApplication.kt @@ -26,12 +26,11 @@ class MainApplication : Application() { override fun onCreate() { super.onCreate() - try { + runCatching { FirebaseApp.initializeApp(this) + } + runCatching { Fabric.with(this) - Log.i("Registered") - } catch (e: IllegalStateException) { - Log.i("Already registered") } Log.handler = object: Log.LogHandler { diff --git a/app/src/main/java/com/github/kr328/clash/ProfilesActivity.kt b/app/src/main/java/com/github/kr328/clash/ProfilesActivity.kt index af3055b..636e74b 100644 --- a/app/src/main/java/com/github/kr328/clash/ProfilesActivity.kt +++ b/app/src/main/java/com/github/kr328/clash/ProfilesActivity.kt @@ -189,7 +189,8 @@ class ProfilesActivity : BaseActivity() { } runOnUiThread { - dialog?.dismiss() + if ( dialog?.isShowing == true ) + dialog?.dismiss() } } } diff --git a/app/src/main/java/com/github/kr328/clash/ProxyActivity.kt b/app/src/main/java/com/github/kr328/clash/ProxyActivity.kt index a2672ee..ee599d9 100644 --- a/app/src/main/java/com/github/kr328/clash/ProxyActivity.kt +++ b/app/src/main/java/com/github/kr328/clash/ProxyActivity.kt @@ -78,7 +78,7 @@ class ProxyActivity : BaseActivity() { runClash { clash -> val packet = clash.queryAllProxies() val proxies = packet.proxies - val order = (proxies["GLOBAL".hashCode()] ?: error("GLOBAL not found")).all + val order = (proxies["GLOBAL".hashCode()]?.all ?: emptyList()) .mapIndexed { index, i -> i to index }.toMap() val listData = proxies diff --git a/app/src/main/java/com/github/kr328/clash/TileService.kt b/app/src/main/java/com/github/kr328/clash/TileService.kt index 02cec2f..3ec689c 100644 --- a/app/src/main/java/com/github/kr328/clash/TileService.kt +++ b/app/src/main/java/com/github/kr328/clash/TileService.kt @@ -41,6 +41,9 @@ class TileService : TileService() { } private fun refreshStatus() { + if ( qsTile == null ) + return + val current = getCurrentStatus() when (current.first) { diff --git a/core/src/main/java/com/github/kr328/clash/core/model/ProxyPacket.kt b/core/src/main/java/com/github/kr328/clash/core/model/ProxyPacket.kt index c9fdb2c..651297d 100644 --- a/core/src/main/java/com/github/kr328/clash/core/model/ProxyPacket.kt +++ b/core/src/main/java/com/github/kr328/clash/core/model/ProxyPacket.kt @@ -8,7 +8,7 @@ import kotlinx.serialization.Serializable @Serializable data class ProxyPacket(val mode: String, val proxies: Map): Parcelable { @Serializable - data class Proxy(val name: String, val type: Type, val now: Int, val all: Set, val delay: Long) + data class Proxy(val name: String, val type: Type, val now: Int, val all: List, val delay: Long) enum class Type { SELECT, @@ -78,7 +78,7 @@ data class ProxyPacket(val mode: String, val proxies: Map): Parcelab } val now = hashed[entry.value.second.now]?.first ?: 0 - val all = entry.value.second.all.mapNotNull { hashed[it]?.first }.toSet() + val all = entry.value.second.all.mapNotNull { hashed[it]?.first } val delay = entry.value.second.history.firstOrNull()?.delay ?: 0 entry.value.first to Proxy(entry.key, type, now, all, delay)