From 411a0c2560bb9e9629c006663860dd949157d7cc Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Tue, 7 Mar 2017 19:58:29 +0800 Subject: [PATCH] fixed profile image preview in settings --- .../twidere/view/ShapedImageView.java | 1 + .../twidere/extension/GlideExtensions.kt | 33 ++++++------------- .../twidere/view/holder/StatusViewHolder.kt | 4 +-- 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/twidere/src/main/java/org/mariotaku/twidere/view/ShapedImageView.java b/twidere/src/main/java/org/mariotaku/twidere/view/ShapedImageView.java index 8869d2e1d..ccdde5b8c 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/view/ShapedImageView.java +++ b/twidere/src/main/java/org/mariotaku/twidere/view/ShapedImageView.java @@ -138,6 +138,7 @@ public class ShapedImageView extends AppCompatImageView { public void setStyle(@ImageShapeStyle final int style) { mStyle = style; + initOutlineProvider(); } public void setBorderColor(int color) { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/extension/GlideExtensions.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/extension/GlideExtensions.kt index 9b65ddaf8..f79d54c61 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/extension/GlideExtensions.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/extension/GlideExtensions.kt @@ -34,13 +34,8 @@ import org.mariotaku.twidere.util.Utils import org.mariotaku.twidere.util.glide.RoundedRectTransformation import org.mariotaku.twidere.view.ShapedImageView -fun RequestManager.loadProfileImage( - context: Context, - url: String?, - @ImageShapeStyle style: Int, - cornerRadius: Float = 0f, cornerRadiusRatio: Float = 0f, - size: String? = null -): DrawableRequestBuilder { +fun RequestManager.loadProfileImage(context: Context, url: String?, @ImageShapeStyle style: Int, + cornerRadius: Float = 0f, cornerRadiusRatio: Float = 0f, size: String? = null): DrawableRequestBuilder { return configureLoadProfileImage(context, style, cornerRadius, cornerRadiusRatio) { if (url == null || size == null) { return@configureLoadProfileImage load(url) @@ -50,23 +45,18 @@ fun RequestManager.loadProfileImage( } } -fun RequestManager.loadProfileImage(context: Context, resourceId: Int, - @ImageShapeStyle shapeStyle: Int, +fun RequestManager.loadProfileImage(context: Context, resourceId: Int, @ImageShapeStyle shapeStyle: Int, cornerRadius: Float = 0f, cornerRadiusRatio: Float = 0f): DrawableRequestBuilder { return configureLoadProfileImage(context, shapeStyle, cornerRadius, cornerRadiusRatio) { load(resourceId) } } -fun RequestManager.loadProfileImage(context: Context, account: AccountDetails, - @ImageShapeStyle shapeStyle: Int, - cornerRadius: Float = 0f, cornerRadiusRatio: Float = 0f, - size: String? = null): DrawableRequestBuilder { +fun RequestManager.loadProfileImage(context: Context, account: AccountDetails, @ImageShapeStyle shapeStyle: Int, + cornerRadius: Float = 0f, cornerRadiusRatio: Float = 0f, size: String? = null): DrawableRequestBuilder { return loadProfileImage(context, account.user, shapeStyle, cornerRadius, cornerRadiusRatio, size) } -fun RequestManager.loadProfileImage(context: Context, user: ParcelableUser, - @ImageShapeStyle shapeStyle: Int, - cornerRadius: Float = 0f, cornerRadiusRatio: Float = 0f, - size: String? = null): DrawableRequestBuilder { +fun RequestManager.loadProfileImage(context: Context, user: ParcelableUser, @ImageShapeStyle shapeStyle: Int, + cornerRadius: Float = 0f, cornerRadiusRatio: Float = 0f, size: String? = null): DrawableRequestBuilder { if (user.extras != null && user.extras.profile_image_url_fallback == null) { // No fallback image, use compatible logic return loadProfileImage(context, user.profile_image_url, shapeStyle, cornerRadius, @@ -97,10 +87,8 @@ fun RequestManager.loadProfileImage(context: Context, group: ParcelableGroup, } } -fun RequestManager.loadProfileImage(context: Context, status: ParcelableStatus, - @ImageShapeStyle shapeStyle: Int, - cornerRadius: Float = 0f, cornerRadiusRatio: Float = 0f, - size: String? = null): DrawableRequestBuilder { +fun RequestManager.loadProfileImage(context: Context, status: ParcelableStatus, @ImageShapeStyle shapeStyle: Int, + cornerRadius: Float = 0f, cornerRadiusRatio: Float = 0f, size: String? = null): DrawableRequestBuilder { if (status.extras != null && status.extras.user_profile_image_url_fallback == null) { // No fallback image, use compatible logic return loadProfileImage(context, status.user_profile_image_url, shapeStyle, cornerRadius, @@ -112,8 +100,7 @@ fun RequestManager.loadProfileImage(context: Context, status: ParcelableStatus, } fun RequestManager.loadProfileImage(context: Context, conversation: ParcelableMessageConversation, - @ImageShapeStyle shapeStyle: Int, - cornerRadius: Float = 0f, cornerRadiusRatio: Float = 0f, + @ImageShapeStyle shapeStyle: Int, cornerRadius: Float = 0f, cornerRadiusRatio: Float = 0f, size: String? = null): DrawableRequestBuilder<*> { if (conversation.conversation_type == ParcelableMessageConversation.ConversationType.ONE_TO_ONE) { val user = conversation.user diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/StatusViewHolder.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/StatusViewHolder.kt index f510279de..e1c50dcc4 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/StatusViewHolder.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/StatusViewHolder.kt @@ -91,8 +91,6 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View) itemView.quotedMediaPreview) } - profileImageView.style = adapter.profileImageStyle - } @@ -506,6 +504,8 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View) fun setupViewOptions() { setTextSize(adapter.textSize) + profileImageView.style = adapter.profileImageStyle + mediaPreview.style = adapter.mediaPreviewStyle quotedMediaPreview.style = adapter.mediaPreviewStyle // profileImageView.setStyle(adapter.getProfileImageStyle());