-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: 공통 이미지 로딩 BindingAdapter 설정 #33 #41
Merged
Junyoung-WON
merged 8 commits into
develop-an
from
feature/#33_set_up_image_loading_binding_adapter
Jul 23, 2024
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5528f94
build: dataBinding 사용 설정
Junyoung-WON c11bb72
feat: 이미지 로딩 바인딩 어댑터 설정
Junyoung-WON c95dd69
style: ktlint check
Junyoung-WON 759ab68
fix: attribute 개수에 맞추어 BindingAdapter의 value 재설정
Junyoung-WON ef5f00a
style: 마지막 줄 개행 추가
Junyoung-WON 111b908
feat: placeHolder를 필수 속성으로 변경 및 coil 이미지 로딩 코드 수정
Junyoung-WON 7d88084
fix: Merge Conflicts 해결
Junyoung-WON a49eeb4
ui: 상단바 색상 변경
Junyoung-WON 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
64 changes: 64 additions & 0 deletions
64
...id/Staccato_AN/app/src/main/java/com/woowacourse/staccato/presentation/BindingAdapters.kt
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,64 @@ | ||
package com.woowacourse.staccato.presentation | ||
|
||
import android.graphics.drawable.Drawable | ||
import android.widget.ImageView | ||
import androidx.databinding.BindingAdapter | ||
import coil.load | ||
import coil.transform.RoundedCornersTransformation | ||
import com.bumptech.glide.Glide | ||
|
||
@BindingAdapter( | ||
value = ["coilImageUrl", "coilPlaceHolder"], | ||
) | ||
fun ImageView.loadImageWithCoil( | ||
url: String?, | ||
placeHolder: Drawable? = null, | ||
) { | ||
load(url) { | ||
placeholder(placeHolder) | ||
error(placeHolder) | ||
} | ||
} | ||
|
||
@BindingAdapter( | ||
value = ["coilCircleImageUrl", "coilPlaceHolder"], | ||
) | ||
fun ImageView.setCircleImageWithCoil( | ||
url: String?, | ||
placeHolder: Drawable? = null, | ||
) { | ||
load(url) { | ||
placeholder(placeHolder) | ||
transformations(RoundedCornersTransformation(1000f)) | ||
error(placeHolder) | ||
} | ||
} | ||
|
||
@BindingAdapter( | ||
value = ["glideImageUrl", "glidePlaceHolder"], | ||
) | ||
fun ImageView.loadImageWithGlide( | ||
url: String?, | ||
placeHolder: Drawable? = null, | ||
) { | ||
Glide.with(context) | ||
.load(url) | ||
.placeholder(placeHolder) | ||
.error(placeHolder) | ||
.into(this) | ||
} | ||
|
||
@BindingAdapter( | ||
value = ["glideCircleImageUrl", "glidePlaceHolder"], | ||
) | ||
fun ImageView.setCircleImageWithGlide( | ||
url: String?, | ||
placeHolder: Drawable? = null, | ||
) { | ||
Glide.with(context) | ||
.load(url) | ||
.placeholder(placeHolder) | ||
.circleCrop() | ||
.error(placeHolder) | ||
.into(this) | ||
} |
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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
<resources xmlns:tools="http://schemas.android.com/tools"> | ||
<!-- Base application theme. --> | ||
<style name="Base.Theme.Staccato_AN" parent="Theme.Material3.DayNight.NoActionBar"> | ||
<!-- Customize your light theme here. --> | ||
<!-- <item name="colorPrimary">@color/my_light_primary</item> --> | ||
<!-- Status bar color. --> | ||
<item name="android:statusBarColor">@android:color/white</item> | ||
<!-- Customize your theme here. --> | ||
<item name="android:windowLightStatusBar">true</item> | ||
</style> | ||
|
||
<style name="Theme.Staccato_AN" parent="Base.Theme.Staccato_AN" /> | ||
</resources> | ||
</resources> |
Oops, something went wrong.
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.
value들의 이름을 명확하게 작성해주셔서 나중에 사용하기 편할 것 같습니다!👍