Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PWN-983 - Add placeholder v2 #2201

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class HistoryTransactionDetailsPresenter(
if (!transaction.status.isPending()) {
showFee(transaction.fees)
}
showTransferView(transaction.token.logoUrl, R.drawable.ic_placeholder_image)
showTransferView(transaction.token.logoUrl, R.drawable.ic_placeholder_v2)
showStateTitleValue(
resources.getString(
if (transaction.isBurn) R.string.transaction_details_burn
Expand All @@ -235,7 +235,7 @@ class HistoryTransactionDetailsPresenter(
view?.showSubtitle(resources.getString(R.string.details_pending))
showProgressTransactionInProgress()
}
showTransferView(transaction.token.logoUrl, R.drawable.ic_placeholder_image)
showTransferView(transaction.token.logoUrl, R.drawable.ic_placeholder_v2)
if (transaction.fees != null && !transaction.status.isPending()) {
showFee(transaction.fees)
}
Expand All @@ -259,7 +259,7 @@ class HistoryTransactionDetailsPresenter(
view?.showSubtitle(resources.getString(R.string.details_pending))
showProgressTransactionInProgress()
}
showTransferView(transaction.token.logoUrl, R.drawable.ic_placeholder_image)
showTransferView(transaction.token.logoUrl, R.drawable.ic_placeholder_v2)
if (transaction.fees != null && !transaction.status.isPending()) {
showFee(transaction.fees)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class HistorySendLinkDetailsBottomSheet :

private fun renderContent(state: ViewState.Content) = with(binding) {
val tokenIconContainer = state.iconUrl?.let(DrawableContainer::invoke)
?: DrawableContainer.invoke(R.drawable.ic_placeholder_image)
?: DrawableContainer.invoke(R.drawable.ic_placeholder_v2)

imageViewSecondIcon.bind(ImageViewCellModel(icon = tokenIconContainer, clippingShape = shapeCircle()))
textViewSubtitle.bind(TextViewCellModel.Raw(TextContainer(state.formattedDate)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,11 @@ private fun AdapterDelegateViewBindingViewHolder<TokenCellModel, ItemTokenBindin
bindBalance()

val iconUrl = item.iconUrl
if (!iconUrl.isNullOrEmpty()) {
glideManager.load(
imageView = imageViewToken,
url = iconUrl,
circleCrop = true
)
}
glideManager.load(
imageView = imageViewToken,
url = iconUrl,
circleCrop = true
)
imageViewWrapped.isVisible = item.isWrapped
textViewName.text = item.tokenName
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class NewSelectTokenViewHolder(
Glide
.with(imageView)
.load(url)
.placeholder(R.drawable.ic_placeholder_image)
.placeholder(R.drawable.ic_placeholder_v2)
.into(imageView)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package org.p2p.wallet.home.ui.select

import androidx.core.view.isVisible
import android.graphics.drawable.PictureDrawable
import android.net.Uri
import android.view.ViewGroup
import android.widget.ImageView
import androidx.core.view.isVisible
import com.bumptech.glide.Glide
import com.bumptech.glide.RequestBuilder
import com.bumptech.glide.request.RequestOptions
import java.util.Locale
import org.p2p.core.R
import org.p2p.core.glide.SvgSoftwareLayerSetter
import org.p2p.core.token.Token
import org.p2p.wallet.common.ui.recycler.adapter.BaseSelectionViewHolder
import org.p2p.wallet.databinding.ItemNewTokenSimpleBinding
import org.p2p.core.token.Token
import org.p2p.wallet.utils.viewbinding.inflateViewBinding
import org.p2p.wallet.utils.withTextOrGone
import java.util.Locale

class NewSelectTokenViewHolder(
parent: ViewGroup,
Expand Down Expand Up @@ -59,7 +59,7 @@ class NewSelectTokenViewHolder(
Glide
.with(imageView)
.load(url)
.placeholder(R.drawable.ic_placeholder_image)
.placeholder(R.drawable.ic_placeholder_v2)
.into(imageView)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class HistoryItemMapper(
}
is RpcHistoryTransaction.BurnOrMint -> with(transaction) {
tokenIconUrl = token.logoUrl
iconRes = R.drawable.ic_placeholder_image
iconRes = R.drawable.ic_placeholder_v2

startTitle = resources.getString(getTitle())
startSubtitle = resources.getString(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package org.p2p.wallet.send.ui.search.adapter

import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import android.view.ViewGroup
import com.bumptech.glide.Glide
import timber.log.Timber
import org.p2p.wallet.R
import org.p2p.wallet.databinding.ItemSearchInvalidResultBinding
import org.p2p.wallet.send.model.SearchResult
Expand All @@ -12,7 +13,6 @@ import org.p2p.wallet.utils.toPx
import org.p2p.wallet.utils.viewbinding.getString
import org.p2p.wallet.utils.viewbinding.inflateViewBinding
import org.p2p.wallet.utils.withTextOrGone
import timber.log.Timber

class SearchErrorViewHolder(
parent: ViewGroup,
Expand Down Expand Up @@ -70,8 +70,8 @@ class SearchErrorViewHolder(
Glide.with(this)
.load(iconUrl)
.circleCrop()
.error(R.drawable.ic_placeholder_image)
.placeholder(R.drawable.ic_placeholder_image)
.error(R.drawable.ic_placeholder_v2)
.placeholder(R.drawable.ic_placeholder_v2)
.into(this)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ class SearchViewHolder(
Glide.with(root)
.load(imageObject)
.circleCrop()
.error(R.drawable.ic_placeholder_image)
.placeholder(R.drawable.ic_placeholder_image)
.error(R.drawable.ic_placeholder_v2)
.placeholder(R.drawable.ic_placeholder_v2)
.into(walletImageView)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ sealed class DrawableContainer : Parcelable {
val requestBuilder: RequestBuilder<PictureDrawable> = Glide.with(imageView.context)
.`as`(PictureDrawable::class.java)
.listener(SvgSoftwareLayerSetter())
val placeholder: Int = R.drawable.ic_placeholder_image
val placeholder: Int = R.drawable.ic_placeholder_v2

if (iconUrl.contains(".svg")) {
requestBuilder
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/java/org/p2p/core/glide/GlideManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ class GlideManager(context: Context) {
url: String?,
size: Int = DEFAULT_IMAGE_SIZE,
circleCrop: Boolean = false,
placeholder: Int = R.drawable.ic_placeholder_image
placeholder: Int = R.drawable.ic_placeholder_v2
) {
if (url?.contains(".svg") == true) {
requestBuilder
.load(Uri.parse(url))
.apply(RequestOptions().override(size, size))
.scaleCrop(url, circleCrop)
.placeholder(placeholder)
.error(placeholder)
.into(imageView)
} else {
Glide
Expand Down
16 changes: 16 additions & 0 deletions core/src/main/res/drawable/ic_placeholder_v2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="40"
android:viewportHeight="40">
<group>
<clip-path
android:pathData="M20,0L20,0A20,20 0,0 1,40 20L40,20A20,20 0,0 1,20 40L20,40A20,20 0,0 1,0 20L0,20A20,20 0,0 1,20 0z"/>
<path
android:pathData="M20,0L20,0A20,20 0,0 1,40 20L40,20A20,20 0,0 1,20 40L20,40A20,20 0,0 1,0 20L0,20A20,20 0,0 1,20 0z"
android:fillColor="#D3E4FF"/>
<path
android:pathData="M29,27V13C29,11.9 28.1,11 27,11H13C11.9,11 11,11.9 11,13V27C11,28.1 11.9,29 13,29H27C28.1,29 29,28.1 29,27ZM16.9,21.98L19,24.51L22.1,20.52C22.3,20.26 22.7,20.26 22.9,20.53L26.41,25.21C26.66,25.54 26.42,26.01 26.01,26.01H14.02C13.6,26.01 13.37,25.53 13.63,25.2L16.12,22C16.31,21.74 16.69,21.73 16.9,21.98Z"
android:fillColor="#1460A5"/>
</group>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class UiKitTransactionImageView @JvmOverloads constructor(
tokenIconUrl: String
) = with(binding) {
imageViewToken.scaleType = ImageView.ScaleType.FIT_CENTER
glideManager.load(imageViewToken, tokenIconUrl, IMAGE_SIZE, circleCrop = true)
glideManager.load(imageView = imageViewToken, url = tokenIconUrl, size = IMAGE_SIZE, circleCrop = true)
}

fun setStatusIcon(@DrawableRes statusIcon: Int?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fun ImageView.loadUrl(
url: String?,
size: Int = DEFAULT_IMAGE_SIZE,
circleCrop: Boolean = false,
placeholder: Int = R.drawable.ic_placeholder_image
placeholder: Int = R.drawable.ic_placeholder_v2
) {
glide.load(
imageView = this,
Expand Down
Loading