fix(home): 커뮤니티 이미지 로드 크기를 전달한다
This commit is contained in:
@@ -132,7 +132,9 @@ class HomeFollowingNewsAdapter(
|
||||
view.setFeedSize(feedSize(FeedVariant.Community, parent))
|
||||
view.bind(feedItem)
|
||||
view.profileImageView().loadHomeCreatorProfileImage(feedItem.creatorImageUrl)
|
||||
bindImage(view.communityImageView(), feedItem.imageUrl.orEmpty())
|
||||
bindImage(view.communityImageView(), feedItem.imageUrl.orEmpty()) { width, height ->
|
||||
view.applyCommunityImageSize(width, height)
|
||||
}
|
||||
view.setOnFeedClick { onClickItem(community) }
|
||||
}
|
||||
}
|
||||
@@ -176,11 +178,21 @@ class HomeFollowingNewsAdapter(
|
||||
return FeedSize.from(variant, FeedWidthMode.ParentAvailable, availableWidthDp)
|
||||
}
|
||||
|
||||
private fun bindImage(imageView: android.widget.ImageView, url: String) {
|
||||
private fun bindImage(
|
||||
imageView: android.widget.ImageView,
|
||||
url: String,
|
||||
onImageLoaded: ((Int, Int) -> Unit)? = null
|
||||
) {
|
||||
if (url.isBlank()) {
|
||||
imageView.setImageDrawable(null)
|
||||
} else {
|
||||
imageView.loadUrl(url)
|
||||
imageView.loadUrl(url) {
|
||||
listener(
|
||||
onSuccess = { _, result ->
|
||||
onImageLoaded?.invoke(result.drawable.intrinsicWidth, result.drawable.intrinsicHeight)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,20 +53,27 @@ class HomePopularCommunityAdapter(
|
||||
bindImage(
|
||||
imageUrl = item.item.imageUrl,
|
||||
imageView = view.communityImageView(),
|
||||
shouldBlur = item.item.price > 0 && !item.item.existOrdered
|
||||
shouldBlur = item.item.price > 0 && !item.item.existOrdered,
|
||||
onImageLoaded = { width, height -> view.applyCommunityImageSize(width, height) }
|
||||
)
|
||||
}
|
||||
|
||||
private fun bindImage(
|
||||
imageUrl: String?,
|
||||
imageView: android.widget.ImageView,
|
||||
shouldBlur: Boolean = false
|
||||
shouldBlur: Boolean = false,
|
||||
onImageLoaded: ((Int, Int) -> Unit)? = null
|
||||
) {
|
||||
if (imageUrl.isNullOrBlank()) {
|
||||
imageView.dispose()
|
||||
imageView.setImageDrawable(null)
|
||||
} else {
|
||||
imageView.loadUrl(imageUrl) {
|
||||
listener(
|
||||
onSuccess = { _, result ->
|
||||
onImageLoaded?.invoke(result.drawable.intrinsicWidth, result.drawable.intrinsicHeight)
|
||||
}
|
||||
)
|
||||
if (shouldBlur) {
|
||||
transformations(BlurTransformation(imageView.context, 25f, 2.5f))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user