From ccfa2f96beac4dac4b8c96d084a65eedf1928b71 Mon Sep 17 00:00:00 2001 From: SsongSik Date: Fri, 16 Jun 2023 00:51:25 +0900 Subject: [PATCH] [feat] : #15 Friend List Selected Text Color Change --- .../presentation/friend/FriendGetAdapter.kt | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/teampome/pome/presentation/friend/FriendGetAdapter.kt b/app/src/main/java/com/teampome/pome/presentation/friend/FriendGetAdapter.kt index cfa414e..4d372f4 100644 --- a/app/src/main/java/com/teampome/pome/presentation/friend/FriendGetAdapter.kt +++ b/app/src/main/java/com/teampome/pome/presentation/friend/FriendGetAdapter.kt @@ -1,6 +1,8 @@ package com.teampome.pome.presentation.friend import android.content.Context +import android.graphics.Color +import android.util.Log import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.DiffUtil @@ -15,6 +17,8 @@ class FriendGetAdapter( private val context : Context? ) : ListAdapter(BookDiffCallback) { + private var selectedPosition = -1 + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FriendGetViewHolder { return FriendGetViewHolder( ItemFriendsListBinding.inflate(LayoutInflater.from(parent.context), parent, false), @@ -24,9 +28,7 @@ class FriendGetAdapter( override fun onBindViewHolder(holder: FriendGetViewHolder, position: Int) { val friends = currentList[position] holder.bind(friends) - holder.itemView.setOnClickListener { - onItemClickListener?.let{ it(friends) } - } + } private var onItemClickListener : ((GetFriends) -> Unit)? = null @@ -44,7 +46,6 @@ class FriendGetAdapter( } else { getFriends.friendNickName } - friendListProfileIv.clipToOutline = true context?.let { context -> Glide.with(context) @@ -52,6 +53,16 @@ class FriendGetAdapter( .circleCrop() .into(friendListProfileIv) } + + friendAllTv.setTextColor( + if (adapterPosition == selectedPosition) Color.BLACK else Color.GRAY + ) + + itemView.setOnClickListener { + selectedPosition = adapterPosition + notifyDataSetChanged() + onItemClickListener?.invoke(getFriends) + } } }