Skip to content

Commit

Permalink
rename/#5: 홈에 있는 rc 관련 파일 이름 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeeum committed Apr 18, 2024
1 parent b27970a commit 5bc08ee
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 39 deletions.
6 changes: 3 additions & 3 deletions app/src/main/java/com/sopt/now/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ class HomeFragment : Fragment() {
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val friendAdapter = FriendAdapter()
val homeListAdapter = HomeListAdapter()
binding.rvFriends.run {
adapter = friendAdapter
adapter = homeListAdapter
layoutManager = LinearLayoutManager(requireContext())
}
friendAdapter.setFriendList(MockFriendList.mockFriendList)
homeListAdapter.setFriendList(HomeListData.homeListData)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.sopt.now

import androidx.annotation.DrawableRes

data class Friend(
data class HomeList(
@DrawableRes val profileImage: Int,
val name: String,
val selfDescription: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import java.lang.RuntimeException

class FriendAdapter() : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
class HomeListAdapter() : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
// 임시의 빈 리스트
private var friendList: List<Friend> = emptyList()
private var homeListList: List<HomeList> = emptyList()
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
val adapterLayout : View?
return when(viewType){
Friend.VIEW_TYPE_USER -> {
HomeList.VIEW_TYPE_USER -> {
adapterLayout = LayoutInflater.from(parent.context)
.inflate(R.layout.item_user,parent,false)
UserViewHolder(adapterLayout)
}
Friend.VIEW_TYPE_FRIEND -> {
HomeList.VIEW_TYPE_FRIEND -> {
adapterLayout = LayoutInflater.from(parent.context)
.inflate(R.layout.item_friend,parent,false)
FriendViewHolder(adapterLayout)
Expand All @@ -27,15 +27,15 @@ class FriendAdapter() : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
}

override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
val item = friendList[position]
val item = homeListList[position]
when(item.viewType){
Friend.VIEW_TYPE_USER -> {
HomeList.VIEW_TYPE_USER -> {
(holder as UserViewHolder).ivProfile.setImageResource(item.profileImage)
holder.tvName.text = item.name
holder.tvSelfDescription.text = item.selfDescription
holder.setIsRecyclable(false)
}
Friend.VIEW_TYPE_FRIEND -> {
HomeList.VIEW_TYPE_FRIEND -> {
(holder as FriendViewHolder).ivProfile.setImageResource(item.profileImage)
holder.tvName.text = item.name
holder.tvSelfDescription.text = item.selfDescription
Expand All @@ -45,12 +45,12 @@ class FriendAdapter() : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
}
}

override fun getItemCount() = friendList.size
override fun getItemCount() = homeListList.size
override fun getItemViewType(position: Int): Int {
return friendList[position].viewType
return homeListList[position].viewType
}
fun setFriendList(friendList: List<Friend>) {
this.friendList = friendList.toList()
fun setFriendList(homeListList: List<HomeList>) {
this.homeListList = homeListList.toList()
notifyDataSetChanged()
}
}
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
package com.sopt.now

object MockFriendList {
val mockFriendList = listOf(
Friend(
object HomeListData {
val homeListData = listOf(
HomeList(
profileImage = R.drawable.main,
name = "송혜음",
selfDescription = "멀티 뷰 리싸이클러뷰!",
0
),
Friend(
HomeList(
profileImage = R.drawable.main,
name = "이의경",
selfDescription = "다들 빨리 끝내고 뒤풀이 가고 싶지? ㅎㅎ 아직 반도 안왔어 ^&^",
1
),
Friend(
HomeList(
profileImage = R.drawable.main,
name = "우상욱",
selfDescription = "나보다 안드 잘하는 사람 있으면 나와봐",
1
),
Friend(
HomeList(
profileImage = R.drawable.main,
name = "배지현",
selfDescription = "표정 풀자 ^^",
1
),
Friend(
HomeList(
profileImage = R.drawable.main,
name = "이의경",
selfDescription = "다들 빨리 끝내고 뒤풀이 가고 싶지? ㅎㅎ 아직 반도 안왔어 ^&^",
1
),
Friend(
HomeList(
profileImage = R.drawable.main,
name = "우상욱",
selfDescription = "나보다 안드 잘하는 사람 있으면 나와봐",
1
),
Friend(
HomeList(
profileImage = R.drawable.main,
name = "배지현",
selfDescription = "표정 풀자 ^^",
1
),
Friend(
HomeList(
profileImage = R.drawable.main,
name = "이의경",
selfDescription = "다들 빨리 끝내고 뒤풀이 가고 싶지? ㅎㅎ 아직 반도 안왔어 ^&^",
1
),
Friend(
HomeList(
profileImage = R.drawable.main,
name = "우상욱",
selfDescription = "나보다 안드 잘하는 사람 있으면 나와봐",
1
),
Friend(
HomeList(
profileImage = R.drawable.main,
name = "배지현",
selfDescription = "표정 풀자 ^^",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ class FriendViewHolder(private val view: View) : RecyclerView.ViewHolder(view) {
val ivProfile : ImageView = view.findViewById(R.id.iv_profile)
val tvName : TextView = view.findViewById(R.id.tv_name)
val tvSelfDescription : TextView = view.findViewById(R.id.tv_self_description)
}
class UserViewHolder(private val view: View) : RecyclerView.ViewHolder(view) {
val ivProfile : ImageView = view.findViewById(R.id.iv_profile)
val tvName : TextView = view.findViewById(R.id.tv_name)
val tvSelfDescription : TextView = view.findViewById(R.id.tv_self_description)
}
12 changes: 0 additions & 12 deletions app/src/main/java/com/sopt/now/UserViewHolder.kt

This file was deleted.

0 comments on commit 5bc08ee

Please sign in to comment.