From f9668745508047793d32bacf2da0ad50468a1626 Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 11 Jan 2023 16:51:42 +0100 Subject: [PATCH] Some fixes --- .../fedilab/android/ui/drawer/StatusAdapter.java | 16 +++++++--------- .../timeline/FragmentMastodonTimeline.java | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java index 2d143993..dbde407b 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java @@ -48,7 +48,6 @@ import android.os.Looper; import android.text.Html; import android.text.SpannableString; import android.text.TextUtils; -import android.util.Log; import android.util.TypedValue; import android.view.LayoutInflater; import android.view.MotionEvent; @@ -137,7 +136,9 @@ import app.fedilab.android.databinding.LayoutMediaBinding; import app.fedilab.android.databinding.LayoutPollItemBinding; import app.fedilab.android.exception.DBException; import app.fedilab.android.helper.CrossActionHelper; +import app.fedilab.android.helper.GlideApp; import app.fedilab.android.helper.GlideFocus; +import app.fedilab.android.helper.GlideRequests; import app.fedilab.android.helper.Helper; import app.fedilab.android.helper.LongClickLinkMovementMethod; import app.fedilab.android.helper.MastodonHelper; @@ -2099,9 +2100,9 @@ public class StatusAdapter extends RecyclerView.Adapter } boolean expand_media = sharedpreferences.getBoolean(context.getString(R.string.SET_EXPAND_MEDIA), false); RequestBuilder requestBuilder; + GlideRequests glideRequests = GlideApp.with(context); if (!isSensitive || expand_media) { - requestBuilder = Glide.with(context) - .load(attachment.preview_url); + requestBuilder = glideRequests.asDrawable(); if (!fullAttachement) { requestBuilder = requestBuilder.apply(new RequestOptions().transform(new GlideFocus(focusX, focusY))); requestBuilder = requestBuilder.dontAnimate(); @@ -2112,8 +2113,7 @@ public class StatusAdapter extends RecyclerView.Adapter requestBuilder = requestBuilder.fitCenter(); } } else { - requestBuilder = Glide.with(context) - .load(attachment.preview_url) + requestBuilder = glideRequests.asDrawable() .dontAnimate() .apply(new RequestOptions().transform(new BlurTransformation(50, 3))); // .apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners((int) Helper.convertDpToPixel(3, context)))) @@ -2193,7 +2193,7 @@ public class StatusAdapter extends RecyclerView.Adapter } else { layoutMediaBinding.viewHide.setImageResource(R.drawable.ic_baseline_visibility_off_24); } - requestBuilder.into(layoutMediaBinding.media); + requestBuilder.load(attachment.preview_url).into(layoutMediaBinding.media); if (statusToDeal.sensitive) { Helper.changeDrawableColor(context, layoutMediaBinding.viewHide, ThemeHelper.getAttColor(context, R.attr.colorError)); } else { @@ -2268,7 +2268,6 @@ public class StatusAdapter extends RecyclerView.Adapter } } } - Log.v(Helper.TAG, position + " - getPreloadItems: " + attachments.size()); return attachments; } @@ -2287,8 +2286,7 @@ public class StatusAdapter extends RecyclerView.Adapter mediaH = attachment.meta.small.height; mediaW = attachment.meta.small.width; } - Log.v(Helper.TAG, "getPreloadRequestBuilder: " + attachment); - return prepareRequestBuilder(context, attachment, mediaW, mediaH, focusX, focusY, attachment.sensitive, timelineType == Timeline.TimeLineEnum.ART); + return prepareRequestBuilder(context, attachment, mediaW, mediaH, focusX, focusY, attachment.sensitive, timelineType == Timeline.TimeLineEnum.ART).load(attachment); } /** diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java index a293613f..d4a84a5f 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java @@ -88,7 +88,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. private StatusAdapter statusAdapter; private Timeline.TimeLineEnum timelineType; private List timelineStatuses; - private static final int PRELOAD_AHEAD_ITEMS = 5; + private static final int PRELOAD_AHEAD_ITEMS = 10; private ViewPreloadSizeProvider preloadSizeProvider; //Handle actions that can be done in other fragments private final BroadcastReceiver receive_action = new BroadcastReceiver() {