From ae617d515469315d645532a7fa0209bb673bf5dd Mon Sep 17 00:00:00 2001 From: klaus Date: Sat, 27 Apr 2024 03:10:51 +0900 Subject: [PATCH] =?UTF-8?q?=ED=81=AC=EB=A6=AC=EC=97=90=EC=9D=B4=ED=84=B0?= =?UTF-8?q?=20=EC=B1=84=EB=84=90=20=EC=8B=9C=EB=A6=AC=EC=A6=88=20-=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=82=AC=EC=9D=B4=EC=A6=88=20?= =?UTF-8?q?=EA=B0=80=EB=A1=9C=20102=20->=20116.7,=20=EC=84=B8=EB=A1=9C=201?= =?UTF-8?q?44=20->=20165=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../explorer/profile/UserProfileActivity.kt | 5 +- .../series/UserProfileSeriesListAdapter.kt | 99 +++++++++++ .../main/res/layout/item_series_list_big.xml | 161 ++++++++++++++++++ 3 files changed, 263 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/kr/co/vividnext/sodalive/explorer/profile/series/UserProfileSeriesListAdapter.kt create mode 100644 app/src/main/res/layout/item_series_list_big.xml diff --git a/app/src/main/java/kr/co/vividnext/sodalive/explorer/profile/UserProfileActivity.kt b/app/src/main/java/kr/co/vividnext/sodalive/explorer/profile/UserProfileActivity.kt index 62604c9..c6603c2 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/explorer/profile/UserProfileActivity.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/explorer/profile/UserProfileActivity.kt @@ -46,6 +46,7 @@ import kr.co.vividnext.sodalive.explorer.profile.donation.UserProfileDonationAda import kr.co.vividnext.sodalive.explorer.profile.donation.UserProfileDonationAllViewActivity import kr.co.vividnext.sodalive.explorer.profile.fantalk.UserProfileFantalkAllViewActivity import kr.co.vividnext.sodalive.explorer.profile.follow.UserFollowerListActivity +import kr.co.vividnext.sodalive.explorer.profile.series.UserProfileSeriesListAdapter import kr.co.vividnext.sodalive.extensions.dpToPx import kr.co.vividnext.sodalive.extensions.loadUrl import kr.co.vividnext.sodalive.extensions.moneyFormat @@ -74,7 +75,7 @@ class UserProfileActivity : BaseActivity( private lateinit var loadingDialog: LoadingDialog private lateinit var liveAdapter: UserProfileLiveAdapter private lateinit var audioContentAdapter: AudioContentAdapter - private lateinit var seriesAdapter: SeriesListAdapter + private lateinit var seriesAdapter: UserProfileSeriesListAdapter private lateinit var donationAdapter: UserProfileDonationAdapter private lateinit var cheersAdapter: UserProfileCheersAdapter @@ -437,7 +438,7 @@ class UserProfileActivity : BaseActivity( false ) - seriesAdapter = SeriesListAdapter( + seriesAdapter = UserProfileSeriesListAdapter( onClickItem = { startActivity( Intent(applicationContext, SeriesDetailActivity::class.java).apply { diff --git a/app/src/main/java/kr/co/vividnext/sodalive/explorer/profile/series/UserProfileSeriesListAdapter.kt b/app/src/main/java/kr/co/vividnext/sodalive/explorer/profile/series/UserProfileSeriesListAdapter.kt new file mode 100644 index 0000000..078ccf0 --- /dev/null +++ b/app/src/main/java/kr/co/vividnext/sodalive/explorer/profile/series/UserProfileSeriesListAdapter.kt @@ -0,0 +1,99 @@ +package kr.co.vividnext.sodalive.explorer.profile.series + +import android.annotation.SuppressLint +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.recyclerview.widget.RecyclerView +import coil.load +import coil.transform.CircleCropTransformation +import coil.transform.RoundedCornersTransformation +import kr.co.vividnext.sodalive.R +import kr.co.vividnext.sodalive.audio_content.series.GetSeriesListResponse +import kr.co.vividnext.sodalive.databinding.ItemSeriesListBigBinding +import kr.co.vividnext.sodalive.databinding.ItemSeriesListBinding +import kr.co.vividnext.sodalive.extensions.dpToPx + +class UserProfileSeriesListAdapter( + private val onClickItem: (Long) -> Unit, + private val onClickCreator: (Long) -> Unit, + private val isVisibleCreator: Boolean +) : RecyclerView.Adapter() { + + val items = mutableListOf() + + inner class ViewHolder( + private val binding: ItemSeriesListBigBinding + ) : RecyclerView.ViewHolder(binding.root) { + @SuppressLint("SetTextI18n") + fun bind(item: GetSeriesListResponse.SeriesListItem) { + binding.ivCover.load(item.coverImage) { + crossfade(true) + placeholder(R.drawable.bg_placeholder) + transformations(RoundedCornersTransformation(5f.dpToPx())) + } + + binding.tvTitle.text = item.title + binding.tvSeriesContentCount.text = "총 ${item.numberOfContent}화" + binding.tvPublishedDaysOfWeek.text = item.publishedDaysOfWeek + + binding.tvNew.visibility = if (item.isNew) { + View.VISIBLE + } else { + View.GONE + } + + binding.tvPopular.visibility = if (item.isPopular) { + View.VISIBLE + } else { + View.GONE + } + + if (item.isComplete) { + binding.tvNew.visibility = View.GONE + binding.tvComplete.visibility = View.VISIBLE + } else { + binding.tvComplete.visibility = View.GONE + } + + if (isVisibleCreator) { + binding.llCreator.visibility = View.VISIBLE + binding.tvCreator.text = item.creator.nickname + binding.ivCreator.load(item.creator.profileImage) { + crossfade(true) + placeholder(R.drawable.ic_place_holder) + transformations(CircleCropTransformation()) + } + binding.llCreator.setOnClickListener { onClickCreator(item.creator.creatorId) } + } else { + binding.llCreator.visibility = View.GONE + } + + binding.root.setOnClickListener { onClickItem(item.seriesId) } + } + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = ViewHolder( + ItemSeriesListBigBinding.inflate( + LayoutInflater.from(parent.context), + parent, + false + ) + ) + + override fun onBindViewHolder(holder: ViewHolder, position: Int) { + holder.bind(items[position]) + } + + override fun getItemCount() = items.count() + + @SuppressLint("NotifyDataSetChanged") + fun addItems(items: List) { + this.items.addAll(items) + notifyDataSetChanged() + } + + fun clear() { + this.items.clear() + } +} diff --git a/app/src/main/res/layout/item_series_list_big.xml b/app/src/main/res/layout/item_series_list_big.xml new file mode 100644 index 0000000..67592d5 --- /dev/null +++ b/app/src/main/res/layout/item_series_list_big.xml @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +