From 55babf39ac4cee176c60afe6ec3234aaa22ac7e9 Mon Sep 17 00:00:00 2001 From: b1urrrr <20190993@sungshin.ac.kr> Date: Thu, 8 Feb 2024 12:41:43 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[FIX/#379]=20loadSvg=20=ED=95=A8=EC=88=98?= =?UTF-8?q?=20=ED=99=9C=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yello/presentation/event/RewardAdapter.kt | 3 ++- .../presentation/event/reward/RewardDialog.kt | 3 ++- .../com/el/yello/util/Image/ImageViewExt.kt | 21 +++++++++++++++++++ app/src/main/java/com/el/yello/util/Utils.kt | 3 ++- .../res/layout/fragment_reward_dialog.xml | 7 +++---- app/src/main/res/layout/item_event_reward.xml | 7 +++---- gradle/libs.versions.toml | 5 ++++- 7 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 app/src/main/java/com/el/yello/util/Image/ImageViewExt.kt diff --git a/app/src/main/java/com/el/yello/presentation/event/RewardAdapter.kt b/app/src/main/java/com/el/yello/presentation/event/RewardAdapter.kt index a2f695e4f..32684a0ea 100644 --- a/app/src/main/java/com/el/yello/presentation/event/RewardAdapter.kt +++ b/app/src/main/java/com/el/yello/presentation/event/RewardAdapter.kt @@ -7,6 +7,7 @@ import androidx.recyclerview.widget.RecyclerView import coil.load import com.el.yello.databinding.ItemEventRewardBinding import com.el.yello.presentation.main.ParcelableReward +import com.el.yello.util.Image.loadSvg import com.example.ui.diff.DiffCallback class RewardAdapter : ListAdapter(diffUtil) { @@ -26,7 +27,7 @@ class RewardAdapter : ListAdapter { binding.tvRewardTitle.text = state.data.title - binding.ivReward.load(state.data.imageUrl) + binding.ivReward.loadSvg(state.data.imageUrl) } is UiState.Failure -> dismiss() diff --git a/app/src/main/java/com/el/yello/util/Image/ImageViewExt.kt b/app/src/main/java/com/el/yello/util/Image/ImageViewExt.kt new file mode 100644 index 000000000..afd0a70b9 --- /dev/null +++ b/app/src/main/java/com/el/yello/util/Image/ImageViewExt.kt @@ -0,0 +1,21 @@ +package com.el.yello.util.Image + +import android.widget.ImageView +import coil.ImageLoader +import coil.decode.SvgDecoder +import coil.request.ImageRequest + +fun ImageView.loadSvg(url: String) { + val imageLoader = ImageLoader.Builder(this.context) + .componentRegistry { add(SvgDecoder(this@loadSvg.context)) } + .build() + + val request = ImageRequest.Builder(this.context) + .crossfade(true) + .crossfade(500) + .data(url) + .target(this) + .build() + + imageLoader.enqueue(request) +} diff --git a/app/src/main/java/com/el/yello/util/Utils.kt b/app/src/main/java/com/el/yello/util/Utils.kt index 75cce70ca..cf2f61e2e 100644 --- a/app/src/main/java/com/el/yello/util/Utils.kt +++ b/app/src/main/java/com/el/yello/util/Utils.kt @@ -30,7 +30,8 @@ object Utils { fun ImageView.setImageOrBasicThumbnail(thumbnail: String) { this.apply { - load(if (thumbnail == URL_BASIC_THUMBNAIL) R.drawable.img_yello_basic else thumbnail) { + if (thumbnail == URL_BASIC_THUMBNAIL) load(R.drawable.img_yello_basic) + else load(thumbnail) { transformations(CircleCropTransformation()) } } diff --git a/app/src/main/res/layout/fragment_reward_dialog.xml b/app/src/main/res/layout/fragment_reward_dialog.xml index 5972f9e0a..00f17b47d 100644 --- a/app/src/main/res/layout/fragment_reward_dialog.xml +++ b/app/src/main/res/layout/fragment_reward_dialog.xml @@ -52,11 +52,10 @@ diff --git a/app/src/main/res/layout/item_event_reward.xml b/app/src/main/res/layout/item_event_reward.xml index 9ed46857d..8762b7268 100644 --- a/app/src/main/res/layout/item_event_reward.xml +++ b/app/src/main/res/layout/item_event_reward.xml @@ -14,11 +14,10 @@ Date: Thu, 8 Feb 2024 12:49:02 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[DEL/#379]=20coilSvgVersion=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle/libs.versions.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 35522543f..721bdf18d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -32,7 +32,6 @@ firebaseVersion = "30.4.0" ## Third-party coilVersion = "1.2.0" -coilSvgVersion = "1.2.0" retrofitVersion = "2.9.0" kotlinSerializationConverterVersion = "1.0.0" okHttpVersion = "4.11.0" From d8e6f0e92148630955c5a76c138520fc1401d6ca Mon Sep 17 00:00:00 2001 From: b1urrrr <20190993@sungshin.ac.kr> Date: Thu, 8 Feb 2024 13:15:06 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[CHORE/#379]=20=ED=99=95=EC=9E=A5=ED=95=A8?= =?UTF-8?q?=EC=88=98=20.svg=20=ED=99=95=EC=9E=A5=EC=9E=90=20=EB=B6=84?= =?UTF-8?q?=EA=B8=B0=EC=B2=98=EB=A6=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yello/presentation/event/RewardAdapter.kt | 5 ++-- .../presentation/event/reward/RewardDialog.kt | 5 ++-- .../com/el/yello/util/Image/ImageViewExt.kt | 28 +++++++++++-------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/com/el/yello/presentation/event/RewardAdapter.kt b/app/src/main/java/com/el/yello/presentation/event/RewardAdapter.kt index 32684a0ea..92e72471f 100644 --- a/app/src/main/java/com/el/yello/presentation/event/RewardAdapter.kt +++ b/app/src/main/java/com/el/yello/presentation/event/RewardAdapter.kt @@ -4,10 +4,9 @@ import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView -import coil.load import com.el.yello.databinding.ItemEventRewardBinding import com.el.yello.presentation.main.ParcelableReward -import com.el.yello.util.Image.loadSvg +import com.el.yello.util.Image.loadUrl import com.example.ui.diff.DiffCallback class RewardAdapter : ListAdapter(diffUtil) { @@ -27,7 +26,7 @@ class RewardAdapter : ListAdapter { binding.tvRewardTitle.text = state.data.title - binding.ivReward.loadSvg(state.data.imageUrl) + binding.ivReward.loadUrl(state.data.imageUrl) } is UiState.Failure -> dismiss() diff --git a/app/src/main/java/com/el/yello/util/Image/ImageViewExt.kt b/app/src/main/java/com/el/yello/util/Image/ImageViewExt.kt index afd0a70b9..e5af8a531 100644 --- a/app/src/main/java/com/el/yello/util/Image/ImageViewExt.kt +++ b/app/src/main/java/com/el/yello/util/Image/ImageViewExt.kt @@ -3,19 +3,25 @@ package com.el.yello.util.Image import android.widget.ImageView import coil.ImageLoader import coil.decode.SvgDecoder +import coil.load import coil.request.ImageRequest -fun ImageView.loadSvg(url: String) { - val imageLoader = ImageLoader.Builder(this.context) - .componentRegistry { add(SvgDecoder(this@loadSvg.context)) } - .build() +fun ImageView.loadUrl(url: String) { + if (url.endsWith(".svg")) { + val imageLoader = ImageLoader.Builder(this.context) + .componentRegistry { add(SvgDecoder(this@loadUrl.context)) } + .build() - val request = ImageRequest.Builder(this.context) - .crossfade(true) - .crossfade(500) - .data(url) - .target(this) - .build() + val request = ImageRequest.Builder(this.context) + .crossfade(true) + .crossfade(500) + .data(url) + .target(this) + .build() - imageLoader.enqueue(request) + imageLoader.enqueue(request) + return + } + + load(url) } From ab3c9c8a9f044470e6ae0759d5d2908fd9d80b84 Mon Sep 17 00:00:00 2001 From: b1urrrr <20190993@sungshin.ac.kr> Date: Thu, 8 Feb 2024 13:32:28 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[CHORE/#379]=20coil=20load=20=ED=95=A8?= =?UTF-8?q?=EC=88=98=20loadUrl=20=ED=95=A8=EC=88=98=EB=A1=9C=20=EB=8C=80?= =?UTF-8?q?=EC=B2=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yello/presentation/auth/SignInActivity.kt | 10 ++++++-- .../presentation/event/reward/RewardDialog.kt | 1 + .../main/dialog/notice/NoticeDialog.kt | 3 ++- .../main/profile/info/ProfileFragment.kt | 1 + .../profile/info/ProfileUserInfoViewHolder.kt | 3 ++- .../fragment/addfriend/AddFriendViewHolder.kt | 5 ++-- .../com/el/yello/util/Image/ImageViewExt.kt | 24 +++++++++++++++++++ app/src/main/java/com/el/yello/util/Utils.kt | 6 ++--- 8 files changed, 42 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/el/yello/presentation/auth/SignInActivity.kt b/app/src/main/java/com/el/yello/presentation/auth/SignInActivity.kt index c5d197cde..0b3b35ee1 100644 --- a/app/src/main/java/com/el/yello/presentation/auth/SignInActivity.kt +++ b/app/src/main/java/com/el/yello/presentation/auth/SignInActivity.kt @@ -166,7 +166,10 @@ class SignInActivity : BindingActivity(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) } } @@ -177,7 +180,10 @@ class SignInActivity : BindingActivity(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() + ) } } diff --git a/app/src/main/java/com/el/yello/presentation/event/reward/RewardDialog.kt b/app/src/main/java/com/el/yello/presentation/event/reward/RewardDialog.kt index e8703acf2..c35e4d2a6 100644 --- a/app/src/main/java/com/el/yello/presentation/event/reward/RewardDialog.kt +++ b/app/src/main/java/com/el/yello/presentation/event/reward/RewardDialog.kt @@ -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 diff --git a/app/src/main/java/com/el/yello/presentation/main/dialog/notice/NoticeDialog.kt b/app/src/main/java/com/el/yello/presentation/main/dialog/notice/NoticeDialog.kt index e6c9ed063..19fc31221 100644 --- a/app/src/main/java/com/el/yello/presentation/main/dialog/notice/NoticeDialog.kt +++ b/app/src/main/java/com/el/yello/presentation/main/dialog/notice/NoticeDialog.kt @@ -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 @@ -59,7 +60,7 @@ class NoticeDialog : private fun initNoticeImageView() { with(binding.ivNoticeImg) { - load(imageUrl) + loadUrl(imageUrl) if (redirectUrl.isBlank()) return setOnSingleClickListener { diff --git a/app/src/main/java/com/el/yello/presentation/main/profile/info/ProfileFragment.kt b/app/src/main/java/com/el/yello/presentation/main/profile/info/ProfileFragment.kt index 3cacecb29..4813e9f3c 100644 --- a/app/src/main/java/com/el/yello/presentation/main/profile/info/ProfileFragment.kt +++ b/app/src/main/java/com/el/yello/presentation/main/profile/info/ProfileFragment.kt @@ -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 diff --git a/app/src/main/java/com/el/yello/presentation/main/profile/info/ProfileUserInfoViewHolder.kt b/app/src/main/java/com/el/yello/presentation/main/profile/info/ProfileUserInfoViewHolder.kt index cefac0ef6..5e9721e93 100644 --- a/app/src/main/java/com/el/yello/presentation/main/profile/info/ProfileUserInfoViewHolder.kt +++ b/app/src/main/java/com/el/yello/presentation/main/profile/info/ProfileUserInfoViewHolder.kt @@ -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 @@ -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) } } } diff --git a/app/src/main/java/com/el/yello/presentation/onboarding/fragment/addfriend/AddFriendViewHolder.kt b/app/src/main/java/com/el/yello/presentation/onboarding/fragment/addfriend/AddFriendViewHolder.kt index 6755dd327..b9107e6b7 100644 --- a/app/src/main/java/com/el/yello/presentation/onboarding/fragment/addfriend/AddFriendViewHolder.kt +++ b/app/src/main/java/com/el/yello/presentation/onboarding/fragment/addfriend/AddFriendViewHolder.kt @@ -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 @@ -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 diff --git a/app/src/main/java/com/el/yello/util/Image/ImageViewExt.kt b/app/src/main/java/com/el/yello/util/Image/ImageViewExt.kt index e5af8a531..c2c60f7b6 100644 --- a/app/src/main/java/com/el/yello/util/Image/ImageViewExt.kt +++ b/app/src/main/java/com/el/yello/util/Image/ImageViewExt.kt @@ -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")) { @@ -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) +} diff --git a/app/src/main/java/com/el/yello/util/Utils.kt b/app/src/main/java/com/el/yello/util/Utils.kt index cf2f61e2e..cc80e3713 100644 --- a/app/src/main/java/com/el/yello/util/Utils.kt +++ b/app/src/main/java/com/el/yello/util/Utils.kt @@ -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 { @@ -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) } }