generated from NOW-SOPT-ANDROID/now-sopt-android-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
133 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.sopt.now | ||
|
||
import androidx.annotation.DrawableRes | ||
|
||
data class Friend( | ||
@DrawableRes val profileImage: Int, | ||
val name: String, | ||
val selfDescription: String, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.sopt.now | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.sopt.now.databinding.ItemFriendBinding | ||
|
||
class FriendAdapter() : RecyclerView.Adapter<FriendViewHolder>() { | ||
// 임시의 빈 리스트 | ||
private var friendList: List<Friend> = emptyList() | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FriendViewHolder { | ||
val inflater = LayoutInflater.from(parent.context) | ||
val binding = ItemFriendBinding.inflate(inflater, parent, false) | ||
return FriendViewHolder(binding) | ||
} | ||
|
||
override fun onBindViewHolder(holder: FriendViewHolder, position: Int) { | ||
holder.onBind(friendList[position]) | ||
} | ||
|
||
override fun getItemCount() = friendList.size | ||
|
||
fun setFriendList(friendList: List<Friend>) { | ||
this.friendList = friendList.toList() | ||
notifyDataSetChanged() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.sopt.now | ||
|
||
import androidx.recyclerview.widget.RecyclerView | ||
import com.sopt.now.databinding.ItemFriendBinding | ||
|
||
class FriendViewHolder(private val binding: ItemFriendBinding) : RecyclerView.ViewHolder(binding.root) { | ||
fun onBind(friendData: Friend) { | ||
binding.run { | ||
ivProfile.setImageResource(friendData.profileImage) | ||
tvName.text = friendData.name | ||
tvSelfDescription.text = friendData.selfDescription | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<ImageView | ||
android:id="@+id/iv_profile" | ||
android:layout_width="50dp" | ||
android:layout_height="0dp" | ||
android:layout_marginStart="20dp" | ||
android:scaleType="centerCrop" | ||
android:layout_marginVertical="10dp" | ||
android:src="@drawable/ic_person_white_24" | ||
app:layout_constraintDimensionRatio="1" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<TextView | ||
android:id="@+id/tv_name" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="8dp" | ||
android:text="친구의 이름" | ||
android:textSize="16sp" | ||
android:textStyle="bold" | ||
app:layout_constraintBottom_toBottomOf="@id/iv_profile" | ||
app:layout_constraintStart_toEndOf="@id/iv_profile" | ||
app:layout_constraintTop_toTopOf="@id/iv_profile" /> | ||
|
||
<TextView | ||
android:id="@+id/tv_self_description" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="20dp" | ||
android:maxLines="1" | ||
android:text="친구의 대화명" | ||
app:layout_constraintBottom_toBottomOf="@id/iv_profile" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintTop_toTopOf="@id/iv_profile" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |