Code refactor
This commit is contained in:
parent
c050ce3fbd
commit
f7d14e13c7
6 changed files with 25 additions and 18 deletions
|
@ -60,7 +60,7 @@ class SearchAdapter(
|
||||||
holder.title?.text = album.title
|
holder.title?.text = album.title
|
||||||
holder.text?.text = album.artistName
|
holder.text?.text = album.artistName
|
||||||
AlbumGlideRequest.Builder.from(Glide.with(activity), album.safeGetFirstSong())
|
AlbumGlideRequest.Builder.from(Glide.with(activity), album.safeGetFirstSong())
|
||||||
.checkIgnoreMediaStore(activity).build().into(holder.image)
|
.checkIgnoreMediaStore().build().into(holder.image)
|
||||||
}
|
}
|
||||||
ARTIST -> {
|
ARTIST -> {
|
||||||
val artist = dataSet.get(position) as Artist
|
val artist = dataSet.get(position) as Artist
|
||||||
|
|
|
@ -101,11 +101,10 @@ open class AlbumAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
AlbumGlideRequest.Builder.from(Glide.with(activity), album.safeGetFirstSong())
|
AlbumGlideRequest.Builder.from(Glide.with(activity), album.safeGetFirstSong())
|
||||||
.checkIgnoreMediaStore(activity)
|
.checkIgnoreMediaStore()
|
||||||
.generatePalette(activity)
|
.generatePalette(activity)
|
||||||
.build()
|
.build()
|
||||||
.into(object : RetroMusicColoredTarget(holder.image!!) {
|
.into(object : RetroMusicColoredTarget(holder.image!!) {
|
||||||
|
|
||||||
override fun onColorReady(colors: MediaNotificationProcessor) {
|
override fun onColorReady(colors: MediaNotificationProcessor) {
|
||||||
setColors(colors, holder)
|
setColors(colors, holder)
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ class HorizontalAlbumAdapter(
|
||||||
override fun loadAlbumCover(album: Album, holder: ViewHolder) {
|
override fun loadAlbumCover(album: Album, holder: ViewHolder) {
|
||||||
if (holder.image == null) return
|
if (holder.image == null) return
|
||||||
AlbumGlideRequest.Builder.from(Glide.with(activity), album.safeGetFirstSong())
|
AlbumGlideRequest.Builder.from(Glide.with(activity), album.safeGetFirstSong())
|
||||||
.checkIgnoreMediaStore(activity)
|
.checkIgnoreMediaStore()
|
||||||
.generatePalette(activity)
|
.generatePalette(activity)
|
||||||
.build()
|
.build()
|
||||||
.into(object : RetroMusicColoredTarget(holder.image!!) {
|
.into(object : RetroMusicColoredTarget(holder.image!!) {
|
||||||
|
|
|
@ -79,7 +79,7 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
||||||
toolbar.title = null
|
toolbar.title = null
|
||||||
|
|
||||||
postponeEnterTransition()
|
postponeEnterTransition()
|
||||||
detailsViewModel.getAlbum2().observe(viewLifecycleOwner, Observer {
|
detailsViewModel.getAlbum().observe(viewLifecycleOwner, Observer {
|
||||||
startPostponedEnterTransition()
|
startPostponedEnterTransition()
|
||||||
showAlbum(it)
|
showAlbum(it)
|
||||||
})
|
})
|
||||||
|
@ -149,12 +149,11 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
||||||
this.album = album
|
this.album = album
|
||||||
|
|
||||||
albumTitle.text = album.title
|
albumTitle.text = album.title
|
||||||
val songText =
|
val songText = resources.getQuantityString(
|
||||||
resources.getQuantityString(
|
R.plurals.albumSongs,
|
||||||
R.plurals.albumSongs,
|
album.songCount,
|
||||||
album.songCount,
|
album.songCount
|
||||||
album.songCount
|
)
|
||||||
)
|
|
||||||
songTitle.text = songText
|
songTitle.text = songText
|
||||||
|
|
||||||
if (MusicUtil.getYearString(album.year) == "-") {
|
if (MusicUtil.getYearString(album.year) == "-") {
|
||||||
|
@ -171,7 +170,7 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
||||||
MusicUtil.getReadableDurationString(MusicUtil.getTotalDuration(album.songs))
|
MusicUtil.getReadableDurationString(MusicUtil.getTotalDuration(album.songs))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
loadAlbumCover()
|
loadAlbumCover(album)
|
||||||
simpleSongAdapter.swapDataSet(album.songs)
|
simpleSongAdapter.swapDataSet(album.songs)
|
||||||
detailsViewModel.loadArtist(album.artistId)
|
detailsViewModel.loadArtist(album.artistId)
|
||||||
detailsViewModel.loadAlbumInfo(album)
|
detailsViewModel.loadAlbumInfo(album)
|
||||||
|
@ -216,6 +215,7 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
||||||
|
|
||||||
private fun loadArtistImage(artist: Artist) {
|
private fun loadArtistImage(artist: Artist) {
|
||||||
ArtistGlideRequest.Builder.from(Glide.with(requireContext()), artist)
|
ArtistGlideRequest.Builder.from(Glide.with(requireContext()), artist)
|
||||||
|
.forceDownload(PreferenceUtil.isAllowedToDownloadMetadata())
|
||||||
.generatePalette(requireContext())
|
.generatePalette(requireContext())
|
||||||
.build()
|
.build()
|
||||||
.dontAnimate()
|
.dontAnimate()
|
||||||
|
@ -226,14 +226,11 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadAlbumCover() {
|
private fun loadAlbumCover(album: Album) {
|
||||||
AlbumGlideRequest.Builder.from(Glide.with(requireContext()), album.safeGetFirstSong())
|
AlbumGlideRequest.Builder.from(Glide.with(requireContext()), album.safeGetFirstSong())
|
||||||
.checkIgnoreMediaStore(requireContext())
|
.checkIgnoreMediaStore()
|
||||||
.ignoreMediaStore(PreferenceUtil.isIgnoreMediaStoreArtwork)
|
|
||||||
.generatePalette(requireContext())
|
.generatePalette(requireContext())
|
||||||
.build()
|
.build()
|
||||||
.dontAnimate()
|
|
||||||
.dontTransform()
|
|
||||||
.into(object : SingleColorTarget(image) {
|
.into(object : SingleColorTarget(image) {
|
||||||
override fun onColorReady(color: Int) {
|
override fun onColorReady(color: Int) {
|
||||||
setColors(color)
|
setColors(color)
|
||||||
|
|
|
@ -16,6 +16,9 @@ package code.name.monkey.retromusic.fragments.home
|
||||||
|
|
||||||
import android.app.ActivityOptions
|
import android.app.ActivityOptions
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuInflater
|
||||||
|
import android.view.MenuItem.SHOW_AS_ACTION_IF_ROOM
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
|
@ -116,6 +119,14 @@ class HomeFragment :
|
||||||
).build().into(userImage)
|
).build().into(userImage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||||
|
super.onCreateOptionsMenu(menu, inflater)
|
||||||
|
menu.removeItem(R.id.action_grid_size)
|
||||||
|
menu.removeItem(R.id.action_layout_type)
|
||||||
|
menu.removeItem(R.id.action_sort_order)
|
||||||
|
menu.findItem(R.id.action_settings).setShowAsAction(SHOW_AS_ACTION_IF_ROOM)
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
const val TAG: String = "BannerHomeFragment"
|
const val TAG: String = "BannerHomeFragment"
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class AlbumGlideRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public Builder checkIgnoreMediaStore(@NonNull Context context) {
|
public Builder checkIgnoreMediaStore() {
|
||||||
return ignoreMediaStore(PreferenceUtil.INSTANCE.isIgnoreMediaStoreArtwork());
|
return ignoreMediaStore(PreferenceUtil.INSTANCE.isIgnoreMediaStoreArtwork());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue