From 2f17e04e1eb22686284ef5f7c0ee345317f0c0e6 Mon Sep 17 00:00:00 2001 From: klaus Date: Sat, 14 Oct 2023 18:48:02 +0900 Subject: [PATCH] =?UTF-8?q?=ED=83=90=EC=83=89=20-=20=ED=81=AC=EB=A6=AC?= =?UTF-8?q?=EC=97=90=EC=9D=B4=ED=84=B0=20=EB=9E=AD=ED=82=B9=20UI=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sodalive/explorer/ExplorerAdapter.kt | 5 ++- .../sodalive/explorer/ExplorerFragment.kt | 8 ++-- .../explorer/ExplorerSectionAdapter.kt | 43 +++++++++++++++++-- .../main/res/layout/item_explorer_section.xml | 37 ++++++++++++---- 4 files changed, 76 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/kr/co/vividnext/sodalive/explorer/ExplorerAdapter.kt b/app/src/main/java/kr/co/vividnext/sodalive/explorer/ExplorerAdapter.kt index 825e602..ce1ca7c 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/explorer/ExplorerAdapter.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/explorer/ExplorerAdapter.kt @@ -67,7 +67,10 @@ class ExplorerAdapter( } private fun setCreatorList(item: GetExplorerSectionResponse) { - val adapter = ExplorerSectionAdapter(onClickItem = onClickItem) + val adapter = ExplorerSectionAdapter( + onClickItem = onClickItem, + isVisibleRanking = item.desc != null + ) binding.rvExplorerSection.layoutManager = LinearLayoutManager( context, diff --git a/app/src/main/java/kr/co/vividnext/sodalive/explorer/ExplorerFragment.kt b/app/src/main/java/kr/co/vividnext/sodalive/explorer/ExplorerFragment.kt index ffcb5fe..b8ebdd8 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/explorer/ExplorerFragment.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/explorer/ExplorerFragment.kt @@ -85,17 +85,17 @@ class ExplorerFragment : BaseFragment( when (parent.getChildAdapterPosition(view)) { 0 -> { outRect.top = 0 - outRect.bottom = 30f.dpToPx().toInt() + outRect.bottom = 15f.dpToPx().toInt() } adapter.itemCount - 1 -> { - outRect.top = 30f.dpToPx().toInt() + outRect.top = 15f.dpToPx().toInt() outRect.bottom = 0 } else -> { - outRect.top = 30f.dpToPx().toInt() - outRect.bottom = 30f.dpToPx().toInt() + outRect.top = 15f.dpToPx().toInt() + outRect.bottom = 15f.dpToPx().toInt() } } } diff --git a/app/src/main/java/kr/co/vividnext/sodalive/explorer/ExplorerSectionAdapter.kt b/app/src/main/java/kr/co/vividnext/sodalive/explorer/ExplorerSectionAdapter.kt index 8c7e6bf..b1497e2 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/explorer/ExplorerSectionAdapter.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/explorer/ExplorerSectionAdapter.kt @@ -2,6 +2,7 @@ package kr.co.vividnext.sodalive.explorer import android.annotation.SuppressLint import android.view.LayoutInflater +import android.view.View import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import coil.load @@ -10,7 +11,8 @@ import kr.co.vividnext.sodalive.R import kr.co.vividnext.sodalive.databinding.ItemExplorerSectionBinding class ExplorerSectionAdapter( - private val onClickItem: (Long) -> Unit + private val onClickItem: (Long) -> Unit, + private val isVisibleRanking: Boolean ) : RecyclerView.Adapter() { private val items = mutableListOf() @@ -18,7 +20,8 @@ class ExplorerSectionAdapter( inner class ViewHolder( private val binding: ItemExplorerSectionBinding ) : RecyclerView.ViewHolder(binding.root) { - fun bind(item: GetExplorerSectionCreatorResponse) { + fun bind(item: GetExplorerSectionCreatorResponse, index: Int) { + binding.root.setOnClickListener { onClickItem(item.id) } binding.tvNickname.text = item.nickname binding.tvTags.text = item.tags @@ -28,7 +31,39 @@ class ExplorerSectionAdapter( crossfade(true) } - binding.root.setOnClickListener { onClickItem(item.id) } + if (isVisibleRanking) { + when (index) { + 0 -> { + binding.ivBg.setImageResource(R.drawable.bg_circle_ffdc00_ffb600) + binding.ivBg.visibility = View.VISIBLE + + binding.ivCrown.setImageResource(R.drawable.ic_crown_1) + binding.ivCrown.visibility = View.VISIBLE + } + + 1 -> { + binding.ivBg.setImageResource(R.drawable.bg_circle_ffffff_9f9f9f) + binding.ivBg.visibility = View.VISIBLE + + binding.ivCrown.setImageResource(R.drawable.ic_crown_2) + binding.ivCrown.visibility = View.VISIBLE + } + + 2 -> { + binding.ivBg.setImageResource(R.drawable.bg_circle_e6a77a_c67e4a) + binding.ivBg.visibility = View.VISIBLE + + binding.ivCrown.setImageResource(R.drawable.ic_crown_3) + binding.ivCrown.visibility = View.VISIBLE + } + + else -> { + binding.ivBg.setImageResource(0) + binding.ivBg.visibility = View.GONE + binding.ivCrown.visibility = View.GONE + } + } + } } } @@ -41,7 +76,7 @@ class ExplorerSectionAdapter( ) override fun onBindViewHolder(holder: ViewHolder, position: Int) { - holder.bind(items[position]) + holder.bind(items[position], index = position) } override fun getItemCount() = items.size diff --git a/app/src/main/res/layout/item_explorer_section.xml b/app/src/main/res/layout/item_explorer_section.xml index c70f1eb..a53d5c9 100644 --- a/app/src/main/res/layout/item_explorer_section.xml +++ b/app/src/main/res/layout/item_explorer_section.xml @@ -5,14 +5,35 @@ android:layout_width="93.3dp" android:layout_height="wrap_content"> - + app:layout_constraintTop_toTopOf="parent"> + + + + + + + + tools:ignore="SmallSp" + tools:text="#연애 #일상 #훈련" />