From de87e3fd744677a4c48598bcdf4907c3bc63264c Mon Sep 17 00:00:00 2001 From: Kr328 <39107975+Kr328@users.noreply.github.com> Date: Sun, 23 Feb 2020 22:54:13 +0800 Subject: [PATCH] add crash log --- .../main/java/com/github/kr328/clash/LogcatService.kt | 11 ++++++----- .../com/github/kr328/clash/adapter/ProxyAdapter.kt | 10 ++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/github/kr328/clash/LogcatService.kt b/app/src/main/java/com/github/kr328/clash/LogcatService.kt index 2f28e7f..99dd4e3 100644 --- a/app/src/main/java/com/github/kr328/clash/LogcatService.kt +++ b/app/src/main/java/com/github/kr328/clash/LogcatService.kt @@ -8,10 +8,7 @@ import android.content.ComponentName import android.content.Context import android.content.Intent import android.content.ServiceConnection -import android.os.Binder -import android.os.Build -import android.os.IBinder -import android.os.IInterface +import android.os.* import androidx.collection.CircularArray import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat @@ -27,6 +24,8 @@ import com.github.kr328.clash.service.util.createLanguageConfigurationContext import com.github.kr328.clash.service.util.intent import com.github.kr328.clash.utils.format import com.github.kr328.clash.utils.logsDir +import com.microsoft.appcenter.analytics.Analytics +import com.microsoft.appcenter.crashes.Crashes import kotlinx.coroutines.* import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.selects.select @@ -57,7 +56,9 @@ class LogcatService : Service(), CoroutineScope by MainScope(), IInterface { private val connection = object : ServiceConnection { override fun onServiceDisconnected(name: ComponentName?) { - stopSelf() + logChannel.offer(LogEvent(LogEvent.Level.ERROR, "Clash Service Crashed")) + + Crashes.trackError(RemoteException("Clash Service Crashed")) } override fun onServiceConnected(name: ComponentName?, service: IBinder?) { diff --git a/app/src/main/java/com/github/kr328/clash/adapter/ProxyAdapter.kt b/app/src/main/java/com/github/kr328/clash/adapter/ProxyAdapter.kt index 76a0d64..fb45929 100644 --- a/app/src/main/java/com/github/kr328/clash/adapter/ProxyAdapter.kt +++ b/app/src/main/java/com/github/kr328/clash/adapter/ProxyAdapter.kt @@ -153,6 +153,10 @@ class ProxyAdapter( groupPosition = groupCache activeList = activeCache result.dispatchUpdatesTo(this@ProxyAdapter) + + groupCache.forEach { (_, u) -> + notifyItemChanged(u) + } } } @@ -190,8 +194,6 @@ class ProxyAdapter( is ProxyGroupHeader -> { val current = renderList[position] as ProxyGroupRenderInfo - groupPosition[current.name] = position - holder.title.text = context.getString(R.string.format_proxy_group_title, current.info.name, current.info.current) holder.urlTest.setOnClickListener { @@ -221,8 +223,6 @@ class ProxyAdapter( holder.delay.text = if (current.info.selectable) "" else "N/A" if (current.info.active) { - activeList[current.group] = position - holder.prefix.setTextColor(Color.WHITE) holder.content.setTextColor(Color.WHITE) holder.delay.setTextColor(Color.WHITE) @@ -246,6 +246,8 @@ class ProxyAdapter( renderList[position] = new.copy(info = new.info.copy(active = true)) renderList[groupPosition] = group.copy(info = group.info.copy(current = current.name)) + activeList[current.group] = position + notifyItemChanged(oldPosition) notifyItemChanged(position) notifyItemChanged(groupPosition)