mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-02-16 11:41:16 +01:00
Start migration of Album and Artist
This commit is contained in:
parent
d243ae1b44
commit
7640f4c4aa
@ -7,7 +7,6 @@ import androidx.lifecycle.LiveData
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.moire.ultrasonic.R
|
||||
import org.moire.ultrasonic.adapters.AlbumRowAdapter
|
||||
import org.moire.ultrasonic.domain.MusicDirectory
|
||||
import org.moire.ultrasonic.util.Constants
|
||||
|
||||
@ -15,7 +14,7 @@ import org.moire.ultrasonic.util.Constants
|
||||
* Displays a list of Albums from the media library
|
||||
* TODO: Check refresh is working
|
||||
*/
|
||||
class AlbumListFragment : EntryListFragment<MusicDirectory.Entry, AlbumRowAdapter>() {
|
||||
class AlbumListFragment : EntryListFragment<MusicDirectory.Entry>() {
|
||||
|
||||
/**
|
||||
* The ViewModel to use to get the data
|
||||
@ -55,19 +54,20 @@ class AlbumListFragment : EntryListFragment<MusicDirectory.Entry, AlbumRowAdapte
|
||||
return listModel.getAlbumList(refresh or append, refreshListView!!, args)
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide the Adapter for the RecyclerView with a lazy delegate
|
||||
*/
|
||||
override val viewAdapter: AlbumRowAdapter by lazy {
|
||||
AlbumRowAdapter(
|
||||
liveDataItems.value ?: listOf(),
|
||||
{ entry -> onItemClick(entry) },
|
||||
{ menuItem, entry -> onContextMenuItemSelected(menuItem, entry) },
|
||||
imageLoaderProvider.getImageLoader(),
|
||||
onMusicFolderUpdate,
|
||||
requireContext()
|
||||
)
|
||||
}
|
||||
// FIXME
|
||||
// /**
|
||||
// * Provide the Adapter for the RecyclerView with a lazy delegate
|
||||
// */
|
||||
// override val viewAdapter: AlbumRowAdapter by lazy {
|
||||
// AlbumRowAdapter(
|
||||
// liveDataItems.value ?: listOf(),
|
||||
// { entry -> onItemClick(entry) },
|
||||
// { menuItem, entry -> onContextMenuItemSelected(menuItem, entry) },
|
||||
// imageLoaderProvider.getImageLoader(),
|
||||
// onMusicFolderUpdate,
|
||||
// requireContext()
|
||||
// )
|
||||
// }
|
||||
|
||||
val newBundleClone: Bundle
|
||||
get() = arguments?.clone() as Bundle
|
||||
|
@ -11,7 +11,7 @@ import org.moire.ultrasonic.util.Constants
|
||||
/**
|
||||
* Displays the list of Artists from the media library
|
||||
*/
|
||||
class ArtistListFragment : EntryListFragment<ArtistOrIndex, ArtistRowAdapter>() {
|
||||
class ArtistListFragment : EntryListFragment<ArtistOrIndex>() {
|
||||
|
||||
/**
|
||||
* The ViewModel to use to get the data
|
||||
@ -50,13 +50,14 @@ class ArtistListFragment : EntryListFragment<ArtistOrIndex, ArtistRowAdapter>()
|
||||
/**
|
||||
* Provide the Adapter for the RecyclerView with a lazy delegate
|
||||
*/
|
||||
override val viewAdapter: ArtistRowAdapter by lazy {
|
||||
ArtistRowAdapter(
|
||||
liveDataItems.value ?: listOf(),
|
||||
{ entry -> onItemClick(entry) },
|
||||
{ menuItem, entry -> onContextMenuItemSelected(menuItem, entry) },
|
||||
imageLoaderProvider.getImageLoader(),
|
||||
onMusicFolderUpdate
|
||||
)
|
||||
}
|
||||
// FIXME
|
||||
// override val viewAdapter: ArtistRowAdapter by lazy {
|
||||
// ArtistRowAdapter(
|
||||
// liveDataItems.value ?: listOf(),
|
||||
// { entry -> onItemClick(entry) },
|
||||
// { menuItem, entry -> onContextMenuItemSelected(menuItem, entry) },
|
||||
// imageLoaderProvider.getImageLoader(),
|
||||
// onMusicFolderUpdate
|
||||
// )
|
||||
// }
|
||||
}
|
||||
|
@ -35,12 +35,12 @@ class DownloadsFragment : MultiListFragment<DownloadFile>() {
|
||||
}
|
||||
|
||||
override fun onContextMenuItemSelected(menuItem: MenuItem, item: DownloadFile): Boolean {
|
||||
// Do nothing
|
||||
// TODO: Add code to enable manipulation of the download list
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onItemClick(item: DownloadFile) {
|
||||
// Do nothing
|
||||
// TODO: Add code to enable manipulation of the download list
|
||||
}
|
||||
|
||||
override fun setTitle(title: String?) {
|
||||
|
@ -182,8 +182,7 @@ abstract class GenericListFragment<T : Identifiable, TA : GenericRowAdapter<T>>
|
||||
abstract fun onItemClick(item: T)
|
||||
}
|
||||
|
||||
abstract class EntryListFragment<T : GenericEntry, TA : GenericRowAdapter<T>> :
|
||||
GenericListFragment<T, TA>() {
|
||||
abstract class EntryListFragment<T : GenericEntry> : MultiListFragment<T>() {
|
||||
@Suppress("LongMethod")
|
||||
override fun onContextMenuItemSelected(menuItem: MenuItem, item: T): Boolean {
|
||||
val isArtist = (item is Artist)
|
||||
|
@ -36,6 +36,7 @@ import timber.log.Timber
|
||||
/**
|
||||
* Contains the mini-now playing information box displayed at the bottom of the screen
|
||||
*/
|
||||
@Suppress("unused")
|
||||
class NowPlayingFragment : Fragment() {
|
||||
|
||||
private var downX = 0f
|
||||
@ -90,13 +91,13 @@ class NowPlayingFragment : Fragment() {
|
||||
if (playerState === PlayerState.PAUSED) {
|
||||
playButton!!.setImageDrawable(
|
||||
getDrawableFromAttribute(
|
||||
context, R.attr.media_play
|
||||
requireContext(), R.attr.media_play
|
||||
)
|
||||
)
|
||||
} else if (playerState === PlayerState.STARTED) {
|
||||
playButton!!.setImageDrawable(
|
||||
getDrawableFromAttribute(
|
||||
context, R.attr.media_pause
|
||||
requireContext(), R.attr.media_pause
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -51,9 +51,7 @@ import timber.log.Timber
|
||||
/**
|
||||
* Displays a group of tracks, eg. the songs of an album, of a playlist etc.
|
||||
* TODO: Move Clickhandler into ViewBinders
|
||||
* TODO: Migrate Album/artistsRow
|
||||
* TODO: Wrong count (selectall)
|
||||
* TODO: Handle updates (playstatus, download status)
|
||||
* TODO: Fix clikc handlers and context menus etc.
|
||||
*/
|
||||
class TrackCollectionFragment :
|
||||
MultiListFragment<MusicDirectory.Entry>() {
|
||||
@ -255,71 +253,71 @@ class TrackCollectionFragment :
|
||||
Timber.d("onContextItemSelected")
|
||||
val info = menuItem.menuInfo as AdapterContextMenuInfo? ?: return true
|
||||
|
||||
// val entry = listView!!.getItemAtPosition(info.position) as MusicDirectory.Entry?
|
||||
// ?: return true
|
||||
//
|
||||
// val entryId = entry.id
|
||||
//
|
||||
// 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.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.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.menu_pin -> {
|
||||
// downloadHandler.downloadRecursively(
|
||||
// this, entryId, save = true, append = true,
|
||||
// autoPlay = false, shuffle = false, background = false,
|
||||
// playNext = false, unpin = false, isArtist = false
|
||||
// )
|
||||
// }
|
||||
// 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.select_album_play_all -> {
|
||||
// // TODO: Why is this being handled here?!
|
||||
// playAll()
|
||||
// }
|
||||
// R.id.menu_item_share -> {
|
||||
// val entries: MutableList<MusicDirectory.Entry?> = ArrayList(1)
|
||||
// entries.add(entry)
|
||||
// shareHandler.createShare(
|
||||
// this, entries, refreshListView,
|
||||
// cancellationToken!!
|
||||
// )
|
||||
// return true
|
||||
// }
|
||||
// else -> {
|
||||
// return super.onContextItemSelected(menuItem)
|
||||
// }
|
||||
// }
|
||||
val entry = viewAdapter.getCurrentList()[info.position] as MusicDirectory.Entry?
|
||||
?: return true
|
||||
|
||||
val entryId = entry.id
|
||||
|
||||
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.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.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.menu_pin -> {
|
||||
downloadHandler.downloadRecursively(
|
||||
this, entryId, save = true, append = true,
|
||||
autoPlay = false, shuffle = false, background = false,
|
||||
playNext = false, unpin = false, isArtist = false
|
||||
)
|
||||
}
|
||||
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.select_album_play_all -> {
|
||||
// TODO: Why is this being handled here?!
|
||||
playAll()
|
||||
}
|
||||
R.id.menu_item_share -> {
|
||||
val entries: MutableList<MusicDirectory.Entry?> = ArrayList(1)
|
||||
entries.add(entry)
|
||||
shareHandler.createShare(
|
||||
this, entries, refreshListView,
|
||||
cancellationToken!!
|
||||
)
|
||||
return true
|
||||
}
|
||||
else -> {
|
||||
return super.onContextItemSelected(menuItem)
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user