mirror of
https://gitlab.com/ultrasonic/ultrasonic.git
synced 2025-04-12 15:37:17 +03:00
Merge branch 'playlistSorting' into 'develop'
Don't sort playlists even when Sort by Disc is activated Closes #1229 See merge request ultrasonic/ultrasonic!1007
This commit is contained in:
commit
b0e850d17e
@ -29,7 +29,8 @@ import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import java.util.Locale
|
||||
import org.koin.java.KoinJavaComponent.inject
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.inject
|
||||
import org.moire.ultrasonic.NavigationGraphDirections
|
||||
import org.moire.ultrasonic.R
|
||||
import org.moire.ultrasonic.api.subsonic.ApiNotSupportedException
|
||||
@ -55,15 +56,13 @@ import org.moire.ultrasonic.util.Util.toast
|
||||
*
|
||||
* TODO: This file has been converted from Java, but not modernized yet.
|
||||
*/
|
||||
class PlaylistsFragment : Fragment() {
|
||||
class PlaylistsFragment : Fragment(), KoinComponent {
|
||||
private var refreshPlaylistsListView: SwipeRefreshLayout? = null
|
||||
private var playlistsListView: ListView? = null
|
||||
private var emptyTextView: View? = null
|
||||
private var playlistAdapter: ArrayAdapter<Playlist>? = null
|
||||
|
||||
private val downloadHandler = inject<DownloadHandler>(
|
||||
DownloadHandler::class.java
|
||||
)
|
||||
private val downloadHandler by inject<DownloadHandler>()
|
||||
|
||||
private var cancellationToken: CancellationToken? = null
|
||||
|
||||
@ -148,7 +147,7 @@ class PlaylistsFragment : Fragment() {
|
||||
val playlist = playlistsListView!!.getItemAtPosition(info.position) as Playlist
|
||||
when (menuItem.itemId) {
|
||||
R.id.playlist_menu_pin -> {
|
||||
downloadHandler.value.justDownload(
|
||||
downloadHandler.justDownload(
|
||||
DownloadAction.PIN,
|
||||
fragment = this,
|
||||
id = playlist.id,
|
||||
@ -158,7 +157,7 @@ class PlaylistsFragment : Fragment() {
|
||||
)
|
||||
}
|
||||
R.id.playlist_menu_unpin -> {
|
||||
downloadHandler.value.justDownload(
|
||||
downloadHandler.justDownload(
|
||||
DownloadAction.UNPIN,
|
||||
fragment = this,
|
||||
id = playlist.id,
|
||||
@ -168,7 +167,7 @@ class PlaylistsFragment : Fragment() {
|
||||
)
|
||||
}
|
||||
R.id.playlist_menu_download -> {
|
||||
downloadHandler.value.justDownload(
|
||||
downloadHandler.justDownload(
|
||||
DownloadAction.DOWNLOAD,
|
||||
fragment = this,
|
||||
id = playlist.id,
|
||||
|
@ -40,7 +40,7 @@ class TrackCollectionModel(application: Application) : GenericListModel(applicat
|
||||
|
||||
val service = MusicServiceFactory.getMusicService()
|
||||
val musicDirectory = service.getMusicDirectory(id, name, refresh)
|
||||
|
||||
currentListIsSortable = true
|
||||
updateList(musicDirectory)
|
||||
}
|
||||
}
|
||||
@ -51,7 +51,7 @@ class TrackCollectionModel(application: Application) : GenericListModel(applicat
|
||||
|
||||
val service = MusicServiceFactory.getMusicService()
|
||||
val musicDirectory: MusicDirectory = service.getAlbumAsDir(id, name, refresh)
|
||||
|
||||
currentListIsSortable = true
|
||||
updateList(musicDirectory)
|
||||
}
|
||||
}
|
||||
@ -60,6 +60,7 @@ class TrackCollectionModel(application: Application) : GenericListModel(applicat
|
||||
withContext(Dispatchers.IO) {
|
||||
val service = MusicServiceFactory.getMusicService()
|
||||
val musicDirectory = service.getSongsByGenre(genre, count, offset)
|
||||
currentListIsSortable = false
|
||||
updateList(musicDirectory, append)
|
||||
}
|
||||
}
|
||||
@ -76,7 +77,7 @@ class TrackCollectionModel(application: Application) : GenericListModel(applicat
|
||||
} else {
|
||||
Util.getSongsFromSearchResult(service.getStarred())
|
||||
}
|
||||
|
||||
currentListIsSortable = false
|
||||
updateList(musicDirectory)
|
||||
}
|
||||
}
|
||||
@ -87,8 +88,8 @@ class TrackCollectionModel(application: Application) : GenericListModel(applicat
|
||||
withContext(Dispatchers.IO) {
|
||||
val service = MusicServiceFactory.getMusicService()
|
||||
val videos = service.getVideos(refresh)
|
||||
|
||||
if (videos != null) {
|
||||
currentListIsSortable = false
|
||||
updateList(videos)
|
||||
}
|
||||
}
|
||||
@ -99,19 +100,16 @@ class TrackCollectionModel(application: Application) : GenericListModel(applicat
|
||||
withContext(Dispatchers.IO) {
|
||||
val service = MusicServiceFactory.getMusicService()
|
||||
val musicDirectory = service.getRandomSongs(size)
|
||||
|
||||
currentListIsSortable = false
|
||||
|
||||
updateList(musicDirectory, append)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getPlaylist(playlistId: String, playlistName: String) {
|
||||
|
||||
withContext(Dispatchers.IO) {
|
||||
val service = MusicServiceFactory.getMusicService()
|
||||
val musicDirectory = service.getPlaylist(playlistId, playlistName)
|
||||
|
||||
currentListIsSortable = false
|
||||
updateList(musicDirectory)
|
||||
}
|
||||
}
|
||||
@ -121,8 +119,8 @@ class TrackCollectionModel(application: Application) : GenericListModel(applicat
|
||||
withContext(Dispatchers.IO) {
|
||||
val service = MusicServiceFactory.getMusicService()
|
||||
val musicDirectory = service.getPodcastEpisodes(podcastChannelId)
|
||||
|
||||
if (musicDirectory != null) {
|
||||
currentListIsSortable = false
|
||||
updateList(musicDirectory)
|
||||
}
|
||||
}
|
||||
@ -144,7 +142,7 @@ class TrackCollectionModel(application: Application) : GenericListModel(applicat
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
currentListIsSortable = false
|
||||
updateList(musicDirectory)
|
||||
}
|
||||
}
|
||||
@ -153,7 +151,7 @@ class TrackCollectionModel(application: Application) : GenericListModel(applicat
|
||||
withContext(Dispatchers.IO) {
|
||||
val service = MusicServiceFactory.getMusicService()
|
||||
val musicDirectory = Util.getSongsFromBookmarks(service.getBookmarks())
|
||||
|
||||
currentListIsSortable = false
|
||||
updateList(musicDirectory)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user