generated from DO-SOPT-ANDROID/do-sopt-android-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 0
6주차 세미나 심화과제 #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Eonji-sw
wants to merge
4
commits into
develop
Choose a base branch
from
feature/seminar6-advanced
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
6주차 세미나 심화과제 #13
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -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 | ||
|
|
||
|
|
@@ -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) | ||
| binding.tvItemName.text = user.firstName | ||
| binding.tvItemMessage.text = user.email | ||
| } | ||
|
|
||
| //기존 뷰들에 없는 새로운 xml 속성을 연결하는 기능 메소드를 가지는 객체 | ||
| //보통 static 메소드를 가진 class로 사용 | ||
| //static 메소드를 가져야하기 때문에 class면 안됨 object로 명시 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 파일을 만들어서 관리하는 것이 가독성, 유지보수 측면에서 좋아보입니다!