Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ plugins {
id 'org.jetbrains.kotlin.plugin.serialization' version '1.8.20'
}

apply plugin: 'kotlin-kapt'

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

Expand Down Expand Up @@ -31,11 +33,11 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '11'
jvmTarget = '17'
}
buildFeatures {
viewBinding true
Expand Down Expand Up @@ -68,6 +70,7 @@ dependencies {
implementation("com.squareup.okhttp3:logging-interceptor")

implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'

implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2"
implementation 'androidx.core:core-ktx:1.8.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package org.sopt.dosopttemplate.data.adaptor
import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.databinding.BindingAdapter
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.google.android.material.imageview.ShapeableImageView
import org.sopt.dosopttemplate.databinding.ItemFriendBinding
import org.sopt.dosopttemplate.server.auth.response.ResponseUserListDataDto

Expand Down Expand Up @@ -35,10 +37,29 @@ class UserViewHolder(private val binding: ItemFriendBinding) :
RecyclerView.ViewHolder(binding.root) {
private val context: Context = binding.root.context
fun onBind(user: ResponseUserListDataDto) {
Glide.with(context)
.load(user.avatar).into(binding.ivItemImage)

loadImage(binding.ivItemImage, user.avatar)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

옹?!!! 사실 이러면 DataBinding을 적용한게 아니라 loadImage 함수를 불러서 imageView에 img를 넣어준거라서, 한번 다시 수정해보면 좋을 것 같아요!!
BindnigAdapter는 잘 만들었어유!! 대신, 따로 BindingAdapter class 파일을 만들어서 관리하는 것이 가독성, 유지보수 측면에서 좋아보입니다!

binding.tvItemName.text = user.firstName
binding.tvItemMessage.text = user.email
}

//기존 뷰들에 없는 새로운 xml 속성을 연결하는 기능 메소드를 가지는 객체
//보통 static 메소드를 가진 class로 사용
//static 메소드를 가져야하기 때문에 class면 안됨 object로 명시

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

주석으로 보이는 공부 열정,,, 멋진 먼지 👍

companion object {
//객체가 단 한마리 밖에 없는 애 : 싱글턴 패턴!!


@JvmStatic //static 만드는 어노테이션
// 1) 이미지뷰에 새로운 xml 속성 만들기
// [속성명 : imageUrl ]
@BindingAdapter("imageUrl") //어노테이션 해독기 필요 - 빌드그래이들에 기능 추가 필요!
fun loadImage(view: ShapeableImageView, imageUrl: String?) {
imageUrl?.let {
//메소드 명은 내 맘대로 다만! 파라미터 (어떤뷰에 주는지(뷰타입), 어떤 값인지(속성값)) 가 중요!!
Glide.with(view.context)
.load(it)
.into(view)
}
}
}
}
3 changes: 2 additions & 1 deletion app/src/main/res/layout/item_friend.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
android:layout_marginVertical="15dp"
android:layout_marginStart="25dp"
android:scaleType="centerCrop"
android:src="@drawable/kakao_profile_sky"
tools:src="@drawable/kakao_profile_sky"
imageUrl="@{user.avatar}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="1"
app:layout_constraintStart_toStartOf="parent"
Expand Down