Merge branch 'develop' into strings-update
This commit is contained in:
commit
6442bae882
|
@ -46,6 +46,7 @@ import org.moire.ultrasonic.util.Constants
|
|||
import org.moire.ultrasonic.util.EntryByDiscAndTrackComparator
|
||||
import org.moire.ultrasonic.util.Settings
|
||||
import org.moire.ultrasonic.util.Util
|
||||
import org.moire.ultrasonic.util.Util.toast
|
||||
|
||||
/**
|
||||
* Displays a group of tracks, eg. the songs of an album, of a playlist etc.
|
||||
|
@ -246,9 +247,10 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
|
|||
super.onDestroyView()
|
||||
}
|
||||
|
||||
private fun playNow(append: Boolean) {
|
||||
val selectedSongs = getSelectedSongs()
|
||||
|
||||
private fun playNow(
|
||||
append: Boolean,
|
||||
selectedSongs: List<MusicDirectory.Entry> = getSelectedSongs()
|
||||
) {
|
||||
if (selectedSongs.isNotEmpty()) {
|
||||
downloadHandler.download(
|
||||
this, append, false, !append, playNext = false,
|
||||
|
@ -374,7 +376,10 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
|
|||
downloadBackground(save, songs)
|
||||
}
|
||||
|
||||
private fun downloadBackground(save: Boolean, songs: List<MusicDirectory.Entry?>) {
|
||||
private fun downloadBackground(
|
||||
save: Boolean,
|
||||
songs: List<MusicDirectory.Entry?>
|
||||
) {
|
||||
val onValid = Runnable {
|
||||
networkAndStorageChecker.warnIfNetworkOrStorageUnavailable()
|
||||
mediaPlayerController.downloadBackground(songs, save)
|
||||
|
@ -398,9 +403,7 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
|
|||
onValid.run()
|
||||
}
|
||||
|
||||
internal fun delete() {
|
||||
val songs = getSelectedSongs()
|
||||
|
||||
internal fun delete(songs: List<MusicDirectory.Entry> = getSelectedSongs()) {
|
||||
Util.toast(
|
||||
context,
|
||||
resources.getQuantityString(
|
||||
|
@ -411,8 +414,7 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
|
|||
mediaPlayerController.delete(songs)
|
||||
}
|
||||
|
||||
internal fun unpin() {
|
||||
val songs = getSelectedSongs()
|
||||
internal fun unpin(songs: List<MusicDirectory.Entry> = getSelectedSongs()) {
|
||||
Util.toast(
|
||||
context,
|
||||
resources.getQuantityString(
|
||||
|
@ -619,56 +621,40 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
|
|||
menuItem: MenuItem,
|
||||
item: MusicDirectory.Child
|
||||
): Boolean {
|
||||
val entryId = item.id
|
||||
val songs = getClickedSong(item)
|
||||
|
||||
when (menuItem.itemId) {
|
||||
R.id.menu_play_now -> {
|
||||
downloadHandler.downloadRecursively(
|
||||
this, entryId, save = false, append = false,
|
||||
autoPlay = true, shuffle = false, background = false,
|
||||
playNext = false, unpin = false, isArtist = false
|
||||
R.id.song_menu_play_now -> {
|
||||
playNow(false, songs)
|
||||
}
|
||||
R.id.song_menu_play_next -> {
|
||||
downloadHandler.download(
|
||||
fragment = this@TrackCollectionFragment,
|
||||
append = true,
|
||||
save = false,
|
||||
autoPlay = false,
|
||||
playNext = true,
|
||||
shuffle = false,
|
||||
songs = songs
|
||||
)
|
||||
}
|
||||
R.id.menu_play_next -> {
|
||||
downloadHandler.downloadRecursively(
|
||||
this, entryId, save = false, append = false,
|
||||
autoPlay = false, shuffle = false, background = false,
|
||||
playNext = true, unpin = false, isArtist = false
|
||||
)
|
||||
R.id.song_menu_play_last -> {
|
||||
playNow(true, songs)
|
||||
}
|
||||
R.id.menu_play_last -> {
|
||||
downloadHandler.downloadRecursively(
|
||||
this, entryId, save = false, append = true,
|
||||
autoPlay = false, shuffle = false, background = false,
|
||||
playNext = false, unpin = false, isArtist = false
|
||||
)
|
||||
R.id.song_menu_pin -> {
|
||||
downloadBackground(true, songs)
|
||||
}
|
||||
R.id.menu_pin -> {
|
||||
downloadHandler.downloadRecursively(
|
||||
this, entryId, save = true, append = true,
|
||||
autoPlay = false, shuffle = false, background = false,
|
||||
playNext = false, unpin = false, isArtist = false
|
||||
)
|
||||
R.id.song_menu_unpin -> {
|
||||
unpin(songs)
|
||||
}
|
||||
R.id.menu_unpin -> {
|
||||
downloadHandler.downloadRecursively(
|
||||
this, entryId, save = false, append = false,
|
||||
autoPlay = false, shuffle = false, background = false,
|
||||
playNext = false, unpin = true, isArtist = false
|
||||
)
|
||||
}
|
||||
R.id.menu_download -> {
|
||||
downloadHandler.downloadRecursively(
|
||||
this, entryId, save = false, append = false,
|
||||
autoPlay = false, shuffle = false, background = true,
|
||||
playNext = false, unpin = false, isArtist = false
|
||||
)
|
||||
R.id.song_menu_download -> {
|
||||
downloadBackground(false, songs)
|
||||
}
|
||||
R.id.select_album_play_all -> {
|
||||
// TODO: Why is this being handled here?!
|
||||
playAll()
|
||||
}
|
||||
R.id.menu_item_share -> {
|
||||
R.id.song_menu_share -> {
|
||||
if (item is MusicDirectory.Entry) {
|
||||
shareHandler.createShare(
|
||||
this, listOf(item), refreshListView,
|
||||
|
@ -683,6 +669,16 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
|
|||
return true
|
||||
}
|
||||
|
||||
internal fun getClickedSong(item: MusicDirectory.Child): List<MusicDirectory.Entry> {
|
||||
// This can probably be done better
|
||||
return viewAdapter.getCurrentList().mapNotNull {
|
||||
if (it is MusicDirectory.Entry && (it.id == item.id))
|
||||
it
|
||||
else
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
override fun onItemClick(item: MusicDirectory.Child) {
|
||||
when {
|
||||
item.isDirectory -> {
|
||||
|
|
Loading…
Reference in New Issue