mirror of
https://github.com/rebelonion/Dantotsu.git
synced 2026-01-19 05:53:55 +00:00
rpc fix
This commit is contained in:
@@ -105,17 +105,14 @@ class DiscordService : Service() {
|
||||
if (intent != null) {
|
||||
if (intent.hasExtra("presence")) {
|
||||
log("Service onStartCommand() setPresence")
|
||||
var lPresence = intent.getStringExtra("presence")
|
||||
val lPresence = intent.getStringExtra("presence")
|
||||
if (this::webSocket.isInitialized) webSocket.send(lPresence!!)
|
||||
presenceStore = lPresence!!
|
||||
} else {
|
||||
log("Service onStartCommand() no presence")
|
||||
DiscordServiceRunningSingleton.running = false
|
||||
client.dispatcher.executorService.shutdown()
|
||||
stopSelf()
|
||||
}
|
||||
if (intent.hasExtra(ACTION_STOP_SERVICE)) {
|
||||
log("Service onStartCommand() stopService")
|
||||
//kill the client
|
||||
client = OkHttpClient()
|
||||
stopSelf()
|
||||
}
|
||||
}
|
||||
@@ -145,6 +142,7 @@ class DiscordService : Service() {
|
||||
wakeLock.release()
|
||||
}
|
||||
SERVICE_RUNNING = false
|
||||
client = OkHttpClient()
|
||||
if (this::webSocket.isInitialized) webSocket.close(1000, "Closed by user")
|
||||
super.onDestroy()
|
||||
//saveLogToFile()
|
||||
@@ -468,7 +466,6 @@ class DiscordService : Service() {
|
||||
|
||||
companion object {
|
||||
var SERVICE_RUNNING = false
|
||||
const val ACTION_STOP_SERVICE = "ACTION_STOP_SERVICE"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -124,12 +124,10 @@ class MangaReaderActivity : AppCompatActivity() {
|
||||
|
||||
override fun onDestroy() {
|
||||
mangaCache.clear()
|
||||
val stopIntent = Intent(this, DiscordService::class.java).apply {
|
||||
putExtra(DiscordService.ACTION_STOP_SERVICE, true)
|
||||
}
|
||||
if (!isOnline(this)) { //TODO:
|
||||
if (isOnline(baseContext)) { //TODO:
|
||||
DiscordServiceRunningSingleton.running = false
|
||||
startService(stopIntent)
|
||||
val stopIntent = Intent(this, DiscordService::class.java)
|
||||
stopService(stopIntent)
|
||||
}
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user