From e560fd364b20b6dcd1f2545cc314d9a54ea323b4 Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Sat, 12 Sep 2020 01:44:34 +0900 Subject: [PATCH] Migrate from Glide to Fresco --- app/build.gradle | 8 +--- .../adapters/DirectMessageMembersAdapter.java | 38 +++++---------- .../instagrabber/adapters/FollowAdapter.java | 38 ++++++--------- .../adapters/PostsMediaAdapter.java | 23 +++------- .../viewholder/FollowsViewHolder.java | 46 ++++++++++++++----- .../viewholder/PostMediaViewHolder.java | 25 ++++++---- .../DirectMessageAnimatedMediaViewHolder.java | 8 +++- .../DirectMessageItemViewHolder.java | 18 ++------ .../DirectMessageLinkViewHolder.java | 2 +- .../DirectMessageMediaShareViewHolder.java | 8 ++-- .../DirectMessageMediaViewHolder.java | 4 +- .../DirectMessageProfileViewHolder.java | 7 +-- .../DirectMessageRavenMediaViewHolder.java | 4 +- .../DirectMessageReelShareViewHolder.java | 4 +- .../DirectMessageStoryShareViewHolder.java | 5 +- .../PauseGlideOnFlingScrollListener.java | 45 ------------------ .../fragments/FollowViewerFragment.java | 12 ++--- .../DirectMessageSettingsFragment.java | 4 +- app/src/main/res/layout/item_child_post.xml | 6 +-- app/src/main/res/layout/item_follow.xml | 12 ++--- .../res/layout/layout_dm_animated_media.xml | 6 +-- app/src/main/res/layout/layout_dm_link.xml | 6 +-- app/src/main/res/layout/layout_dm_media.xml | 6 +-- .../main/res/layout/layout_dm_media_share.xml | 6 +-- .../main/res/layout/layout_dm_raven_media.xml | 6 +-- .../main/res/layout/layout_dm_story_share.xml | 6 +-- 26 files changed, 139 insertions(+), 214 deletions(-) delete mode 100644 app/src/main/java/awais/instagrabber/customviews/helpers/PauseGlideOnFlingScrollListener.java diff --git a/app/build.gradle b/app/build.gradle index 09c80872..650be3f0 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -45,24 +45,20 @@ dependencies { // For loading and tinting drawables on older versions of the platform implementation "androidx.appcompat:appcompat-resources:$appcompat_version" implementation "androidx.recyclerview:recyclerview:1.2.0-alpha05" - implementation 'com.google.android.material:material:1.2.0' + implementation 'com.google.android.material:material:1.2.1' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' implementation "androidx.viewpager2:viewpager2:1.0.0" implementation "androidx.navigation:navigation-fragment:$nav_version" implementation "androidx.navigation:navigation-ui:$nav_version" - implementation "androidx.constraintlayout:constraintlayout:2.0.0" + implementation "androidx.constraintlayout:constraintlayout:2.0.1" implementation "androidx.preference:preference:$preference_version" implementation 'org.jsoup:jsoup:1.13.1' - implementation 'com.github.bumptech.glide:glide:4.11.0' - implementation 'com.github.chrisbanes:PhotoView:v2.0.0' implementation 'com.google.android.exoplayer:exoplayer:2.11.1' implementation 'com.facebook.fresco:fresco:2.3.0' implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:converter-scalars:2.9.0' implementation 'com.squareup.retrofit2:converter-gson:2.9.0' - - annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0' } diff --git a/app/src/main/java/awais/instagrabber/adapters/DirectMessageMembersAdapter.java b/app/src/main/java/awais/instagrabber/adapters/DirectMessageMembersAdapter.java index 6920596b..01ed6bbd 100755 --- a/app/src/main/java/awais/instagrabber/adapters/DirectMessageMembersAdapter.java +++ b/app/src/main/java/awais/instagrabber/adapters/DirectMessageMembersAdapter.java @@ -1,6 +1,5 @@ package awais.instagrabber.adapters; -import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -8,52 +7,37 @@ import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; -import com.bumptech.glide.Glide; - import java.util.List; -import awais.instagrabber.R; import awais.instagrabber.adapters.viewholder.FollowsViewHolder; +import awais.instagrabber.databinding.ItemFollowBinding; import awais.instagrabber.models.ProfileModel; -public final class DirectMessageMembersAdapter extends RecyclerView.Adapter { +public final class DirectMessageMembersAdapter extends RecyclerView.Adapter { private final ProfileModel[] profileModels; private final List admins; private final View.OnClickListener onClickListener; - private final LayoutInflater layoutInflater; - public DirectMessageMembersAdapter(final ProfileModel[] profileModels, final List admins, - final Context context, final View.OnClickListener onClickListener) { + public DirectMessageMembersAdapter(final ProfileModel[] profileModels, + final List admins, + final View.OnClickListener onClickListener) { this.profileModels = profileModels; this.admins = admins; - this.layoutInflater = LayoutInflater.from(context); this.onClickListener = onClickListener; } @NonNull @Override - public RecyclerView.ViewHolder onCreateViewHolder(@NonNull final ViewGroup parent, final int viewType) { - final View view = layoutInflater.inflate(R.layout.item_follow, parent, false); - return new FollowsViewHolder(view); + public FollowsViewHolder onCreateViewHolder(@NonNull final ViewGroup parent, final int viewType) { + final LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext()); + final ItemFollowBinding binding = ItemFollowBinding.inflate(layoutInflater, parent, false); + return new FollowsViewHolder(binding); } @Override - public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, final int position) { + public void onBindViewHolder(@NonNull final FollowsViewHolder holder, final int position) { final ProfileModel model = profileModels[position]; - - final FollowsViewHolder followHolder = (FollowsViewHolder) holder; - if (model != null) { - followHolder.itemView.setTag(model); - followHolder.itemView.setOnClickListener(onClickListener); - - followHolder.tvUsername.setText(model.getUsername()); - followHolder.tvFullName.setText(model.getName()); - - if (admins != null && admins.contains(Long.parseLong(model.getId()))) - followHolder.isAdmin.setVisibility(View.VISIBLE); - - Glide.with(layoutInflater.getContext()).load(model.getSdProfilePic()).into(followHolder.profileImage); - } + holder.bind(model, admins, onClickListener); } @Override diff --git a/app/src/main/java/awais/instagrabber/adapters/FollowAdapter.java b/app/src/main/java/awais/instagrabber/adapters/FollowAdapter.java index b951e9aa..b11e0411 100755 --- a/app/src/main/java/awais/instagrabber/adapters/FollowAdapter.java +++ b/app/src/main/java/awais/instagrabber/adapters/FollowAdapter.java @@ -1,6 +1,5 @@ package awais.instagrabber.adapters; -import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -11,13 +10,12 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.recyclerview.widget.RecyclerView; -import com.bumptech.glide.Glide; - import java.util.ArrayList; import java.util.List; import awais.instagrabber.R; import awais.instagrabber.adapters.viewholder.FollowsViewHolder; +import awais.instagrabber.databinding.ItemFollowBinding; import awais.instagrabber.interfaces.OnGroupClickListener; import awais.instagrabber.models.FollowModel; import awais.instagrabber.utils.TextUtils; @@ -66,12 +64,10 @@ public final class FollowAdapter extends RecyclerView.Adapter groups) { - this.layoutInflater = LayoutInflater.from(context); + public FollowAdapter(final View.OnClickListener onClickListener, @NonNull final ArrayList groups) { this.expandableList = new ExpandableList(groups); this.onClickListener = onClickListener; this.hasManyGroups = groups.size() > 1; @@ -86,10 +82,15 @@ public final class FollowAdapter extends RecyclerView.Adapter { private final View.OnClickListener clickListener; - private LayoutInflater layoutInflater; private ViewerPostModel[] postModels; public PostsMediaAdapter(final ViewerPostModel[] postModels, final View.OnClickListener clickListener) { @@ -27,25 +25,16 @@ public final class PostsMediaAdapter extends RecyclerView.Adapter admins, + final View.OnClickListener onClickListener) { + if (model == null) return; + itemView.setTag(model); + itemView.setOnClickListener(onClickListener); + binding.tvUsername.setText(model.getUsername()); + binding.tvFullName.setText(model.getName()); + if (admins != null && admins.contains(Long.parseLong(model.getId()))) { + binding.isAdmin.setVisibility(View.VISIBLE); + } + binding.ivProfilePic.setImageURI(model.getSdProfilePic()); + } + + public void bind(final FollowModel model, + final View.OnClickListener onClickListener) { + if (model == null) return; + itemView.setTag(model); + itemView.setOnClickListener(onClickListener); + binding.tvUsername.setText(model.getUsername()); + binding.tvFullName.setText(model.getFullName()); + binding.ivProfilePic.setImageURI(model.getProfilePicUrl()); } } \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/adapters/viewholder/PostMediaViewHolder.java b/app/src/main/java/awais/instagrabber/adapters/viewholder/PostMediaViewHolder.java index 65d115bd..2c81475a 100755 --- a/app/src/main/java/awais/instagrabber/adapters/viewholder/PostMediaViewHolder.java +++ b/app/src/main/java/awais/instagrabber/adapters/viewholder/PostMediaViewHolder.java @@ -1,20 +1,29 @@ package awais.instagrabber.adapters.viewholder; import android.view.View; -import android.widget.ImageView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; -import awais.instagrabber.R; +import awais.instagrabber.databinding.ItemChildPostBinding; +import awais.instagrabber.models.ViewerPostModel; public final class PostMediaViewHolder extends RecyclerView.ViewHolder { - public final ImageView icon, isDownloaded, selectedView; - public PostMediaViewHolder(@NonNull final View itemView) { - super(itemView); - selectedView = itemView.findViewById(R.id.selectedView); - isDownloaded = itemView.findViewById(R.id.isDownloaded); - icon = itemView.findViewById(R.id.icon); + private final ItemChildPostBinding binding; + + public PostMediaViewHolder(@NonNull final ItemChildPostBinding binding) { + super(binding.getRoot()); + this.binding = binding; + } + + public void bind(final ViewerPostModel model, final int position, final View.OnClickListener clickListener) { + if (model == null) return; + model.setPosition(position); + itemView.setTag(model); + itemView.setOnClickListener(clickListener); + binding.selectedView.setVisibility(model.isCurrentSlide() ? View.VISIBLE : View.GONE); + binding.isDownloaded.setVisibility(model.isDownloaded() ? View.VISIBLE : View.GONE); + binding.icon.setImageURI(model.getSliderDisplayUrl()); } } diff --git a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageAnimatedMediaViewHolder.java b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageAnimatedMediaViewHolder.java index ed96398c..8f9f3f4e 100644 --- a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageAnimatedMediaViewHolder.java +++ b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageAnimatedMediaViewHolder.java @@ -4,6 +4,8 @@ import android.view.View; import androidx.annotation.NonNull; +import com.facebook.drawee.backends.pipeline.Fresco; + import awais.instagrabber.databinding.LayoutDmAnimatedMediaBinding; import awais.instagrabber.databinding.LayoutDmBaseBinding; import awais.instagrabber.models.direct_messages.DirectItemModel; @@ -22,8 +24,10 @@ public class DirectMessageAnimatedMediaViewHolder extends DirectMessageItemViewH @Override public void bindItem(final DirectItemModel directItemModel) { - getGlideRequestManager().asGif().load(directItemModel.getAnimatedMediaModel().getGifUrl()) - .into(binding.ivAnimatedMessage); + binding.ivAnimatedMessage.setController(Fresco.newDraweeControllerBuilder() + .setUri(directItemModel.getAnimatedMediaModel().getGifUrl()) + .setAutoPlayAnimations(true) + .build()); binding.ivAnimatedMessage.setVisibility(View.VISIBLE); } } diff --git a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageItemViewHolder.java b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageItemViewHolder.java index 75ef7689..747fd8ef 100644 --- a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageItemViewHolder.java +++ b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageItemViewHolder.java @@ -8,12 +8,8 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.recyclerview.widget.RecyclerView; -import com.bumptech.glide.Glide; -import com.bumptech.glide.RequestManager; - import java.util.List; -import awais.instagrabber.R; import awais.instagrabber.databinding.LayoutDmBaseBinding; import awais.instagrabber.models.ProfileModel; import awais.instagrabber.models.direct_messages.DirectItemModel; @@ -29,19 +25,15 @@ public abstract class DirectMessageItemViewHolder extends RecyclerView.ViewHolde private final ProfileModel myProfileHolder = ProfileModel.getDefaultProfileModel( CookieUtils.getUserIdFromCookie(Utils.settingsHelper.getString(Constants.COOKIE))); private final LayoutDmBaseBinding binding; - private final String strDmYou; private final int itemMargin; - private final RequestManager glideRequestManager; - public DirectMessageItemViewHolder(@NonNull final LayoutDmBaseBinding binding, @NonNull final View.OnClickListener onClickListener) { super(binding.getRoot()); this.binding = binding; binding.ivProfilePic.setOnClickListener(onClickListener); binding.messageCard.setOnClickListener(onClickListener); - strDmYou = binding.getRoot().getContext().getString(R.string.direct_messages_you); + // final String strDmYou = binding.getRoot().getContext().getString(R.string.direct_messages_you); itemMargin = Utils.displayMetrics.widthPixels / 5; - glideRequestManager = Glide.with(itemView); } public void bind(final DirectItemModel directItemModel, final List users, final List leftUsers) { @@ -50,7 +42,7 @@ public abstract class DirectMessageItemViewHolder extends RecyclerView.ViewHolde final RecyclerView.LayoutParams itemViewLayoutParams = (RecyclerView.LayoutParams) itemView.getLayoutParams(); itemViewLayoutParams.setMargins(type == MESSAGE_OUTGOING ? itemMargin : 0, 0, - type == MESSAGE_INCOMING ? itemMargin : 0, 0); + type == MESSAGE_INCOMING ? itemMargin : 0, 0); final ViewGroup messageCardParent = (ViewGroup) binding.messageCard.getParent(); binding.contentContainer.setGravity(type == MESSAGE_INCOMING ? Gravity.START : Gravity.END); @@ -69,7 +61,7 @@ public abstract class DirectMessageItemViewHolder extends RecyclerView.ViewHolde binding.messageCard.setTag(directItemModel); if (type == MESSAGE_INCOMING && user != null) { - glideRequestManager.load(user.getSdProfilePic()).into(binding.ivProfilePic); + binding.ivProfilePic.setImageURI(user.getSdProfilePic()); } bindItem(directItemModel); @@ -79,10 +71,6 @@ public abstract class DirectMessageItemViewHolder extends RecyclerView.ViewHolde this.binding.messageCard.addView(view); } - public RequestManager getGlideRequestManager() { - return glideRequestManager; - } - public abstract void bindItem(final DirectItemModel directItemModel); @Nullable diff --git a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageLinkViewHolder.java b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageLinkViewHolder.java index d48a1cc3..776c9355 100644 --- a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageLinkViewHolder.java +++ b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageLinkViewHolder.java @@ -29,7 +29,7 @@ public class DirectMessageLinkViewHolder extends DirectMessageItemViewHolder { if (TextUtils.isEmpty(linkImageUrl)) { binding.ivLinkPreview.setVisibility(View.GONE); } else { - getGlideRequestManager().load(linkImageUrl).into(binding.ivLinkPreview); + binding.ivLinkPreview.setImageURI(linkImageUrl); } if (TextUtils.isEmpty(linkContext.getLinkTitle())) { binding.tvLinkTitle.setVisibility(View.GONE); diff --git a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageMediaShareViewHolder.java b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageMediaShareViewHolder.java index e8840096..d788074d 100644 --- a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageMediaShareViewHolder.java +++ b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageMediaShareViewHolder.java @@ -34,11 +34,13 @@ public class DirectMessageMediaShareViewHolder extends DirectMessageItemViewHold final DirectItemMediaModel mediaModel = directItemModel.getMediaModel(); final ProfileModel modelUser = mediaModel.getUser(); if (modelUser != null) { - binding.tvMessage.setText(HtmlCompat.fromHtml("" + context.getString(R.string.dms_inbox_media_shared_from, modelUser.getUsername()) + "", FROM_HTML_MODE_COMPACT)); + binding.tvMessage.setText(HtmlCompat.fromHtml( + "" + context.getString(R.string.dms_inbox_media_shared_from, modelUser.getUsername()) + "", + FROM_HTML_MODE_COMPACT)); } - getGlideRequestManager().load(mediaModel.getThumbUrl()).into(binding.ivMediaPreview); + binding.ivMediaPreview.setImageURI(mediaModel.getThumbUrl()); final MediaItemType modelMediaType = mediaModel.getMediaType(); binding.typeIcon.setVisibility(modelMediaType == MediaItemType.MEDIA_TYPE_VIDEO - || modelMediaType == MediaItemType.MEDIA_TYPE_SLIDER ? View.VISIBLE : View.GONE); + || modelMediaType == MediaItemType.MEDIA_TYPE_SLIDER ? View.VISIBLE : View.GONE); } } diff --git a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageMediaViewHolder.java b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageMediaViewHolder.java index 3bbe8a87..8c6e0da6 100644 --- a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageMediaViewHolder.java +++ b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageMediaViewHolder.java @@ -24,9 +24,9 @@ public class DirectMessageMediaViewHolder extends DirectMessageItemViewHolder { @Override public void bindItem(final DirectItemModel directItemModel) { final DirectItemModel.DirectItemMediaModel mediaModel = directItemModel.getMediaModel(); - getGlideRequestManager().load(mediaModel.getThumbUrl()).into(binding.ivMediaPreview); + binding.ivMediaPreview.setImageURI(mediaModel.getThumbUrl()); final MediaItemType modelMediaType = mediaModel.getMediaType(); binding.typeIcon.setVisibility(modelMediaType == MediaItemType.MEDIA_TYPE_VIDEO - || modelMediaType == MediaItemType.MEDIA_TYPE_SLIDER ? View.VISIBLE : View.GONE); + || modelMediaType == MediaItemType.MEDIA_TYPE_SLIDER ? View.VISIBLE : View.GONE); } } diff --git a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageProfileViewHolder.java b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageProfileViewHolder.java index 1ebfae22..64f4d70b 100644 --- a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageProfileViewHolder.java +++ b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageProfileViewHolder.java @@ -4,8 +4,6 @@ import android.view.View; import androidx.annotation.NonNull; -import com.bumptech.glide.Glide; - import awais.instagrabber.databinding.LayoutDmBaseBinding; import awais.instagrabber.databinding.LayoutDmProfileBinding; import awais.instagrabber.models.ProfileModel; @@ -27,9 +25,8 @@ public class DirectMessageProfileViewHolder extends DirectMessageItemViewHolder @Override public void bindItem(final DirectItemModel directItemModel) { final ProfileModel profileModel = directItemModel.getProfileModel(); - Glide.with(binding.profileInfo) - .load(profileModel.getSdProfilePic()) - .into(binding.profileInfo); + if (profileModel == null) return; + binding.profileInfo.setImageURI(profileModel.getSdProfilePic()); binding.btnOpenProfile.setTag(profileModel); binding.tvFullName.setText(profileModel.getName()); binding.profileInfoText.setText(profileModel.getUsername()); diff --git a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageRavenMediaViewHolder.java b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageRavenMediaViewHolder.java index 5a7d59d7..fc7e404f 100644 --- a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageRavenMediaViewHolder.java +++ b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageRavenMediaViewHolder.java @@ -73,8 +73,8 @@ public class DirectMessageRavenMediaViewHolder extends DirectMessageItemViewHold final MediaItemType mediaType = mediaModel.getMediaType(); textRes = -1; binding.typeIcon.setVisibility(mediaType == MediaItemType.MEDIA_TYPE_VIDEO || - mediaType == MediaItemType.MEDIA_TYPE_SLIDER ? View.VISIBLE : View.GONE); - getGlideRequestManager().load(mediaModel.getThumbUrl()).into(binding.ivMediaPreview); + mediaType == MediaItemType.MEDIA_TYPE_SLIDER ? View.VISIBLE : View.GONE); + binding.ivMediaPreview.setImageURI(mediaModel.getThumbUrl()); } } if (textRes != -1) { diff --git a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageReelShareViewHolder.java b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageReelShareViewHolder.java index 25993e1f..ce027fc3 100644 --- a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageReelShareViewHolder.java +++ b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageReelShareViewHolder.java @@ -41,8 +41,8 @@ public class DirectMessageReelShareViewHolder extends DirectMessageItemViewHolde binding.mediaExpiredIcon.setVisibility(View.VISIBLE); } else { binding.typeIcon.setVisibility(mediaType == MediaItemType.MEDIA_TYPE_VIDEO || - mediaType == MediaItemType.MEDIA_TYPE_SLIDER ? View.VISIBLE : View.GONE); - getGlideRequestManager().load(reelShareMedia.getThumbUrl()).into(binding.ivMediaPreview); + mediaType == MediaItemType.MEDIA_TYPE_SLIDER ? View.VISIBLE : View.GONE); + binding.ivMediaPreview.setImageURI(reelShareMedia.getThumbUrl()); } } } diff --git a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageStoryShareViewHolder.java b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageStoryShareViewHolder.java index 28ca4332..e588bc3c 100644 --- a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageStoryShareViewHolder.java +++ b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageStoryShareViewHolder.java @@ -37,12 +37,11 @@ public class DirectMessageStoryShareViewHolder extends DirectMessageItemViewHold if (!TextUtils.isEmpty(text)) { binding.tvMessage.setText(text); binding.tvMessage.setVisibility(View.VISIBLE); - } - else { + } else { final DirectItemModel.DirectItemMediaModel reelShareMedia = reelShare.getMedia(); final MediaItemType mediaType = reelShareMedia.getMediaType(); binding.typeIcon.setVisibility(mediaType == MediaItemType.MEDIA_TYPE_VIDEO ? View.VISIBLE : View.GONE); - getGlideRequestManager().load(reelShareMedia.getThumbUrl()).into(binding.ivMediaPreview); + binding.ivMediaPreview.setImageURI(reelShareMedia.getThumbUrl()); } } } diff --git a/app/src/main/java/awais/instagrabber/customviews/helpers/PauseGlideOnFlingScrollListener.java b/app/src/main/java/awais/instagrabber/customviews/helpers/PauseGlideOnFlingScrollListener.java deleted file mode 100644 index 0249c1fa..00000000 --- a/app/src/main/java/awais/instagrabber/customviews/helpers/PauseGlideOnFlingScrollListener.java +++ /dev/null @@ -1,45 +0,0 @@ -package awais.instagrabber.customviews.helpers; - -import androidx.recyclerview.widget.RecyclerView; - -import com.bumptech.glide.RequestManager; - -import static androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_DRAGGING; -import static androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_IDLE; - -public class PauseGlideOnFlingScrollListener extends RecyclerView.OnScrollListener { - private static final int FLING_JUMP_LOW_THRESHOLD = 80; - private static final int FLING_JUMP_HIGH_THRESHOLD = 120; - - private final RequestManager glide; - private boolean dragging = false; - - public PauseGlideOnFlingScrollListener(final RequestManager glide) { - this.glide = glide; - } - - @Override - public void onScrollStateChanged(RecyclerView recyclerView, int newState) { - dragging = newState == SCROLL_STATE_DRAGGING; - if (glide.isPaused()) { - if (newState == SCROLL_STATE_DRAGGING || newState == SCROLL_STATE_IDLE) { - // user is touchy or the scroll finished, show images - glide.resumeRequests(); - } // settling means the user let the screen go, but it can still be flinging - } - } - - @Override - public void onScrolled(RecyclerView recyclerView, int dx, int dy) { - if (!dragging) { - // TODO can be made better by a rolling average of last N calls to smooth out patterns like a,b,a - int currentSpeed = Math.abs(dy); - boolean paused = glide.isPaused(); - if (paused && currentSpeed < FLING_JUMP_LOW_THRESHOLD) { - glide.resumeRequests(); - } else if (!paused && FLING_JUMP_HIGH_THRESHOLD < currentSpeed) { - glide.pauseRequests(); - } - } - } -} diff --git a/app/src/main/java/awais/instagrabber/fragments/FollowViewerFragment.java b/app/src/main/java/awais/instagrabber/fragments/FollowViewerFragment.java index 30a15e3c..4747fdda 100644 --- a/app/src/main/java/awais/instagrabber/fragments/FollowViewerFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/FollowViewerFragment.java @@ -345,15 +345,9 @@ public final class FollowViewerFragment extends Fragment implements SwipeRefresh final ExpandableGroup group = new ExpandableGroup(type, followModels); groups.add(group); } - - try { - adapter = new FollowAdapter(requireContext(), clickListener, groups); - adapter.toggleGroup(0); - binding.rvFollow.setAdapter(adapter); - } - catch (IllegalStateException e) { - // do nothing - } + adapter = new FollowAdapter(clickListener, groups); + adapter.toggleGroup(0); + binding.rvFollow.setAdapter(adapter); } public void stopCurrentExecutor() { diff --git a/app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageSettingsFragment.java b/app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageSettingsFragment.java index 8fc25ff0..fa453bbd 100644 --- a/app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageSettingsFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageSettingsFragment.java @@ -72,12 +72,12 @@ public class DirectMessageSettingsFragment extends Fragment implements SwipeRefr final boolean amAdmin = adminList.contains(Long.parseLong(userIdFromCookie)); final DirectMessageMembersAdapter memberAdapter = new DirectMessageMembersAdapter(threadModel.getUsers(), adminList, - requireContext(), amAdmin ? clickListener : basicClickListener); userList.setAdapter(memberAdapter); if (threadModel.getLeftUsers() != null && threadModel.getLeftUsers().length > 0) { leftTitle.setVisibility(View.VISIBLE); - final DirectMessageMembersAdapter leftAdapter = new DirectMessageMembersAdapter(threadModel.getLeftUsers(), null, requireContext(), + final DirectMessageMembersAdapter leftAdapter = new DirectMessageMembersAdapter(threadModel.getLeftUsers(), + null, basicClickListener); leftUserList.setAdapter(leftAdapter); } diff --git a/app/src/main/res/layout/item_child_post.xml b/app/src/main/res/layout/item_child_post.xml index 7305ee12..90c2174e 100755 --- a/app/src/main/res/layout/item_child_post.xml +++ b/app/src/main/res/layout/item_child_post.xml @@ -1,7 +1,6 @@ + android:foreground="?android:selectableItemBackground"> - diff --git a/app/src/main/res/layout/item_follow.xml b/app/src/main/res/layout/item_follow.xml index 646200df..de7a6825 100755 --- a/app/src/main/res/layout/item_follow.xml +++ b/app/src/main/res/layout/item_follow.xml @@ -1,14 +1,12 @@ + android:padding="8dp"> - + android:visibility="gone" + app:srcCompat="@drawable/ic_star" /> \ No newline at end of file diff --git a/app/src/main/res/layout/layout_dm_animated_media.xml b/app/src/main/res/layout/layout_dm_animated_media.xml index bdf2673a..f4598a38 100644 --- a/app/src/main/res/layout/layout_dm_animated_media.xml +++ b/app/src/main/res/layout/layout_dm_animated_media.xml @@ -1,6 +1,6 @@ - \ No newline at end of file + android:layout_height="wrap_content" + android:maxHeight="@dimen/dm_media_img_max_height" /> \ No newline at end of file diff --git a/app/src/main/res/layout/layout_dm_link.xml b/app/src/main/res/layout/layout_dm_link.xml index f7b63efe..ce47347e 100644 --- a/app/src/main/res/layout/layout_dm_link.xml +++ b/app/src/main/res/layout/layout_dm_link.xml @@ -13,11 +13,11 @@ android:textAppearance="@style/TextAppearance.AppCompat.Medium" android:textColor="?android:textColorPrimary" /> - + android:scaleType="centerCrop" /> \ No newline at end of file diff --git a/app/src/main/res/layout/layout_dm_media.xml b/app/src/main/res/layout/layout_dm_media.xml index b8ac3745..76894e52 100644 --- a/app/src/main/res/layout/layout_dm_media.xml +++ b/app/src/main/res/layout/layout_dm_media.xml @@ -4,12 +4,12 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - + android:adjustViewBounds="true" + android:maxHeight="@dimen/dm_media_img_max_height" /> - + android:adjustViewBounds="true" + android:maxHeight="@dimen/dm_media_img_max_height" /> - + android:adjustViewBounds="true" + android:maxHeight="@dimen/dm_media_img_max_height" /> - + android:adjustViewBounds="true" + android:maxHeight="@dimen/dm_media_img_max_height" />