Skip to content
This repository has been archived by the owner on Dec 28, 2022. It is now read-only.

Commit

Permalink
Fixed an issue where load() was called on background thread
Browse files Browse the repository at this point in the history
  • Loading branch information
timusus committed Nov 21, 2018
1 parent f508882 commit a0fdf3c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import com.simplecity.amp_library.model.Song
import com.simplecity.amp_library.utils.DataManager
import com.simplecity.amp_library.utils.StringUtils
import io.reactivex.Single
import io.reactivex.android.schedulers.AndroidSchedulers

sealed class MediaIdWrapper {

Expand Down Expand Up @@ -149,20 +150,23 @@ class MediaIdHelper {
.sortedBy { song -> song.albumName }
.sortedBy { song -> song.track }
}
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{ songs -> completion(songs, songs.indexOfFirst { it.id == mediaWrapper.songId }.or(0)) },
{ completion(mutableListOf(), 0) }
)
}
is MediaIdWrapper.Playlist -> {
getSongsForPlaylistId(mediaWrapper.playlistId)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{ songs -> completion(songs, 0) },
{ completion(mutableListOf(), 0) }
)
}
is MediaIdWrapper.Genre -> {
getSongsForGenreId(mediaWrapper.genreId)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{ songs -> completion(songs, 0) },
{ completion(mutableListOf(), 0) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.simplecity.amp_library.utils.LogUtils;
import com.simplecity.amp_library.utils.SettingsManager;
import com.simplecity.amp_library.utils.SleepTimer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers;
import java.util.List;
Expand Down Expand Up @@ -143,6 +144,7 @@ void playAutoShuffleList() {
disposables.add(DataManager.getInstance().getSongsRelay()
.firstOrError()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(songs -> {
queueManager.playlist = QueueItemKt.toQueueItems(songs);
queueManager.queuePosition = -1;
Expand Down

0 comments on commit a0fdf3c

Please sign in to comment.