mirror of
https://github.com/apognu/otter
synced 2025-02-09 15:58:39 +01:00
Some vendors' battery optimizers killed the background service quite
quickly when the app is in the background and *not* playing music. This had the effect of breaking all player actions within the app (queue listing, playback control, etc.). This "starts" PlayerService every time MainActivity is resumed, which is a noop if the service is still running, but allows retrieving app functionality otherwise.
This commit is contained in:
parent
bf1bba1162
commit
657c72480e
@ -90,8 +90,8 @@ dependencies {
|
||||
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
|
||||
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.50")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.2")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.2")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2")
|
||||
|
||||
implementation("androidx.appcompat:appcompat:1.1.0")
|
||||
implementation("androidx.core:core-ktx:1.2.0-beta01")
|
||||
|
@ -17,7 +17,7 @@ class Otter : Application() {
|
||||
fun get(): Otter = instance
|
||||
}
|
||||
|
||||
var eventBus: BroadcastChannel<Event> = BroadcastChannel(10)
|
||||
val eventBus: BroadcastChannel<Event> = BroadcastChannel(10)
|
||||
val commandBus: Channel<Command> = Channel(10)
|
||||
val requestBus: BroadcastChannel<Request> = BroadcastChannel(10)
|
||||
val progressBus: BroadcastChannel<Triple<Int, Int, Int>> = ConflatedBroadcastChannel()
|
||||
|
@ -59,8 +59,6 @@ class MainActivity : AppCompatActivity() {
|
||||
.replace(R.id.container, BrowseFragment())
|
||||
.commit()
|
||||
|
||||
startService(Intent(this, PlayerService::class.java))
|
||||
|
||||
watchEventBus()
|
||||
|
||||
CommandBus.send(Command.RefreshService)
|
||||
@ -69,6 +67,8 @@ class MainActivity : AppCompatActivity() {
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
startService(Intent(this, PlayerService::class.java))
|
||||
|
||||
now_playing_toggle.setOnClickListener {
|
||||
CommandBus.send(Command.ToggleState)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user