From 2684d62b31ffcba8e633467b7c49bfbcb1af5a60 Mon Sep 17 00:00:00 2001 From: Yuichiro Kinoshita Date: Sun, 8 Oct 2023 16:33:37 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=A2=E3=83=90=E3=82=BF=E3=83=BC=E3=81=AE?= =?UTF-8?q?=E3=82=A2=E3=82=A4=E3=82=B3=E3=83=B3=E3=82=92=E8=AA=AD=E3=81=BF?= =?UTF-8?q?=E8=BE=BC=E3=82=80=E6=99=82=E3=81=AB=E3=82=B5=E3=83=A0=E3=83=8D?= =?UTF-8?q?=E3=82=A4=E3=83=AB=E3=81=A8=E3=81=97=E3=81=A6blurhash=E3=82=92?= =?UTF-8?q?=E5=85=83=E3=81=AB=E3=81=97=E3=81=9F=E7=94=BB=E5=83=8F=E3=82=92?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pantasystem/milktea/common/ui/AvatarIconView.kt | 11 +++++++++-- .../src/main/res/layout/item_user_chip.xml | 1 + .../note/src/main/res/layout/item_detail_note.xml | 1 + .../note/src/main/res/layout/item_simple_note.xml | 2 ++ .../user/src/main/res/layout/activity_user_detail.xml | 1 + 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/common/src/main/java/net/pantasystem/milktea/common/ui/AvatarIconView.kt b/modules/common/src/main/java/net/pantasystem/milktea/common/ui/AvatarIconView.kt index 5e7faa6166..bff96972fa 100644 --- a/modules/common/src/main/java/net/pantasystem/milktea/common/ui/AvatarIconView.kt +++ b/modules/common/src/main/java/net/pantasystem/milktea/common/ui/AvatarIconView.kt @@ -6,6 +6,7 @@ import androidx.appcompat.widget.AppCompatImageView import androidx.databinding.BindingAdapter import net.pantasystem.milktea.common.R import net.pantasystem.milktea.common.glide.GlideApp +import net.pantasystem.milktea.common.glide.blurhash.BlurHashSource class AvatarIconView : AppCompatImageView { @@ -13,11 +14,17 @@ class AvatarIconView : AppCompatImageView { const val SHAPE_CIRCLE = 0 const val SHAPE_ROUNDED_CORNER = 1 - @BindingAdapter("imageUrl") + @BindingAdapter("imageUrl", "blurhash") @JvmStatic - fun setImageUrl(iconView: AvatarIconView, url: String?) { + fun setImageUrl(iconView: AvatarIconView, url: String?, blurhash: String?) { GlideApp.with(iconView.context) .load(url) + .thumbnail( + GlideApp.with(iconView.context) + .load(blurhash?.let { + BlurHashSource(it) + }) + ) .error(R.drawable.ic_cloud_off_black_24dp) .into(iconView) } diff --git a/modules/common_android_ui/src/main/res/layout/item_user_chip.xml b/modules/common_android_ui/src/main/res/layout/item_user_chip.xml index 2e1733a2a9..8f5622edbc 100644 --- a/modules/common_android_ui/src/main/res/layout/item_user_chip.xml +++ b/modules/common_android_ui/src/main/res/layout/item_user_chip.xml @@ -27,6 +27,7 @@ android:layout_height="25dp" tools:src="@drawable/ic_person_black_24dp" app:imageUrl="@{userViewData.user.avatarUrl}" + app:blurhash="@{userViewData.user.avatarBlurhash}" app:iconShape="circle" tools:ignore="ContentDescription" android:layout_gravity="center_vertical" diff --git a/modules/features/note/src/main/res/layout/item_detail_note.xml b/modules/features/note/src/main/res/layout/item_detail_note.xml index fe7e71ea4c..481d7ce1e2 100644 --- a/modules/features/note/src/main/res/layout/item_detail_note.xml +++ b/modules/features/note/src/main/res/layout/item_detail_note.xml @@ -69,6 +69,7 @@ android:layout_marginEnd="8dp" android:contentDescription="@string/avataricon" app:imageUrl='@{note.avatarUrl}' + app:blurhash="@{note.toShowNote.user.avatarBlurhash}" app:iconShape="@{note.config.avatarIconShapeType.value}" app:transitionDestinationUser="@{note.toShowNote.user}" tools:srcCompat="@android:drawable/sym_def_app_icon" diff --git a/modules/features/note/src/main/res/layout/item_simple_note.xml b/modules/features/note/src/main/res/layout/item_simple_note.xml index 7edb8a206b..6d85cacddd 100644 --- a/modules/features/note/src/main/res/layout/item_simple_note.xml +++ b/modules/features/note/src/main/res/layout/item_simple_note.xml @@ -48,6 +48,7 @@ android:scaleType="centerCrop" app:iconShape="@{note.config.avatarIconShapeType.value}" app:imageUrl="@{note.avatarUrl}" + app:blurhash="@{note.toShowNote.user.avatarBlurhash}" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:transitionDestinationUser="@{note.toShowNote.user}" @@ -285,6 +286,7 @@ android:scaleType="centerCrop" app:iconShape="@{note.config.avatarIconShapeType.value}" app:imageUrl="@{note.subNoteAvatarUrl}" + app:blurhash="@{note.subNote.user.avatarBlurhash}" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:transitionDestinationUser="@{note.subNote.user}" /> diff --git a/modules/features/user/src/main/res/layout/activity_user_detail.xml b/modules/features/user/src/main/res/layout/activity_user_detail.xml index c8ca34453c..9c13e0c802 100644 --- a/modules/features/user/src/main/res/layout/activity_user_detail.xml +++ b/modules/features/user/src/main/res/layout/activity_user_detail.xml @@ -99,6 +99,7 @@ android:layout_marginTop="-50dp" android:layout_marginStart="16dp" app:imageUrl="@{userViewModel.userState.avatarUrl}" + app:blurhash="@{userViewModel.userState.avatarBlurhash}" app:iconShape="@{userViewModel.config.avatarIconShapeType.value}" tools:srcCompat="@drawable/ic_follow" android:layout_marginBottom="8dp"