Improve: migrate to latest dependencies

This commit is contained in:
Kr328
2021-05-24 15:57:22 +08:00
parent 4f05ba1ac6
commit 27dc5395e0
31 changed files with 92 additions and 83 deletions

View File

@@ -114,7 +114,7 @@ abstract class BaseActivity<D : Design<*>> :
Remote.broadcasts.addObserver(this)
events.offer(Event.ActivityStart)
events.trySend(Event.ActivityStart)
}
override fun onStop() {
@@ -124,7 +124,7 @@ abstract class BaseActivity<D : Design<*>> :
Remote.broadcasts.removeObserver(this)
events.offer(Event.ActivityStop)
events.trySend(Event.ActivityStop)
}
override fun onDestroy() {
@@ -174,23 +174,23 @@ abstract class BaseActivity<D : Design<*>> :
}
override fun onProfileChanged() {
events.offer(Event.ProfileChanged)
events.trySend(Event.ProfileChanged)
}
override fun onProfileLoaded() {
events.offer(Event.ProfileLoaded)
events.trySend(Event.ProfileLoaded)
}
override fun onServiceRecreated() {
events.offer(Event.ServiceRecreated)
events.trySend(Event.ServiceRecreated)
}
override fun onStarted() {
events.offer(Event.ClashStart)
events.trySend(Event.ClashStart)
}
override fun onStopped(cause: String?) {
events.offer(Event.ClashStop)
events.trySend(Event.ClashStop)
if (cause != null && activityStarted) {
launch {

View File

@@ -141,7 +141,7 @@ class FilesActivity : BaseActivity<FilesDesign>() {
}
override fun onBackPressed() {
design?.requests?.offer(FilesDesign.Request.PopStack)
design?.requests?.trySend(FilesDesign.Request.PopStack)
}
private suspend fun FilesDesign.fetch(client: FilesClient, stack: Stack<String>, root: String) {

View File

@@ -97,7 +97,7 @@ class LogcatService : Service(), CoroutineScope by CoroutineScope(Dispatchers.De
LogcatWriter(this@LogcatService).use {
val observer = object : ILogObserver {
override fun newItem(log: LogMessage) {
channel.offer(log)
channel.trySend(log)
}
}

View File

@@ -47,7 +47,7 @@ class LogsActivity : BaseActivity<LogsDesign>() {
deleteAllLogs()
}
events.offer(Event.ActivityStart)
events.trySend(Event.ActivityStart)
}
}
is LogsDesign.Request.OpenFile -> {

View File

@@ -32,4 +32,8 @@ class MainApplication : Application() {
sendServiceRecreated()
}
}
fun finalize() {
Global.destroy()
}
}

View File

@@ -73,7 +73,7 @@ class ProxyActivity : BaseActivity<ProxyDesign>() {
}
ProxyDesign.Request.ReloadAll -> {
names.indices.forEach { idx ->
design.requests.offer(ProxyDesign.Request.Reload(idx))
design.requests.trySend(ProxyDesign.Request.Reload(idx))
}
}
is ProxyDesign.Request.Reload -> {

View File

@@ -10,7 +10,6 @@ import com.github.kr328.clash.store.AppStore
import com.github.kr328.clash.util.ApplicationObserver
import com.github.kr328.clash.util.verifyApk
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.launch
@@ -30,9 +29,9 @@ object Remote {
fun launch() {
ApplicationObserver.attach(Global.application)
ApplicationObserver.onVisibleChanged(visible::offer)
ApplicationObserver.onVisibleChanged { visible.trySend(it) }
GlobalScope.launch(Dispatchers.IO) {
Global.launch(Dispatchers.IO) {
run()
}
}