mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2026-05-09 18:11:26 +08:00
Improve: migrate to latest dependencies
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class LogsActivity : BaseActivity<LogsDesign>() {
|
||||
deleteAllLogs()
|
||||
}
|
||||
|
||||
events.offer(Event.ActivityStart)
|
||||
events.trySend(Event.ActivityStart)
|
||||
}
|
||||
}
|
||||
is LogsDesign.Request.OpenFile -> {
|
||||
|
||||
@@ -32,4 +32,8 @@ class MainApplication : Application() {
|
||||
sendServiceRecreated()
|
||||
}
|
||||
}
|
||||
|
||||
fun finalize() {
|
||||
Global.destroy()
|
||||
}
|
||||
}
|
||||
@@ -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 -> {
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user