Skip to content

Commit

Permalink
[feat] : #15 Friend List Selected Text Color Change
Browse files Browse the repository at this point in the history
  • Loading branch information
SsongSik committed Jun 15, 2023
1 parent e153205 commit ccfa2f9
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -15,6 +17,8 @@ class FriendGetAdapter(
private val context : Context?
) : ListAdapter<GetFriends, FriendGetAdapter.FriendGetViewHolder>(BookDiffCallback) {

private var selectedPosition = -1

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FriendGetViewHolder {
return FriendGetViewHolder(
ItemFriendsListBinding.inflate(LayoutInflater.from(parent.context), parent, false),
Expand All @@ -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
Expand All @@ -44,14 +46,23 @@ class FriendGetAdapter(
} else {
getFriends.friendNickName
}
friendListProfileIv.clipToOutline = true

context?.let { context ->
Glide.with(context)
.load(getFriends.imageKey)
.circleCrop()
.into(friendListProfileIv)
}

friendAllTv.setTextColor(
if (adapterPosition == selectedPosition) Color.BLACK else Color.GRAY
)

itemView.setOnClickListener {
selectedPosition = adapterPosition
notifyDataSetChanged()
onItemClickListener?.invoke(getFriends)
}
}

}
Expand Down

0 comments on commit ccfa2f9

Please sign in to comment.