If the playback service is stopped before the main activity gets killed, this would have caused the old class to still get updates.
Sending preference updates to such an orphaned PlaybackService would trigger crashes in some cases (especially when MediaLibrary detects suspicious unregisters).
The change adds interactive check to see if smooth scroll is actually
needed. If user doesn't see the library screen there's no point in
doing smooth scroll.
Besides, for old Android versions (like 4.x)
View.getFirstVisiblePosition, View.getLastVisiblePosition calls are
working only if view is currently visible.
* Update plugin waking code, fix crash on Oreo devices
In Android Oreo we can't use services without bringing them to the
foreground, i.e. showing icon and following specified lifecycle.
After some consideration the new way was implemented for plugin system.
Plugins will no longer have bound service and instead will do everything
required from within their activities. All background logic that
previously resided in services will now be performed before the activity
has even shown its window. This greatly reduces complexity and cost
associated with bringing service model in accordance with Oreo
guidelines. The only downside to this approach is small flickering
or pause in emulators as activities still expect to show themselves
on start instead of disappearing again.
* Move value to class-level constant
Now if the option "scroll to the queue position" is enabled and
a user is selecting a song in queue it immediately disappears from under
the finger and jumps to the top of currently visible list.
This patch fixes this behaviour - only scroll if next (or previous) song
falls out of list view visible range. I.e. sudden scrolling will never
happen if user clicks an item in queue as it's currently visible.
This is a special-snowflake menu entry which is only visible in one specific adapter.
Let onPrepareOptionsMenu fully manage it to avoid clashes with SlidingPlaybackView's menu entry hider.
ShowQueueFragment used to keep a reference to PlaybackService - which may get stale at some point (if the service is re-created), causing the fragment to lose any functionality.
This commit gets rid of the long lived reference.
(Note that the Adapter still has a semi-long-lived reference. Thats not nice but okay as it only needs to access the SongTimeline)