code clean
This commit is contained in:
parent
6845f75ea0
commit
1b08b775ac
10 changed files with 37 additions and 48 deletions
|
@ -239,15 +239,17 @@ class HomeAdapter(
|
||||||
val clickableArea: ViewGroup = itemView.findViewById(R.id.clickable_area)
|
val clickableArea: ViewGroup = itemView.findViewById(R.id.clickable_area)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun artistsAdapter(artists: List<Artist>) =
|
private fun artistsAdapter(artists: List<Artist>) =
|
||||||
ArtistAdapter(activity, artists, PreferenceUtil.homeArtistGridStyle, null, this)
|
ArtistAdapter(activity, artists, PreferenceUtil.homeArtistGridStyle, null, this)
|
||||||
|
|
||||||
fun albumAdapter(albums: List<Album>) =
|
private fun albumAdapter(albums: List<Album>) =
|
||||||
AlbumAdapter(activity, albums, PreferenceUtil.homeAlbumGridStyle, null, this)
|
AlbumAdapter(activity, albums, PreferenceUtil.homeAlbumGridStyle, null, this)
|
||||||
|
|
||||||
fun gridLayoutManager() = GridLayoutManager(activity, 1, GridLayoutManager.HORIZONTAL, false)
|
private fun gridLayoutManager() =
|
||||||
|
GridLayoutManager(activity, 1, GridLayoutManager.HORIZONTAL, false)
|
||||||
|
|
||||||
fun linearLayoutManager() = LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL, false)
|
private fun linearLayoutManager() =
|
||||||
|
LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL, false)
|
||||||
|
|
||||||
override fun onArtist(artistId: Long, view: View) {
|
override fun onArtist(artistId: Long, view: View) {
|
||||||
activity.findNavController(R.id.fragment_container).navigate(
|
activity.findNavController(R.id.fragment_container).navigate(
|
||||||
|
|
|
@ -42,10 +42,10 @@ class SongFileAdapter(
|
||||||
private val activity: AppCompatActivity,
|
private val activity: AppCompatActivity,
|
||||||
private var dataSet: List<File>,
|
private var dataSet: List<File>,
|
||||||
private val itemLayoutRes: Int,
|
private val itemLayoutRes: Int,
|
||||||
private val ICallbacks: ICallbacks?,
|
private val iCallbacks: ICallbacks?,
|
||||||
ICabHolder: ICabHolder?
|
iCabHolder: ICabHolder?
|
||||||
) : AbsMultiSelectAdapter<SongFileAdapter.ViewHolder, File>(
|
) : AbsMultiSelectAdapter<SongFileAdapter.ViewHolder, File>(
|
||||||
activity, ICabHolder, R.menu.menu_media_selection
|
activity, iCabHolder, R.menu.menu_media_selection
|
||||||
), PopupTextProvider {
|
), PopupTextProvider {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
@ -135,8 +135,8 @@ class SongFileAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onMultipleItemAction(menuItem: MenuItem, selection: List<File>) {
|
override fun onMultipleItemAction(menuItem: MenuItem, selection: List<File>) {
|
||||||
if (ICallbacks == null) return
|
if (iCallbacks == null) return
|
||||||
ICallbacks.onMultipleItemAction(menuItem, selection as ArrayList<File>)
|
iCallbacks.onMultipleItemAction(menuItem, selection as ArrayList<File>)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getPopupText(position: Int): String {
|
override fun getPopupText(position: Int): String {
|
||||||
|
@ -150,11 +150,11 @@ class SongFileAdapter(
|
||||||
inner class ViewHolder(itemView: View) : MediaEntryViewHolder(itemView) {
|
inner class ViewHolder(itemView: View) : MediaEntryViewHolder(itemView) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (menu != null && ICallbacks != null) {
|
if (menu != null && iCallbacks != null) {
|
||||||
menu?.setOnClickListener { v ->
|
menu?.setOnClickListener { v ->
|
||||||
val position = layoutPosition
|
val position = layoutPosition
|
||||||
if (isPositionInRange(position)) {
|
if (isPositionInRange(position)) {
|
||||||
ICallbacks.onFileMenuClicked(dataSet[position], v)
|
iCallbacks.onFileMenuClicked(dataSet[position], v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ class SongFileAdapter(
|
||||||
if (isInQuickSelectMode) {
|
if (isInQuickSelectMode) {
|
||||||
toggleChecked(position)
|
toggleChecked(position)
|
||||||
} else {
|
} else {
|
||||||
ICallbacks?.onFileSelected(dataSet[position])
|
iCallbacks?.onFileSelected(dataSet[position])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ class ArtistAdapter(
|
||||||
loadArtistImage(artist, holder)
|
loadArtistImage(artist, holder)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setColors(processor: MediaNotificationProcessor, holder: ViewHolder) {
|
private fun setColors(processor: MediaNotificationProcessor, holder: ViewHolder) {
|
||||||
holder.mask?.backgroundTintList = ColorStateList.valueOf(processor.primaryTextColor)
|
holder.mask?.backgroundTintList = ColorStateList.valueOf(processor.primaryTextColor)
|
||||||
if (holder.paletteColorContainer != null) {
|
if (holder.paletteColorContainer != null) {
|
||||||
holder.paletteColorContainer?.setBackgroundColor(processor.backgroundColor)
|
holder.paletteColorContainer?.setBackgroundColor(processor.backgroundColor)
|
||||||
|
|
|
@ -24,13 +24,13 @@ import code.name.monkey.retromusic.dialogs.RemoveSongFromPlaylistDialog
|
||||||
import code.name.monkey.retromusic.interfaces.ICabHolder
|
import code.name.monkey.retromusic.interfaces.ICabHolder
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
|
|
||||||
open class PlaylistSongAdapter(
|
class PlaylistSongAdapter(
|
||||||
private val playlist: PlaylistEntity,
|
private val playlist: PlaylistEntity,
|
||||||
activity: FragmentActivity,
|
activity: FragmentActivity,
|
||||||
dataSet: MutableList<Song>,
|
dataSet: MutableList<Song>,
|
||||||
itemLayoutRes: Int,
|
itemLayoutRes: Int,
|
||||||
ICabHolder: ICabHolder?
|
iCabHolder: ICabHolder?
|
||||||
) : SongAdapter(activity, dataSet, itemLayoutRes, ICabHolder) {
|
) : SongAdapter(activity, dataSet, itemLayoutRes, iCabHolder) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
this.setMultiSelectMenuRes(R.menu.menu_cannot_delete_single_songs_playlist_songs_selection)
|
this.setMultiSelectMenuRes(R.menu.menu_cannot_delete_single_songs_playlist_songs_selection)
|
||||||
|
|
|
@ -16,6 +16,7 @@ package code.name.monkey.retromusic.dialogs
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import androidx.core.text.HtmlCompat
|
import androidx.core.text.HtmlCompat
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import code.name.monkey.retromusic.EXTRA_SONG
|
import code.name.monkey.retromusic.EXTRA_SONG
|
||||||
|
@ -40,11 +41,11 @@ class DeleteSongsDialog : DialogFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun create(songs: List<Song>): DeleteSongsDialog {
|
fun create(songs: List<Song>): DeleteSongsDialog {
|
||||||
val dialog = DeleteSongsDialog()
|
return DeleteSongsDialog().apply {
|
||||||
val args = Bundle()
|
arguments = bundleOf(
|
||||||
args.putParcelableArrayList(EXTRA_SONG, ArrayList(songs))
|
EXTRA_SONG to ArrayList(songs)
|
||||||
dialog.arguments = args
|
)
|
||||||
return dialog
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,6 @@ class SleepTimerDialog : DialogFragment() {
|
||||||
) {
|
) {
|
||||||
|
|
||||||
override fun onTick(millisUntilFinished: Long) {
|
override fun onTick(millisUntilFinished: Long) {
|
||||||
println("onTick: $millisUntilFinished")
|
|
||||||
seekBar.progress = millisUntilFinished.toInt()
|
seekBar.progress = millisUntilFinished.toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.annotation.NonNull
|
import androidx.annotation.NonNull
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import androidx.core.text.HtmlCompat
|
import androidx.core.text.HtmlCompat
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import code.name.monkey.retromusic.EXTRA_SONG
|
import code.name.monkey.retromusic.EXTRA_SONG
|
||||||
|
@ -155,11 +156,11 @@ class SongDetailDialog : DialogFragment() {
|
||||||
val TAG: String = SongDetailDialog::class.java.simpleName
|
val TAG: String = SongDetailDialog::class.java.simpleName
|
||||||
|
|
||||||
fun create(song: Song): SongDetailDialog {
|
fun create(song: Song): SongDetailDialog {
|
||||||
val dialog = SongDetailDialog()
|
return SongDetailDialog().apply {
|
||||||
val args = Bundle()
|
arguments = bundleOf(
|
||||||
args.putParcelable(EXTRA_SONG, song)
|
EXTRA_SONG to song
|
||||||
dialog.arguments = args
|
)
|
||||||
return dialog
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun makeTextWithTitle(context: Context, titleResId: Int, text: String?): Spanned {
|
private fun makeTextWithTitle(context: Context, titleResId: Int, text: String?): Spanned {
|
||||||
|
|
|
@ -17,6 +17,7 @@ package code.name.monkey.retromusic.dialogs
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import code.name.monkey.retromusic.EXTRA_SONG
|
import code.name.monkey.retromusic.EXTRA_SONG
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
|
@ -93,11 +94,11 @@ class SongShareDialog : DialogFragment() {
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
fun create(song: Song): SongShareDialog {
|
fun create(song: Song): SongShareDialog {
|
||||||
val dialog = SongShareDialog()
|
return SongShareDialog().apply {
|
||||||
val args = Bundle()
|
arguments = bundleOf(
|
||||||
args.putParcelable(EXTRA_SONG, song)
|
EXTRA_SONG to song
|
||||||
dialog.arguments = args
|
)
|
||||||
return dialog
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,14 +49,3 @@ fun Drawable.getBitmapDrawable(): Bitmap {
|
||||||
draw(canvas)
|
draw(canvas)
|
||||||
return bmp
|
return bmp
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAdaptiveIconDrawable(context: Context): Drawable {
|
|
||||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
||||||
AdaptiveIconDrawable(
|
|
||||||
ContextCompat.getDrawable(context, R.drawable.ic_launcher_background),
|
|
||||||
ContextCompat.getDrawable(context, R.drawable.ic_launcher_background)
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
ContextCompat.getDrawable(context, R.drawable.color_circle_gradient)!!
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -122,10 +122,6 @@ class VolumeFragment : Fragment(), SeekBar.OnSeekBarChangeListener, OnAudioVolum
|
||||||
volumeSeekBar.applyColor(color)
|
volumeSeekBar.applyColor(color)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun removeThumb() {
|
|
||||||
volumeSeekBar.thumb = null
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setPauseWhenZeroVolume(pauseWhenZeroVolume: Boolean) {
|
private fun setPauseWhenZeroVolume(pauseWhenZeroVolume: Boolean) {
|
||||||
if (PreferenceUtil.isPauseOnZeroVolume)
|
if (PreferenceUtil.isPauseOnZeroVolume)
|
||||||
if (MusicPlayerRemote.isPlaying && pauseWhenZeroVolume)
|
if (MusicPlayerRemote.isPlaying && pauseWhenZeroVolume)
|
||||||
|
|
Loading…
Reference in a new issue