Skip to content

Commit

Permalink
[CHORE/#379] coil load 함수 loadUrl 함수로 대체
Browse files Browse the repository at this point in the history
  • Loading branch information
b1urrrr committed Feb 8, 2024
1 parent d8e6f0e commit ab3c9c8
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ class SignInActivity : BindingActivity<ActivitySignInBinding>(R.layout.activity_
putExtra(EXTRA_NAME, viewModel.kakaoUserInfo.kakaoAccount?.name.orEmpty())
putExtra(EXTRA_GENDER, viewModel.kakaoUserInfo.kakaoAccount?.gender.toString())
putExtra(EXTRA_EMAIL, viewModel.kakaoUserInfo.kakaoAccount?.email.orEmpty())
putExtra(EXTRA_PROFILE_IMAGE, viewModel.kakaoUserInfo.kakaoAccount?.profile?.profileImageUrl.orEmpty())
putExtra(
EXTRA_PROFILE_IMAGE,
viewModel.kakaoUserInfo.kakaoAccount?.profile?.profileImageUrl.orEmpty()
)
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
}
}
Expand All @@ -177,7 +180,10 @@ class SignInActivity : BindingActivity<ActivitySignInBinding>(R.layout.activity_
putString(EXTRA_NAME, viewModel.kakaoUserInfo.kakaoAccount?.name.orEmpty())
putString(EXTRA_GENDER, viewModel.kakaoUserInfo.kakaoAccount?.gender.toString())
putString(EXTRA_EMAIL, viewModel.kakaoUserInfo.kakaoAccount?.email.orEmpty())
putString(EXTRA_PROFILE_IMAGE, viewModel.kakaoUserInfo.kakaoAccount?.profile?.profileImageUrl.orEmpty())
putString(
EXTRA_PROFILE_IMAGE,
viewModel.kakaoUserInfo.kakaoAccount?.profile?.profileImageUrl.orEmpty()
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.fragment.app.activityViewModels
import androidx.fragment.app.viewModels
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import coil.load
import com.el.yello.R
import com.el.yello.databinding.FragmentRewardDialogBinding
import com.el.yello.presentation.event.EventViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.lifecycle.lifecycleScope
import coil.load
import com.el.yello.R
import com.el.yello.databinding.FragmentNoticeDialogBinding
import com.el.yello.util.Image.loadUrl
import com.example.ui.base.BindingDialogFragment
import com.example.ui.view.setOnSingleClickListener
import dagger.hilt.android.AndroidEntryPoint
Expand Down Expand Up @@ -59,7 +60,7 @@ class NoticeDialog :

private fun initNoticeImageView() {
with(binding.ivNoticeImg) {
load(imageUrl)
loadUrl(imageUrl)

if (redirectUrl.isBlank()) return
setOnSingleClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import coil.load
import com.el.yello.R
import com.el.yello.databinding.FragmentProfileBinding
import com.el.yello.presentation.main.profile.ProfileViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.recyclerview.widget.RecyclerView
import coil.load
import com.el.yello.databinding.ItemProfileUserInfoBinding
import com.el.yello.presentation.main.profile.ProfileViewModel
import com.el.yello.util.Image.loadUrl
import com.el.yello.util.Utils.setImageOrBasicThumbnail
import com.example.ui.view.setOnSingleClickListener

Expand Down Expand Up @@ -32,7 +33,7 @@ class ProfileUserInfoViewHolder(
}

if (viewModel.profileBanner.isAvailable) {
binding.ivProfileBanner.load(viewModel.profileBanner.imageUrl)
binding.ivProfileBanner.loadUrl(viewModel.profileBanner.imageUrl)
binding.ivProfileBanner.setOnSingleClickListener { bannerClick(viewModel.profileBanner.redirectUrl) }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import coil.load
import coil.transform.CircleCropTransformation
import com.el.yello.R
import com.el.yello.databinding.ItemAddFriendBinding
import com.el.yello.util.Image.loadUrlWithCircleCrop
import com.example.domain.entity.onboarding.AddFriendListModel
import com.example.ui.view.setOnSingleClickListener

Expand All @@ -16,9 +17,7 @@ class AddFriendViewHolder(

fun onBind(friendModel: AddFriendListModel.FriendModel, position: Int) {
with(binding) {
ivFriendProfile.load(friendModel.profileImage) {
transformations(CircleCropTransformation())
}
ivFriendProfile.loadUrlWithCircleCrop(friendModel.profileImage)
tvFriendName.text = friendModel.name
tvFriendDepartment.text = friendModel.groupName
btnFriendCheck.isSelected = friendModel.isSelected
Expand Down
24 changes: 24 additions & 0 deletions app/src/main/java/com/el/yello/util/Image/ImageViewExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import coil.ImageLoader
import coil.decode.SvgDecoder
import coil.load
import coil.request.ImageRequest
import coil.transform.CircleCropTransformation

fun ImageView.loadUrl(url: String) {
if (url.endsWith(".svg")) {
Expand All @@ -25,3 +26,26 @@ fun ImageView.loadUrl(url: String) {

load(url)
}

fun ImageView.loadUrlWithCircleCrop(url: String) {
if (!url.endsWith(".svg")) {
load(url) {
transformations(CircleCropTransformation())
}
return
}

val imageLoader = ImageLoader.Builder(this.context)
.componentRegistry { add(SvgDecoder(this@loadUrlWithCircleCrop.context)) }
.build()

val request = ImageRequest.Builder(this.context)
.crossfade(true)
.crossfade(500)
.data(url)
.transformations(CircleCropTransformation())
.target(this)
.build()

imageLoader.enqueue(request)
}
6 changes: 2 additions & 4 deletions app/src/main/java/com/el/yello/util/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.el.yello.util
import android.widget.ImageView
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import coil.load
import coil.transform.CircleCropTransformation
import com.el.yello.R
import com.el.yello.util.Image.loadUrlWithCircleCrop
import com.example.ui.context.colorOf

object Utils {
Expand All @@ -31,9 +31,7 @@ object Utils {
fun ImageView.setImageOrBasicThumbnail(thumbnail: String) {
this.apply {
if (thumbnail == URL_BASIC_THUMBNAIL) load(R.drawable.img_yello_basic)
else load(thumbnail) {
transformations(CircleCropTransformation())
}
else loadUrlWithCircleCrop(thumbnail)
}
}

Expand Down

0 comments on commit ab3c9c8

Please sign in to comment.