rpc fix
This commit is contained in:
parent
c728eae2ba
commit
8c957007ab
2 changed files with 7 additions and 12 deletions
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue