-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* build: dataBinding 사용 설정 * feat: 이미지 로딩 바인딩 어댑터 설정 - Glide, Coil 바인딩 어댑터를 각각 작성 - placeholder 설정 * style: ktlint check - import 순서 조정 * fix: attribute 개수에 맞추어 BindingAdapter의 value 재설정 * style: 마지막 줄 개행 추가 * feat: placeHolder를 필수 속성으로 변경 및 coil 이미지 로딩 코드 수정 - placeHolder를 ImageView의 필수 속성으로 지정 - Coil BindingAdapter에서 url이 null인 경우에도 이미지를 로드하는 동작이 수행되도록 수정 * ui: 상단바 색상 변경
- Loading branch information
1 parent
c98784e
commit 5428d76
Showing
3 changed files
with
70 additions
and
4 deletions.
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> |