Skip to content

Commit

Permalink
feat: 둥근 모서리로 이미지를 로딩하는 Glide 바인딩 어댑터 작성
Browse files Browse the repository at this point in the history
- 세 속성이 모두 필요하다.
- glideRoundedCornerImageUrl: 출력하고자 하는 이미지 url
- glidePlaceHolder: placeHolder의 url
- glideRoundingRadius: 모서리의 둥근 정도를 Int로 설정
  • Loading branch information
Junyoung-WON committed Jul 24, 2024
1 parent 35985e8 commit 7c305dd
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import androidx.databinding.BindingAdapter
import coil.load
import coil.transform.RoundedCornersTransformation
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.request.RequestOptions

@BindingAdapter(
value = ["coilImageUrl", "coilPlaceHolder"],
Expand Down Expand Up @@ -62,3 +64,19 @@ fun ImageView.setCircleImageWithGlide(
.error(placeHolder)
.into(this)
}

@BindingAdapter(
value = ["glideRoundedCornerImageUrl", "glidePlaceHolder", "glideRoundingRadius"],
)
fun ImageView.setRoundedCornerImageWithGlide(
url: String?,
placeHolder: Drawable? = null,
roundingRadius: Int,
) {
Glide.with(context)
.load(url)
.placeholder(placeHolder)
.apply(RequestOptions.bitmapTransform(RoundedCorners(roundingRadius)))
.error(placeHolder)
.into(this)
}

0 comments on commit 7c305dd

Please sign in to comment.