Merge pull request #2 from h4h13/new-style

Added image to queue
This commit is contained in:
Hemanth S 2020-10-09 23:33:16 +05:30 committed by GitHub
commit 912960fc31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 6 deletions

View file

@ -19,6 +19,8 @@ import android.view.View
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.FragmentActivity import androidx.fragment.app.FragmentActivity
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
import code.name.monkey.retromusic.glide.SongGlideRequest
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.MusicPlayerRemote.isPlaying import code.name.monkey.retromusic.helper.MusicPlayerRemote.isPlaying
import code.name.monkey.retromusic.helper.MusicPlayerRemote.playNextSong import code.name.monkey.retromusic.helper.MusicPlayerRemote.playNextSong
@ -26,6 +28,8 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote.removeFromQueue
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import com.bumptech.glide.Glide
import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemAdapter import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemAdapter
import com.h6ah4i.android.widget.advrecyclerview.draggable.ItemDraggableRange import com.h6ah4i.android.widget.advrecyclerview.draggable.ItemDraggableRange
import com.h6ah4i.android.widget.advrecyclerview.draggable.annotation.DraggableItemStateFlags import com.h6ah4i.android.widget.advrecyclerview.draggable.annotation.DraggableItemStateFlags
@ -55,8 +59,8 @@ class PlayingQueueAdapter(
override fun onBindViewHolder(holder: SongAdapter.ViewHolder, position: Int) { override fun onBindViewHolder(holder: SongAdapter.ViewHolder, position: Int) {
super.onBindViewHolder(holder, position) super.onBindViewHolder(holder, position)
holder.imageText?.text = (position - current).toString() val song = dataSet[position]
holder.time?.text = MusicUtil.getReadableDurationString(dataSet[position].duration) holder.time?.text = MusicUtil.getReadableDurationString(song.duration)
if (holder.itemViewType == HISTORY || holder.itemViewType == CURRENT) { if (holder.itemViewType == HISTORY || holder.itemViewType == CURRENT) {
setAlpha(holder, 0.5f) setAlpha(holder, 0.5f)
} }
@ -72,7 +76,17 @@ class PlayingQueueAdapter(
} }
override fun loadAlbumCover(song: Song, holder: SongAdapter.ViewHolder) { override fun loadAlbumCover(song: Song, holder: SongAdapter.ViewHolder) {
// We don't want to load it in this adapter if (holder.image == null) {
return
}
SongGlideRequest.Builder.from(Glide.with(activity), song)
.checkIgnoreMediaStore(activity)
.generatePalette(activity).build()
.into(object : RetroMusicColoredTarget(holder.image!!) {
override fun onColorReady(colors: MediaNotificationProcessor) {
//setColors(colors, holder)
}
})
} }
fun swapDataSet(dataSet: List<Song>, position: Int) { fun swapDataSet(dataSet: List<Song>, position: Int) {
@ -90,7 +104,6 @@ class PlayingQueueAdapter(
holder.image?.alpha = alpha holder.image?.alpha = alpha
holder.title?.alpha = alpha holder.title?.alpha = alpha
holder.text?.alpha = alpha holder.text?.alpha = alpha
holder.imageText?.alpha = alpha
holder.paletteColorContainer?.alpha = alpha holder.paletteColorContainer?.alpha = alpha
holder.dragView?.alpha = alpha holder.dragView?.alpha = alpha
holder.menu?.alpha = alpha holder.menu?.alpha = alpha
@ -143,7 +156,6 @@ class PlayingQueueAdapter(
} }
init { init {
imageText?.visibility = View.VISIBLE
dragView?.visibility = View.VISIBLE dragView?.visibility = View.VISIBLE
} }

View file

@ -177,7 +177,6 @@ open class SongAdapter(
get() = dataSet[layoutPosition] get() = dataSet[layoutPosition]
init { init {
setImageTransitionName(activity.getString(R.string.transition_album_art))
menu?.setOnClickListener(object : SongMenuHelper.OnClickSongMenu(activity) { menu?.setOnClickListener(object : SongMenuHelper.OnClickSongMenu(activity) {
override val song: Song override val song: Song
get() = this@ViewHolder.song get() = this@ViewHolder.song

View file

@ -51,6 +51,16 @@
app:layout_constraintStart_toEndOf="@id/drag_view" app:layout_constraintStart_toEndOf="@id/drag_view"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/image"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:scaleType="centerCrop"
tools:srcCompat="@tools:sample/backgrounds/scenic"
tools:visibility="visible" />
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/imageText" android:id="@+id/imageText"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View file

@ -52,6 +52,15 @@
app:layout_constraintStart_toEndOf="@id/drag_view" app:layout_constraintStart_toEndOf="@id/drag_view"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/image"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:scaleType="centerCrop"
tools:srcCompat="@tools:sample/backgrounds/scenic"
tools:visibility="visible" />
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/imageText" android:id="@+id/imageText"