콘텐츠 플레이어

- 현재 재생 중인 콘텐츠 배경 변경
This commit is contained in:
klaus 2025-02-25 18:30:20 +09:00
parent 7d15179be0
commit 5d7db2d7e9
5 changed files with 31 additions and 1 deletions

View File

@ -390,6 +390,8 @@ class AudioContentPlayerFragment(
placeholder(R.drawable.ic_place_holder)
transformations(RoundedCornersTransformation(8f.dpToPx()))
}
adapter.updateCurrentPlayingId(it.extras?.getLong(Constants.EXTRA_AUDIO_CONTENT_ID))
}
}

View File

@ -229,6 +229,10 @@ class AudioContentPlayerService : MediaSessionService() {
Constants.EXTRA_AUDIO_CONTENT_CREATOR_PROFILE_IMAGE,
content.creatorProfileUrl
)
putLong(
Constants.EXTRA_AUDIO_CONTENT_ID,
content.id
)
}
val mediaMetadata = MediaMetadata.Builder()

View File

@ -14,6 +14,7 @@ class AudioContentPlaylistDetailAdapter :
RecyclerView.Adapter<AudioContentPlaylistDetailAdapter.ViewHolder>() {
private val items = mutableListOf<AudioContentPlaylistContent>()
private var currentPlayingContentId = 0L
inner class ViewHolder(
private val binding: ItemPlaylistContentBinding
@ -29,6 +30,12 @@ class AudioContentPlaylistDetailAdapter :
binding.tvTheme.text = item.category
binding.tvDuration.text = item.duration
binding.tvCreatorNickname.text = item.creatorNickname
if (currentPlayingContentId == item.id) {
binding.root.setBackgroundResource(R.drawable.bg_round_corner_6_7_333bb9f1)
} else {
binding.root.setBackgroundResource(0)
}
}
}
@ -52,4 +59,12 @@ class AudioContentPlaylistDetailAdapter :
this.items.addAll(items)
notifyDataSetChanged()
}
@SuppressLint("NotifyDataSetChanged")
fun updateCurrentPlayingId(contentId: Long?) {
if (contentId != null) {
this.currentPlayingContentId = contentId
}
notifyDataSetChanged()
}
}

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/color_333bb9f1" />
<corners android:radius="6.7dp" />
<stroke
android:width="1dp"
android:color="@color/color_333bb9f1" />
</shape>

View File

@ -3,7 +3,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:padding="13.3dp">
<ImageView
android:id="@+id/iv_cover"