Skip to content

Commit

Permalink
[MERGE] : #379 -> develop
Browse files Browse the repository at this point in the history
[FIX/#379] Event /  SVG 이미지 로드 이슈 해결
  • Loading branch information
Chaeyeon authored Feb 8, 2024
2 parents f84ea98 + ab3c9c8 commit b6a3aba
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 23 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 @@ -4,9 +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.loadUrl
import com.example.ui.diff.DiffCallback

class RewardAdapter : ListAdapter<ParcelableReward, RewardAdapter.RewardViewHolder>(diffUtil) {
Expand All @@ -26,7 +26,7 @@ class RewardAdapter : ListAdapter<ParcelableReward, RewardAdapter.RewardViewHold
class RewardViewHolder(private val binding: ItemEventRewardBinding) :
RecyclerView.ViewHolder(binding.root) {
fun setReward(reward: ParcelableReward) {
binding.ivEventReward.load(reward.imageUrl)
binding.ivEventReward.loadUrl(reward.imageUrl)
binding.tvEventRewardDescription.text = reward.name
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import coil.load
import com.el.yello.R
import com.el.yello.databinding.FragmentRewardDialogBinding
import com.el.yello.presentation.event.EventViewModel
import com.el.yello.util.Image.loadUrl
import com.example.ui.base.BindingDialogFragment
import com.example.ui.view.UiState
import com.example.ui.view.setOnSingleClickListener
Expand Down Expand Up @@ -38,7 +39,7 @@ class RewardDialog :
when (state) {
is UiState.Success -> {
binding.tvRewardTitle.text = state.data.title
binding.ivReward.load(state.data.imageUrl)
binding.ivReward.loadUrl(state.data.imageUrl)
}

is UiState.Failure -> dismiss()
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
51 changes: 51 additions & 0 deletions app/src/main/java/com/el/yello/util/Image/ImageViewExt.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.el.yello.util.Image

import android.widget.ImageView
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")) {
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()

imageLoader.enqueue(request)
return
}

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)
}
7 changes: 3 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 @@ -30,9 +30,8 @@ object Utils {

fun ImageView.setImageOrBasicThumbnail(thumbnail: String) {
this.apply {
load(if (thumbnail == URL_BASIC_THUMBNAIL) R.drawable.img_yello_basic else thumbnail) {
transformations(CircleCropTransformation())
}
if (thumbnail == URL_BASIC_THUMBNAIL) load(R.drawable.img_yello_basic)
else loadUrlWithCircleCrop(thumbnail)
}
}

Expand Down
7 changes: 3 additions & 4 deletions app/src/main/res/layout/fragment_reward_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,10 @@

<ImageView
android:id="@+id/iv_reward"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="200dp"
android:layout_height="0dp"
app:layout_constraintDimensionRatio="1:1"
android:layout_marginTop="20dp"
android:minWidth="200dp"
android:minHeight="200dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_reward_subtitle" />
Expand Down
7 changes: 3 additions & 4 deletions app/src/main/res/layout/item_event_reward.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@

<ImageView
android:id="@+id/iv_event_reward"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="48dp"
android:layout_height="0dp"
android:contentDescription="@string/event_reward_image"
android:minWidth="48dp"
android:minHeight="48dp"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
Expand Down
4 changes: 3 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ billingVersion = "6.0.1"
firebaseVersion = "30.4.0"

## Third-party
coilVersion = "2.4.0"
coilVersion = "1.2.0"
retrofitVersion = "2.9.0"
kotlinSerializationConverterVersion = "1.0.0"
okHttpVersion = "4.11.0"
Expand Down Expand Up @@ -111,6 +111,7 @@ hiltAndroidCompiler = { group = "com.google.dagger", name = "hilt-compiler", ver
hiltWorkManagerCompiler = { group = "androidx.hilt", name = "hilt-compiler", version.ref = "hiltWorkManagerVersion" }

coil = { group = "io.coil-kt", name = "coil", version.ref = "coilVersion" }
coil-svg = { group = "io.coil-kt", name = "coil-svg", version.ref = "coilVersion" }
retrofit = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofitVersion" }
retrofit-json-converter = { group = "com.jakewharton.retrofit", name = "retrofit2-kotlinx-serialization-converter", version.ref = "kotlinSerializationConverterVersion" }
okhttp-Bom = { group = "com.squareup.okhttp3", name = "okhttp-bom", version.ref = "okHttpVersion" }
Expand Down Expand Up @@ -219,6 +220,7 @@ kakao = [

appModuleLibraryEtc = [
"coil",
"coil-svg",
"timber",
"progressView",
"balloon",
Expand Down

0 comments on commit b6a3aba

Please sign in to comment.