Fix code
This commit is contained in:
parent
3f3e26ea45
commit
e31a1a6e2f
7 changed files with 40 additions and 144 deletions
|
@ -55,12 +55,8 @@ class SongFileAdapter(
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, index: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, index: Int) {
|
||||||
val file = dataSet!![index]
|
val file = dataSet!![index]
|
||||||
|
|
||||||
holder.itemView.isActivated = isChecked(file)
|
holder.itemView.isActivated = isChecked(file)
|
||||||
|
holder.title?.text = getFileTitle(file)
|
||||||
if (holder.title != null) {
|
|
||||||
holder.title!!.text = getFileTitle(file)
|
|
||||||
}
|
|
||||||
if (holder.text != null) {
|
if (holder.text != null) {
|
||||||
if (holder.itemViewType == FILE) {
|
if (holder.itemViewType == FILE) {
|
||||||
holder.text!!.text = getFileText(file)
|
holder.text!!.text = getFileText(file)
|
||||||
|
|
|
@ -80,19 +80,11 @@ open class AlbumAdapter(protected val activity: AppCompatActivity,
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
val album = dataSet[position]
|
val album = dataSet[position]
|
||||||
|
|
||||||
val isChecked = isChecked(album)
|
val isChecked = isChecked(album)
|
||||||
holder.itemView.isActivated = isChecked
|
holder.itemView.isActivated = isChecked
|
||||||
|
holder.title?.text = getAlbumTitle(album)
|
||||||
if (holder.title != null) {
|
holder.text?.text = getAlbumText(album)
|
||||||
holder.title!!.text = getAlbumTitle(album)
|
holder.playSongs?.setOnClickListener { album.songs?.let { songs -> MusicPlayerRemote.openQueue(songs, 0, true) } }
|
||||||
}
|
|
||||||
if (holder.text != null) {
|
|
||||||
holder.text!!.text = getAlbumText(album)
|
|
||||||
}
|
|
||||||
if (holder.playSongs != null) {
|
|
||||||
holder.playSongs!!.setOnClickListener { MusicPlayerRemote.openQueue(album.songs!!, 0, true) }
|
|
||||||
}
|
|
||||||
loadAlbumCover(album, holder)
|
loadAlbumCover(album, holder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,18 +40,10 @@ class AlbumFullWidthAdapter(private val activity: Activity, private val dataSet:
|
||||||
override fun onBindViewHolder(holder: FullMetalViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: FullMetalViewHolder, position: Int) {
|
||||||
// don't forget about calling supper.onBindViewHolder!
|
// don't forget about calling supper.onBindViewHolder!
|
||||||
super.onBindViewHolder(holder, position)
|
super.onBindViewHolder(holder, position)
|
||||||
|
|
||||||
val album = dataSet[position]
|
val album = dataSet[position]
|
||||||
|
holder.title?.text = getAlbumTitle(album)
|
||||||
if (holder.title != null) {
|
holder.text?.text = getAlbumText(album)
|
||||||
holder.title!!.text = getAlbumTitle(album)
|
holder.playSongs?.setOnClickListener { album.songs?.let { songs -> MusicPlayerRemote.openQueue(songs, 0, true) } }
|
||||||
}
|
|
||||||
if (holder.text != null) {
|
|
||||||
holder.text!!.text = getAlbumText(album)
|
|
||||||
}
|
|
||||||
if (holder.playSongs != null) {
|
|
||||||
holder.playSongs!!.setOnClickListener { MusicPlayerRemote.openQueue(album.songs!!, 0, true) }
|
|
||||||
}
|
|
||||||
loadAlbumCover(album, holder)
|
loadAlbumCover(album, holder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
package code.name.monkey.retromusic.adapter.playlist
|
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.app.Dialog
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
|
|
||||||
import java.util.ArrayList
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
|
||||||
import code.name.monkey.retromusic.model.Playlist
|
|
||||||
import code.name.monkey.retromusic.model.Song
|
|
||||||
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
|
|
||||||
import code.name.monkey.retromusic.adapter.playlist.AddToPlaylist.ViewHolder
|
|
||||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
|
||||||
|
|
||||||
class AddToPlaylist(private val activity: Activity,
|
|
||||||
private val playlists: ArrayList<Playlist>, private val itemLayoutRes: Int,
|
|
||||||
private val songs: ArrayList<Song>, private val dialog: Dialog) : RecyclerView.Adapter<ViewHolder>() {
|
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
|
||||||
return ViewHolder(LayoutInflater.from(activity).inflate(itemLayoutRes, parent, false))
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
|
||||||
val playlist = playlists[position]
|
|
||||||
if (holder.title != null) {
|
|
||||||
holder.title!!.text = playlist.name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
|
||||||
return playlists.size
|
|
||||||
}
|
|
||||||
|
|
||||||
inner class ViewHolder(itemView: View) : MediaEntryViewHolder(itemView) {
|
|
||||||
|
|
||||||
override fun onClick(v: View?) {
|
|
||||||
super.onClick(v)
|
|
||||||
PlaylistsUtil.addToPlaylist(activity, songs, playlists[adapterPosition].id, true)
|
|
||||||
dialog.dismiss()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,7 +5,6 @@ import android.view.LayoutInflater
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.annotation.LayoutRes
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.widget.PopupMenu
|
import androidx.appcompat.widget.PopupMenu
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
import code.name.monkey.appthemehelper.ThemeStore
|
||||||
|
@ -30,15 +29,15 @@ import code.name.monkey.retromusic.util.NavigationUtil
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
class PlaylistAdapter(protected val activity: AppCompatActivity, dataSet: ArrayList<Playlist>,
|
class PlaylistAdapter(private val activity: AppCompatActivity,
|
||||||
@param:LayoutRes protected var itemLayoutRes: Int, cabHolder: CabHolder?) : AbsMultiSelectAdapter<PlaylistAdapter.ViewHolder, Playlist>(activity, cabHolder, R.menu.menu_playlists_selection) {
|
var dataSet: ArrayList<Playlist>,
|
||||||
var dataSet: ArrayList<Playlist>
|
private var itemLayoutRes: Int,
|
||||||
protected set
|
cabHolder: CabHolder?) : AbsMultiSelectAdapter<PlaylistAdapter.ViewHolder, Playlist>(activity, cabHolder, R.menu.menu_playlists_selection) {
|
||||||
|
|
||||||
var songs = ArrayList<Song>()
|
var songs = ArrayList<Song>()
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
this.dataSet = dataSet
|
|
||||||
setHasStableIds(true)
|
setHasStableIds(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,20 +69,11 @@ class PlaylistAdapter(protected val activity: AppCompatActivity, dataSet: ArrayL
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
|
|
||||||
val playlist = dataSet[position]
|
val playlist = dataSet[position]
|
||||||
val songs = getSongs(playlist)
|
|
||||||
holder.itemView.isActivated = isChecked(playlist)
|
holder.itemView.isActivated = isChecked(playlist)
|
||||||
|
holder.title?.text = getPlaylistTitle(playlist)
|
||||||
if (holder.title != null) {
|
holder.text?.text = getPlaylistText(playlist)
|
||||||
holder.title!!.text = getPlaylistTitle(playlist)
|
holder.image?.setImageDrawable(getIconRes(playlist))
|
||||||
}
|
|
||||||
if (holder.text != null) {
|
|
||||||
holder.text!!.text = getPlaylistText(playlist)
|
|
||||||
}
|
|
||||||
if (holder.image != null) {
|
|
||||||
holder.image!!.setImageDrawable(getIconRes(playlist))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getIconRes(playlist: Playlist): Drawable {
|
private fun getIconRes(playlist: Playlist): Drawable {
|
||||||
|
|
|
@ -100,9 +100,9 @@ class OrderablePlaylistSongAdapter(activity: AppCompatActivity,
|
||||||
init {
|
init {
|
||||||
if (dragView != null) {
|
if (dragView != null) {
|
||||||
if (onMoveItemListener != null) {
|
if (onMoveItemListener != null) {
|
||||||
dragView!!.visibility = View.VISIBLE
|
dragView?.visibility = View.VISIBLE
|
||||||
} else {
|
} else {
|
||||||
dragView!!.visibility = View.GONE
|
dragView?.visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ import android.graphics.PorterDuff
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import androidx.annotation.ColorInt
|
|
||||||
import androidx.annotation.LayoutRes
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
|
@ -20,36 +18,27 @@ import com.h6ah4i.android.widget.advrecyclerview.draggable.annotation.DraggableI
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
class PlayingQueueAdapter : SongAdapter, DraggableItemAdapter<PlayingQueueAdapter.ViewHolder> {
|
class PlayingQueueAdapter(activity: AppCompatActivity,
|
||||||
|
dataSet: ArrayList<Song>,
|
||||||
|
private var current: Int,
|
||||||
|
itemLayoutRes: Int) : SongAdapter(
|
||||||
|
activity,
|
||||||
|
dataSet,
|
||||||
|
itemLayoutRes,
|
||||||
|
false,
|
||||||
|
null
|
||||||
|
), DraggableItemAdapter<PlayingQueueAdapter.ViewHolder> {
|
||||||
|
|
||||||
private var current: Int = 0
|
|
||||||
private var color = -1
|
private var color = -1
|
||||||
|
|
||||||
constructor(activity: AppCompatActivity, dataSet: ArrayList<Song>, current: Int,
|
|
||||||
@LayoutRes itemLayoutRes: Int) : super(activity, dataSet, itemLayoutRes, false, null) {
|
|
||||||
this.current = current
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(activity: AppCompatActivity,
|
|
||||||
dataSet: ArrayList<Song>, current: Int,
|
|
||||||
@LayoutRes itemLayoutRes: Int,
|
|
||||||
@ColorInt color: Int) : super(activity, dataSet, itemLayoutRes, false, null) {
|
|
||||||
this.current = current
|
|
||||||
this.color = color
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun createViewHolder(view: View): SongAdapter.ViewHolder {
|
override fun createViewHolder(view: View): SongAdapter.ViewHolder {
|
||||||
return ViewHolder(view)
|
return ViewHolder(view)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: SongAdapter.ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: SongAdapter.ViewHolder, position: Int) {
|
||||||
super.onBindViewHolder(holder, position)
|
super.onBindViewHolder(holder, position)
|
||||||
if (holder.imageText != null) {
|
holder.imageText?.text = (position - current).toString()
|
||||||
holder.imageText!!.text = (position - current).toString()
|
holder.time?.text = MusicUtil.getReadableDurationString(dataSet[position].duration)
|
||||||
}
|
|
||||||
if (holder.time != null) {
|
|
||||||
holder.time!!.text = MusicUtil.getReadableDurationString(dataSet[position].duration)
|
|
||||||
}
|
|
||||||
if (holder.itemViewType == HISTORY || holder.itemViewType == CURRENT) {
|
if (holder.itemViewType == HISTORY || holder.itemViewType == CURRENT) {
|
||||||
setAlpha(holder, 0.5f)
|
setAlpha(holder, 0.5f)
|
||||||
}
|
}
|
||||||
|
@ -66,15 +55,10 @@ class PlayingQueueAdapter : SongAdapter, DraggableItemAdapter<PlayingQueueAdapte
|
||||||
holder.title!!.setTextColor(color)
|
holder.title!!.setTextColor(color)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (holder.text != null) {
|
|
||||||
holder.text!!.setTextColor(white)
|
holder.text?.setTextColor(white)
|
||||||
}
|
holder.time?.setTextColor(white)
|
||||||
if (holder.time != null) {
|
holder.imageText?.setTextColor(white)
|
||||||
holder.time!!.setTextColor(white)
|
|
||||||
}
|
|
||||||
if (holder.imageText != null) {
|
|
||||||
holder.imageText!!.setTextColor(white)
|
|
||||||
}
|
|
||||||
if (holder.menu != null) {
|
if (holder.menu != null) {
|
||||||
(holder.menu as ImageView).setColorFilter(white, PorterDuff.Mode.SRC_IN)
|
(holder.menu as ImageView).setColorFilter(white, PorterDuff.Mode.SRC_IN)
|
||||||
}
|
}
|
||||||
|
@ -111,21 +95,11 @@ class PlayingQueueAdapter : SongAdapter, DraggableItemAdapter<PlayingQueueAdapte
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setAlpha(holder: SongAdapter.ViewHolder, alpha: Float) {
|
private fun setAlpha(holder: SongAdapter.ViewHolder, alpha: Float) {
|
||||||
if (holder.image != null) {
|
holder.image?.alpha = alpha
|
||||||
holder.image!!.alpha = alpha
|
holder.title?.alpha = alpha
|
||||||
}
|
holder.text?.alpha = alpha
|
||||||
if (holder.title != null) {
|
holder.imageText?.alpha = alpha
|
||||||
holder.title!!.alpha = alpha
|
holder.paletteColorContainer?.alpha = alpha
|
||||||
}
|
|
||||||
if (holder.text != null) {
|
|
||||||
holder.text!!.alpha = alpha
|
|
||||||
}
|
|
||||||
if (holder.imageText != null) {
|
|
||||||
holder.imageText!!.alpha = alpha
|
|
||||||
}
|
|
||||||
if (holder.paletteColorContainer != null) {
|
|
||||||
holder.paletteColorContainer!!.alpha = alpha
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCheckCanStartDrag(holder: ViewHolder, position: Int, x: Int, y: Int): Boolean {
|
override fun onCheckCanStartDrag(holder: ViewHolder, position: Int, x: Int, y: Int): Boolean {
|
||||||
|
@ -164,12 +138,8 @@ class PlayingQueueAdapter : SongAdapter, DraggableItemAdapter<PlayingQueueAdapte
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (imageText != null) {
|
imageText?.visibility = View.VISIBLE
|
||||||
imageText!!.visibility = View.VISIBLE
|
dragView?.visibility = View.VISIBLE
|
||||||
}
|
|
||||||
if (dragView != null) {
|
|
||||||
dragView!!.visibility = View.VISIBLE
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSongMenuItemClick(item: MenuItem): Boolean {
|
override fun onSongMenuItemClick(item: MenuItem): Boolean {
|
||||||
|
|
Loading…
Reference in a new issue