From 449eac0d991296e3a56d8a3eec356f642947cb2b Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 10 Sep 2021 18:14:39 +0200 Subject: [PATCH] Fix annoying issue detected by lint (CheckResult) and consider that's errors from now --- vector/lint.xml | 1 + .../im/vector/app/features/home/AvatarRenderer.kt | 12 ++++++------ .../roomdirectory/picker/RoomDirectoryItem.kt | 6 ++++-- .../roomprofile/settings/RoomSettingsViewModel.kt | 1 + 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/vector/lint.xml b/vector/lint.xml index a8eed30160..3fca617dee 100644 --- a/vector/lint.xml +++ b/vector/lint.xml @@ -47,6 +47,7 @@ + diff --git a/vector/src/main/java/im/vector/app/features/home/AvatarRenderer.kt b/vector/src/main/java/im/vector/app/features/home/AvatarRenderer.kt index d22707bda0..2ee3233637 100644 --- a/vector/src/main/java/im/vector/app/features/home/AvatarRenderer.kt +++ b/vector/src/main/java/im/vector/app/features/home/AvatarRenderer.kt @@ -138,13 +138,13 @@ class AvatarRenderer @Inject constructor(private val activeSessionHolder: Active target: Target) { val placeholder = getPlaceholderDrawable(matrixItem) glideRequests.loadResolvedUrl(matrixItem.avatarUrl) - .apply { + .let { when (matrixItem) { is MatrixItem.SpaceItem -> { - transform(MultiTransformation(CenterCrop(), RoundedCorners(dimensionConverter.dpToPx(8)))) + it.transform(MultiTransformation(CenterCrop(), RoundedCorners(dimensionConverter.dpToPx(8)))) } else -> { - apply(RequestOptions.circleCropTransform()) + it.apply(RequestOptions.circleCropTransform()) } } } @@ -157,13 +157,13 @@ class AvatarRenderer @Inject constructor(private val activeSessionHolder: Active fun shortcutDrawable(glideRequests: GlideRequests, matrixItem: MatrixItem, iconSize: Int): Bitmap { return glideRequests .asBitmap() - .apply { + .let { val resolvedUrl = resolvedUrl(matrixItem.avatarUrl) if (resolvedUrl != null) { - load(resolvedUrl) + it.load(resolvedUrl) } else { val avatarColor = matrixItemColorProvider.getColor(matrixItem) - load(TextDrawable.builder() + it.load(TextDrawable.builder() .beginConfig() .bold() .endConfig() diff --git a/vector/src/main/java/im/vector/app/features/roomdirectory/picker/RoomDirectoryItem.kt b/vector/src/main/java/im/vector/app/features/roomdirectory/picker/RoomDirectoryItem.kt index db1ba95e9e..e898bb2230 100644 --- a/vector/src/main/java/im/vector/app/features/roomdirectory/picker/RoomDirectoryItem.kt +++ b/vector/src/main/java/im/vector/app/features/roomdirectory/picker/RoomDirectoryItem.kt @@ -60,9 +60,11 @@ abstract class RoomDirectoryItem : VectorEpoxyModel() // Avatar GlideApp.with(holder.avatarView) .load(directoryAvatarUrl) - .apply { + .let { if (!includeAllNetworks) { - placeholder(R.drawable.network_matrix) + it.placeholder(R.drawable.network_matrix) + } else { + it } } .into(holder.avatarView) diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/settings/RoomSettingsViewModel.kt b/vector/src/main/java/im/vector/app/features/roomprofile/settings/RoomSettingsViewModel.kt index 1265e7e5ee..e872a04d80 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/settings/RoomSettingsViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/settings/RoomSettingsViewModel.kt @@ -312,6 +312,7 @@ class RoomSettingsViewModel @AssistedInject constructor(@Assisted initialState: _viewEvents.post(RoomSettingsViewEvents.Failure(it)) } ) + .disposeOnClear() } private fun postLoading(isLoading: Boolean) {