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)
|
||||
}
|
||||
|
||||
fun artistsAdapter(artists: List<Artist>) =
|
||||
private fun artistsAdapter(artists: List<Artist>) =
|
||||
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)
|
||||
|
||||
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) {
|
||||
activity.findNavController(R.id.fragment_container).navigate(
|
||||
|
|
|
@ -42,10 +42,10 @@ class SongFileAdapter(
|
|||
private val activity: AppCompatActivity,
|
||||
private var dataSet: List<File>,
|
||||
private val itemLayoutRes: Int,
|
||||
private val ICallbacks: ICallbacks?,
|
||||
ICabHolder: ICabHolder?
|
||||
private val iCallbacks: ICallbacks?,
|
||||
iCabHolder: ICabHolder?
|
||||
) : AbsMultiSelectAdapter<SongFileAdapter.ViewHolder, File>(
|
||||
activity, ICabHolder, R.menu.menu_media_selection
|
||||
activity, iCabHolder, R.menu.menu_media_selection
|
||||
), PopupTextProvider {
|
||||
|
||||
init {
|
||||
|
@ -135,8 +135,8 @@ class SongFileAdapter(
|
|||
}
|
||||
|
||||
override fun onMultipleItemAction(menuItem: MenuItem, selection: List<File>) {
|
||||
if (ICallbacks == null) return
|
||||
ICallbacks.onMultipleItemAction(menuItem, selection as ArrayList<File>)
|
||||
if (iCallbacks == null) return
|
||||
iCallbacks.onMultipleItemAction(menuItem, selection as ArrayList<File>)
|
||||
}
|
||||
|
||||
override fun getPopupText(position: Int): String {
|
||||
|
@ -150,11 +150,11 @@ class SongFileAdapter(
|
|||
inner class ViewHolder(itemView: View) : MediaEntryViewHolder(itemView) {
|
||||
|
||||
init {
|
||||
if (menu != null && ICallbacks != null) {
|
||||
if (menu != null && iCallbacks != null) {
|
||||
menu?.setOnClickListener { v ->
|
||||
val position = layoutPosition
|
||||
if (isPositionInRange(position)) {
|
||||
ICallbacks.onFileMenuClicked(dataSet[position], v)
|
||||
iCallbacks.onFileMenuClicked(dataSet[position], v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ class SongFileAdapter(
|
|||
if (isInQuickSelectMode) {
|
||||
toggleChecked(position)
|
||||
} else {
|
||||
ICallbacks?.onFileSelected(dataSet[position])
|
||||
iCallbacks?.onFileSelected(dataSet[position])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ class ArtistAdapter(
|
|||
loadArtistImage(artist, holder)
|
||||
}
|
||||
|
||||
fun setColors(processor: MediaNotificationProcessor, holder: ViewHolder) {
|
||||
private fun setColors(processor: MediaNotificationProcessor, holder: ViewHolder) {
|
||||
holder.mask?.backgroundTintList = ColorStateList.valueOf(processor.primaryTextColor)
|
||||
if (holder.paletteColorContainer != null) {
|
||||
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.model.Song
|
||||
|
||||
open class PlaylistSongAdapter(
|
||||
class PlaylistSongAdapter(
|
||||
private val playlist: PlaylistEntity,
|
||||
activity: FragmentActivity,
|
||||
dataSet: MutableList<Song>,
|
||||
itemLayoutRes: Int,
|
||||
ICabHolder: ICabHolder?
|
||||
) : SongAdapter(activity, dataSet, itemLayoutRes, ICabHolder) {
|
||||
iCabHolder: ICabHolder?
|
||||
) : SongAdapter(activity, dataSet, itemLayoutRes, iCabHolder) {
|
||||
|
||||
init {
|
||||
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.os.Bundle
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import code.name.monkey.retromusic.EXTRA_SONG
|
||||
|
@ -40,11 +41,11 @@ class DeleteSongsDialog : DialogFragment() {
|
|||
}
|
||||
|
||||
fun create(songs: List<Song>): DeleteSongsDialog {
|
||||
val dialog = DeleteSongsDialog()
|
||||
val args = Bundle()
|
||||
args.putParcelableArrayList(EXTRA_SONG, ArrayList(songs))
|
||||
dialog.arguments = args
|
||||
return dialog
|
||||
return DeleteSongsDialog().apply {
|
||||
arguments = bundleOf(
|
||||
EXTRA_SONG to ArrayList(songs)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -164,7 +164,6 @@ class SleepTimerDialog : DialogFragment() {
|
|||
) {
|
||||
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
println("onTick: $millisUntilFinished")
|
||||
seekBar.progress = millisUntilFinished.toInt()
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import android.util.Log
|
|||
import android.view.LayoutInflater
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.NonNull
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import code.name.monkey.retromusic.EXTRA_SONG
|
||||
|
@ -155,11 +156,11 @@ class SongDetailDialog : DialogFragment() {
|
|||
val TAG: String = SongDetailDialog::class.java.simpleName
|
||||
|
||||
fun create(song: Song): SongDetailDialog {
|
||||
val dialog = SongDetailDialog()
|
||||
val args = Bundle()
|
||||
args.putParcelable(EXTRA_SONG, song)
|
||||
dialog.arguments = args
|
||||
return dialog
|
||||
return SongDetailDialog().apply {
|
||||
arguments = bundleOf(
|
||||
EXTRA_SONG to song
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
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.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import code.name.monkey.retromusic.EXTRA_SONG
|
||||
import code.name.monkey.retromusic.R
|
||||
|
@ -93,11 +94,11 @@ class SongShareDialog : DialogFragment() {
|
|||
companion object {
|
||||
|
||||
fun create(song: Song): SongShareDialog {
|
||||
val dialog = SongShareDialog()
|
||||
val args = Bundle()
|
||||
args.putParcelable(EXTRA_SONG, song)
|
||||
dialog.arguments = args
|
||||
return dialog
|
||||
return SongShareDialog().apply {
|
||||
arguments = bundleOf(
|
||||
EXTRA_SONG to song
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,15 +48,4 @@ fun Drawable.getBitmapDrawable(): Bitmap {
|
|||
val canvas = Canvas(bmp)
|
||||
draw(canvas)
|
||||
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)
|
||||
}
|
||||
|
||||
fun removeThumb() {
|
||||
volumeSeekBar.thumb = null
|
||||
}
|
||||
|
||||
private fun setPauseWhenZeroVolume(pauseWhenZeroVolume: Boolean) {
|
||||
if (PreferenceUtil.isPauseOnZeroVolume)
|
||||
if (MusicPlayerRemote.isPlaying && pauseWhenZeroVolume)
|
||||
|
|
Loading…
Reference in a new issue