Code Cleanup
This commit is contained in:
parent
2bffff1eaa
commit
5c1a88b32b
17 changed files with 46 additions and 43 deletions
|
@ -351,10 +351,10 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateColor() {
|
private fun updateColor() {
|
||||||
libraryViewModel.paletteColor.observe(this, { color ->
|
libraryViewModel.paletteColor.observe(this) { color ->
|
||||||
this.paletteColor = color
|
this.paletteColor = color
|
||||||
onPaletteColorChanged()
|
onPaletteColorChanged()
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setBottomNavVisibility(visible: Boolean, animate: Boolean = false, hideBottomSheet: Boolean = MusicPlayerRemote.playingQueue.isEmpty()) {
|
fun setBottomNavVisibility(visible: Boolean, animate: Boolean = false, hideBottomSheet: Boolean = MusicPlayerRemote.playingQueue.isEmpty()) {
|
||||||
|
|
|
@ -122,9 +122,9 @@ class AboutFragment : Fragment(R.layout.fragment_about), View.OnClickListener {
|
||||||
itemAnimator = DefaultItemAnimator()
|
itemAnimator = DefaultItemAnimator()
|
||||||
adapter = contributorAdapter
|
adapter = contributorAdapter
|
||||||
}
|
}
|
||||||
libraryViewModel.fetchContributors().observe(viewLifecycleOwner, { contributors ->
|
libraryViewModel.fetchContributors().observe(viewLifecycleOwner) { contributors ->
|
||||||
contributorAdapter.swapData(contributors)
|
contributorAdapter.swapData(contributors)
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
|
|
|
@ -122,7 +122,7 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
||||||
binding.toolbar.title = " "
|
binding.toolbar.title = " "
|
||||||
ViewCompat.setTransitionName(binding.albumCoverContainer, arguments.extraAlbumId.toString())
|
ViewCompat.setTransitionName(binding.albumCoverContainer, arguments.extraAlbumId.toString())
|
||||||
postponeEnterTransition()
|
postponeEnterTransition()
|
||||||
detailsViewModel.getAlbum().observe(viewLifecycleOwner, {
|
detailsViewModel.getAlbum().observe(viewLifecycleOwner) {
|
||||||
requireView().doOnPreDraw {
|
requireView().doOnPreDraw {
|
||||||
startPostponedEnterTransition()
|
startPostponedEnterTransition()
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
||||||
} else {
|
} else {
|
||||||
ViewCompat.setTransitionName(binding.artistImage, album.artistId.toString())
|
ViewCompat.setTransitionName(binding.artistImage, album.artistId.toString())
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
setupRecyclerView()
|
setupRecyclerView()
|
||||||
binding.artistImage.setOnClickListener { artistView ->
|
binding.artistImage.setOnClickListener { artistView ->
|
||||||
|
@ -236,17 +236,17 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
||||||
simpleSongAdapter.swapDataSet(album.songs)
|
simpleSongAdapter.swapDataSet(album.songs)
|
||||||
if (albumArtistExists) {
|
if (albumArtistExists) {
|
||||||
detailsViewModel.getAlbumArtist(album.albumArtist.toString())
|
detailsViewModel.getAlbumArtist(album.albumArtist.toString())
|
||||||
.observe(viewLifecycleOwner, {
|
.observe(viewLifecycleOwner) {
|
||||||
loadArtistImage(it)
|
loadArtistImage(it)
|
||||||
})
|
}
|
||||||
} else {
|
} else {
|
||||||
detailsViewModel.getArtist(album.artistId).observe(viewLifecycleOwner, {
|
detailsViewModel.getArtist(album.artistId).observe(viewLifecycleOwner) {
|
||||||
loadArtistImage(it)
|
loadArtistImage(it)
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
detailsViewModel.getAlbumInfo(album).observe(viewLifecycleOwner, { result ->
|
detailsViewModel.getAlbumInfo(album).observe(viewLifecycleOwner) { result ->
|
||||||
when (result) {
|
when (result) {
|
||||||
is Result.Loading -> {
|
is Result.Loading -> {
|
||||||
println("Loading")
|
println("Loading")
|
||||||
|
@ -258,7 +258,7 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
||||||
aboutAlbum(result.data)
|
aboutAlbum(result.data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun moreAlbums(albums: List<Album>) {
|
private fun moreAlbums(albums: List<Album>) {
|
||||||
|
@ -305,9 +305,9 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadArtistImage(artist: Artist) {
|
private fun loadArtistImage(artist: Artist) {
|
||||||
detailsViewModel.getMoreAlbums(artist).observe(viewLifecycleOwner, {
|
detailsViewModel.getMoreAlbums(artist).observe(viewLifecycleOwner) {
|
||||||
moreAlbums(it)
|
moreAlbums(it)
|
||||||
})
|
}
|
||||||
GlideApp.with(requireContext()).asBitmapPalette().artistImageOptions(artist)
|
GlideApp.with(requireContext()).asBitmapPalette().artistImageOptions(artist)
|
||||||
//.forceDownload(PreferenceUtil.isAllowedToDownloadMetadata())
|
//.forceDownload(PreferenceUtil.isAllowedToDownloadMetadata())
|
||||||
.load(
|
.load(
|
||||||
|
|
|
@ -48,12 +48,12 @@ class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridL
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
libraryViewModel.getAlbums().observe(viewLifecycleOwner, {
|
libraryViewModel.getAlbums().observe(viewLifecycleOwner) {
|
||||||
if (it.isNotEmpty())
|
if (it.isNotEmpty())
|
||||||
adapter?.swapDataSet(it)
|
adapter?.swapDataSet(it)
|
||||||
else
|
else
|
||||||
adapter?.swapDataSet(listOf())
|
adapter?.swapDataSet(listOf())
|
||||||
})
|
}
|
||||||
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner) {
|
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner) {
|
||||||
if (!handleBackPress()) {
|
if (!handleBackPress()) {
|
||||||
remove()
|
remove()
|
||||||
|
|
|
@ -92,12 +92,12 @@ abstract class AbsArtistDetailsFragment : AbsMainActivityFragment(R.layout.fragm
|
||||||
(artistId ?: artistName).toString()
|
(artistId ?: artistName).toString()
|
||||||
)
|
)
|
||||||
postponeEnterTransition()
|
postponeEnterTransition()
|
||||||
detailsViewModel.getArtist().observe(viewLifecycleOwner, {
|
detailsViewModel.getArtist().observe(viewLifecycleOwner) {
|
||||||
requireView().doOnPreDraw {
|
requireView().doOnPreDraw {
|
||||||
startPostponedEnterTransition()
|
startPostponedEnterTransition()
|
||||||
}
|
}
|
||||||
showArtist(it)
|
showArtist(it)
|
||||||
})
|
}
|
||||||
setupRecyclerView()
|
setupRecyclerView()
|
||||||
|
|
||||||
binding.fragmentArtistContent.playAction.apply {
|
binding.fragmentArtistContent.playAction.apply {
|
||||||
|
@ -180,13 +180,13 @@ abstract class AbsArtistDetailsFragment : AbsMainActivityFragment(R.layout.fragm
|
||||||
biography = null
|
biography = null
|
||||||
this.lang = lang
|
this.lang = lang
|
||||||
detailsViewModel.getArtistInfo(name, lang, null)
|
detailsViewModel.getArtistInfo(name, lang, null)
|
||||||
.observe(viewLifecycleOwner, { result ->
|
.observe(viewLifecycleOwner) { result ->
|
||||||
when (result) {
|
when (result) {
|
||||||
is Result.Loading -> println("Loading")
|
is Result.Loading -> println("Loading")
|
||||||
is Result.Error -> println("Error")
|
is Result.Error -> println("Error")
|
||||||
is Result.Success -> artistInfo(result.data)
|
is Result.Success -> artistInfo(result.data)
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun artistInfo(lastFmArtist: LastFmArtist?) {
|
private fun artistInfo(lastFmArtist: LastFmArtist?) {
|
||||||
|
|
|
@ -49,12 +49,12 @@ class ArtistsFragment : AbsRecyclerViewCustomGridSizeFragment<ArtistAdapter, Gri
|
||||||
IArtistClickListener, IAlbumArtistClickListener, ICabHolder {
|
IArtistClickListener, IAlbumArtistClickListener, ICabHolder {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
libraryViewModel.getArtists().observe(viewLifecycleOwner, {
|
libraryViewModel.getArtists().observe(viewLifecycleOwner) {
|
||||||
if (it.isNotEmpty())
|
if (it.isNotEmpty())
|
||||||
adapter?.swapDataSet(it)
|
adapter?.swapDataSet(it)
|
||||||
else
|
else
|
||||||
adapter?.swapDataSet(listOf())
|
adapter?.swapDataSet(listOf())
|
||||||
})
|
}
|
||||||
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner) {
|
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner) {
|
||||||
if (!handleBackPress()) {
|
if (!handleBackPress()) {
|
||||||
remove()
|
remove()
|
||||||
|
|
|
@ -41,7 +41,7 @@ class BackupFragment : Fragment(R.layout.fragment_backup), BackupAdapter.BackupC
|
||||||
_binding = FragmentBackupBinding.bind(view)
|
_binding = FragmentBackupBinding.bind(view)
|
||||||
initAdapter()
|
initAdapter()
|
||||||
setupRecyclerview()
|
setupRecyclerview()
|
||||||
backupViewModel.backupsLiveData.observe(this) {
|
backupViewModel.backupsLiveData.observe(viewLifecycleOwner) {
|
||||||
if (it.isNotEmpty())
|
if (it.isNotEmpty())
|
||||||
backupAdapter?.swapDataset(it)
|
backupAdapter?.swapDataset(it)
|
||||||
else
|
else
|
||||||
|
|
|
@ -86,11 +86,11 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
|
||||||
} else {
|
} else {
|
||||||
binding.shuffleButton.isVisible = false
|
binding.shuffleButton.isVisible = false
|
||||||
}
|
}
|
||||||
libraryViewModel.getFabMargin().observe(viewLifecycleOwner, {
|
libraryViewModel.getFabMargin().observe(viewLifecycleOwner) {
|
||||||
binding.shuffleButton.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
binding.shuffleButton.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
bottomMargin = it
|
bottomMargin = it
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun onShuffleClicked() {
|
open fun onShuffleClicked() {
|
||||||
|
|
|
@ -62,9 +62,9 @@ class GenreDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playlist_
|
||||||
genre = arguments.extraGenre
|
genre = arguments.extraGenre
|
||||||
binding.toolbar.title = arguments.extraGenre.name
|
binding.toolbar.title = arguments.extraGenre.name
|
||||||
setupRecyclerView()
|
setupRecyclerView()
|
||||||
detailsViewModel.getSongs().observe(viewLifecycleOwner, {
|
detailsViewModel.getSongs().observe(viewLifecycleOwner) {
|
||||||
songs(it)
|
songs(it)
|
||||||
})
|
}
|
||||||
postponeEnterTransition()
|
postponeEnterTransition()
|
||||||
view.doOnPreDraw {
|
view.doOnPreDraw {
|
||||||
startPostponedEnterTransition()
|
startPostponedEnterTransition()
|
||||||
|
|
|
@ -40,12 +40,12 @@ GenresFragment : AbsRecyclerViewFragment<GenreAdapter, LinearLayoutManager>(),
|
||||||
IGenreClickListener {
|
IGenreClickListener {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
libraryViewModel.getGenre().observe(viewLifecycleOwner, {
|
libraryViewModel.getGenre().observe(viewLifecycleOwner) {
|
||||||
if (it.isNotEmpty())
|
if (it.isNotEmpty())
|
||||||
adapter?.swapDataSet(it)
|
adapter?.swapDataSet(it)
|
||||||
else
|
else
|
||||||
adapter?.swapDataSet(listOf())
|
adapter?.swapDataSet(listOf())
|
||||||
})
|
}
|
||||||
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner) {
|
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner) {
|
||||||
remove()
|
remove()
|
||||||
requireActivity().onBackPressed()
|
requireActivity().onBackPressed()
|
||||||
|
|
|
@ -77,12 +77,12 @@ class HomeFragment :
|
||||||
layoutManager = LinearLayoutManager(mainActivity)
|
layoutManager = LinearLayoutManager(mainActivity)
|
||||||
adapter = homeAdapter
|
adapter = homeAdapter
|
||||||
}
|
}
|
||||||
libraryViewModel.getHome().observe(viewLifecycleOwner, {
|
libraryViewModel.getHome().observe(viewLifecycleOwner) {
|
||||||
homeAdapter.swapData(it)
|
homeAdapter.swapData(it)
|
||||||
})
|
}
|
||||||
libraryViewModel.getSuggestions().observe(viewLifecycleOwner, {
|
libraryViewModel.getSuggestions().observe(viewLifecycleOwner) {
|
||||||
loadSuggestions(it)
|
loadSuggestions(it)
|
||||||
})
|
}
|
||||||
|
|
||||||
loadProfile()
|
loadProfile()
|
||||||
setupTitle()
|
setupTitle()
|
||||||
|
|
|
@ -114,11 +114,11 @@ class UserInfoFragment : Fragment() {
|
||||||
view.doOnPreDraw {
|
view.doOnPreDraw {
|
||||||
startPostponedEnterTransition()
|
startPostponedEnterTransition()
|
||||||
}
|
}
|
||||||
libraryViewModel.getFabMargin().observe(viewLifecycleOwner, {
|
libraryViewModel.getFabMargin().observe(viewLifecycleOwner) {
|
||||||
binding.next.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
binding.next.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
bottomMargin = it
|
bottomMargin = it
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadProfile() {
|
private fun loadProfile() {
|
||||||
|
|
|
@ -132,7 +132,7 @@ class FullPlayerFragment : AbsPlayerFragment(R.layout.fragment_full) {
|
||||||
|
|
||||||
private fun updateArtistImage() {
|
private fun updateArtistImage() {
|
||||||
libraryViewModel.artist(MusicPlayerRemote.currentSong.artistId)
|
libraryViewModel.artist(MusicPlayerRemote.currentSong.artistId)
|
||||||
.observe(viewLifecycleOwner, { artist ->
|
.observe(viewLifecycleOwner) { artist ->
|
||||||
if (artist.id != -1L) {
|
if (artist.id != -1L) {
|
||||||
GlideApp.with(requireActivity()).asBitmapPalette().artistImageOptions(artist)
|
GlideApp.with(requireActivity()).asBitmapPalette().artistImageOptions(artist)
|
||||||
.load(RetroGlideExtension.getArtistModel(artist))
|
.load(RetroGlideExtension.getArtistModel(artist))
|
||||||
|
@ -142,7 +142,7 @@ class FullPlayerFragment : AbsPlayerFragment(R.layout.fragment_full) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onQueueChanged() {
|
override fun onQueueChanged() {
|
||||||
|
|
|
@ -88,9 +88,9 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWa
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
query = savedInstanceState.getString(QUERY)
|
query = savedInstanceState.getString(QUERY)
|
||||||
}
|
}
|
||||||
libraryViewModel.getSearchResult().observe(viewLifecycleOwner, {
|
libraryViewModel.getSearchResult().observe(viewLifecycleOwner) {
|
||||||
showData(it)
|
showData(it)
|
||||||
})
|
}
|
||||||
setupChips()
|
setupChips()
|
||||||
postponeEnterTransition()
|
postponeEnterTransition()
|
||||||
view.doOnPreDraw {
|
view.doOnPreDraw {
|
||||||
|
|
|
@ -42,12 +42,12 @@ class SongsFragment : AbsRecyclerViewCustomGridSizeFragment<SongAdapter, GridLay
|
||||||
ICabHolder {
|
ICabHolder {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
libraryViewModel.getSongs().observe(viewLifecycleOwner, {
|
libraryViewModel.getSongs().observe(viewLifecycleOwner) {
|
||||||
if (it.isNotEmpty())
|
if (it.isNotEmpty())
|
||||||
adapter?.swapDataSet(it)
|
adapter?.swapDataSet(it)
|
||||||
else
|
else
|
||||||
adapter?.swapDataSet(listOf())
|
adapter?.swapDataSet(listOf())
|
||||||
})
|
}
|
||||||
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner) {
|
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner) {
|
||||||
if (!handleBackPress()) {
|
if (!handleBackPress()) {
|
||||||
remove()
|
remove()
|
||||||
|
|
|
@ -30,6 +30,7 @@ import androidx.annotation.ColorInt;
|
||||||
import androidx.annotation.DrawableRes;
|
import androidx.annotation.DrawableRes;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
@ -100,7 +101,7 @@ public class ImageUtil {
|
||||||
|
|
||||||
public static Drawable getVectorDrawable(
|
public static Drawable getVectorDrawable(
|
||||||
@NonNull Resources res, @DrawableRes int resId, @Nullable Resources.Theme theme) {
|
@NonNull Resources res, @DrawableRes int resId, @Nullable Resources.Theme theme) {
|
||||||
return res.getDrawable(resId, theme);
|
return ResourcesCompat.getDrawable(res,resId, theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Makes sure that {@code mTempBuffer} has at least length {@code size}. */
|
/** Makes sure that {@code mTempBuffer} has at least length {@code size}. */
|
||||||
|
|
|
@ -25,6 +25,8 @@ import android.util.Log;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R;
|
import code.name.monkey.retromusic.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -222,7 +224,7 @@ public class SeekArc extends View {
|
||||||
* provides notifications of when the user starts and stops a touch gesture within the SeekArc.
|
* provides notifications of when the user starts and stops a touch gesture within the SeekArc.
|
||||||
*
|
*
|
||||||
* @param l The seek bar notification listener
|
* @param l The seek bar notification listener
|
||||||
* @see SeekArc.OnSeekBarChangeListener
|
* @see SeekArc.OnSeekArcChangeListener
|
||||||
*/
|
*/
|
||||||
public void setOnSeekArcChangeListener(OnSeekArcChangeListener l) {
|
public void setOnSeekArcChangeListener(OnSeekArcChangeListener l) {
|
||||||
mOnSeekArcChangeListener = l;
|
mOnSeekArcChangeListener = l;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue