mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-02-16 11:41:16 +01:00
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.EntryByDiscAndTrackComparator
|
||||||
import org.moire.ultrasonic.util.Settings
|
import org.moire.ultrasonic.util.Settings
|
||||||
import org.moire.ultrasonic.util.Util
|
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.
|
* 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()
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun playNow(append: Boolean) {
|
private fun playNow(
|
||||||
val selectedSongs = getSelectedSongs()
|
append: Boolean,
|
||||||
|
selectedSongs: List<MusicDirectory.Entry> = getSelectedSongs()
|
||||||
|
) {
|
||||||
if (selectedSongs.isNotEmpty()) {
|
if (selectedSongs.isNotEmpty()) {
|
||||||
downloadHandler.download(
|
downloadHandler.download(
|
||||||
this, append, false, !append, playNext = false,
|
this, append, false, !append, playNext = false,
|
||||||
@ -374,7 +376,10 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
|
|||||||
downloadBackground(save, songs)
|
downloadBackground(save, songs)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun downloadBackground(save: Boolean, songs: List<MusicDirectory.Entry?>) {
|
private fun downloadBackground(
|
||||||
|
save: Boolean,
|
||||||
|
songs: List<MusicDirectory.Entry?>
|
||||||
|
) {
|
||||||
val onValid = Runnable {
|
val onValid = Runnable {
|
||||||
networkAndStorageChecker.warnIfNetworkOrStorageUnavailable()
|
networkAndStorageChecker.warnIfNetworkOrStorageUnavailable()
|
||||||
mediaPlayerController.downloadBackground(songs, save)
|
mediaPlayerController.downloadBackground(songs, save)
|
||||||
@ -398,9 +403,7 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
|
|||||||
onValid.run()
|
onValid.run()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun delete() {
|
internal fun delete(songs: List<MusicDirectory.Entry> = getSelectedSongs()) {
|
||||||
val songs = getSelectedSongs()
|
|
||||||
|
|
||||||
Util.toast(
|
Util.toast(
|
||||||
context,
|
context,
|
||||||
resources.getQuantityString(
|
resources.getQuantityString(
|
||||||
@ -411,8 +414,7 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
|
|||||||
mediaPlayerController.delete(songs)
|
mediaPlayerController.delete(songs)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun unpin() {
|
internal fun unpin(songs: List<MusicDirectory.Entry> = getSelectedSongs()) {
|
||||||
val songs = getSelectedSongs()
|
|
||||||
Util.toast(
|
Util.toast(
|
||||||
context,
|
context,
|
||||||
resources.getQuantityString(
|
resources.getQuantityString(
|
||||||
@ -619,56 +621,40 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
|
|||||||
menuItem: MenuItem,
|
menuItem: MenuItem,
|
||||||
item: MusicDirectory.Child
|
item: MusicDirectory.Child
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val entryId = item.id
|
val songs = getClickedSong(item)
|
||||||
|
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.menu_play_now -> {
|
R.id.song_menu_play_now -> {
|
||||||
downloadHandler.downloadRecursively(
|
playNow(false, songs)
|
||||||
this, entryId, save = false, append = false,
|
}
|
||||||
autoPlay = true, shuffle = false, background = false,
|
R.id.song_menu_play_next -> {
|
||||||
playNext = false, unpin = false, isArtist = false
|
downloadHandler.download(
|
||||||
|
fragment = this@TrackCollectionFragment,
|
||||||
|
append = true,
|
||||||
|
save = false,
|
||||||
|
autoPlay = false,
|
||||||
|
playNext = true,
|
||||||
|
shuffle = false,
|
||||||
|
songs = songs
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
R.id.menu_play_next -> {
|
R.id.song_menu_play_last -> {
|
||||||
downloadHandler.downloadRecursively(
|
playNow(true, songs)
|
||||||
this, entryId, save = false, append = false,
|
|
||||||
autoPlay = false, shuffle = false, background = false,
|
|
||||||
playNext = true, unpin = false, isArtist = false
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
R.id.menu_play_last -> {
|
R.id.song_menu_pin -> {
|
||||||
downloadHandler.downloadRecursively(
|
downloadBackground(true, songs)
|
||||||
this, entryId, save = false, append = true,
|
|
||||||
autoPlay = false, shuffle = false, background = false,
|
|
||||||
playNext = false, unpin = false, isArtist = false
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
R.id.menu_pin -> {
|
R.id.song_menu_unpin -> {
|
||||||
downloadHandler.downloadRecursively(
|
unpin(songs)
|
||||||
this, entryId, save = true, append = true,
|
|
||||||
autoPlay = false, shuffle = false, background = false,
|
|
||||||
playNext = false, unpin = false, isArtist = false
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
R.id.menu_unpin -> {
|
R.id.song_menu_download -> {
|
||||||
downloadHandler.downloadRecursively(
|
downloadBackground(false, songs)
|
||||||
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.select_album_play_all -> {
|
R.id.select_album_play_all -> {
|
||||||
// TODO: Why is this being handled here?!
|
// TODO: Why is this being handled here?!
|
||||||
playAll()
|
playAll()
|
||||||
}
|
}
|
||||||
R.id.menu_item_share -> {
|
R.id.song_menu_share -> {
|
||||||
if (item is MusicDirectory.Entry) {
|
if (item is MusicDirectory.Entry) {
|
||||||
shareHandler.createShare(
|
shareHandler.createShare(
|
||||||
this, listOf(item), refreshListView,
|
this, listOf(item), refreshListView,
|
||||||
@ -683,6 +669,16 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
|
|||||||
return true
|
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) {
|
override fun onItemClick(item: MusicDirectory.Child) {
|
||||||
when {
|
when {
|
||||||
item.isDirectory -> {
|
item.isDirectory -> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user