Ammar Githam
4 years ago
26 changed files with 140 additions and 215 deletions
-
8app/build.gradle
-
38app/src/main/java/awais/instagrabber/adapters/DirectMessageMembersAdapter.java
-
38app/src/main/java/awais/instagrabber/adapters/FollowAdapter.java
-
23app/src/main/java/awais/instagrabber/adapters/PostsMediaAdapter.java
-
48app/src/main/java/awais/instagrabber/adapters/viewholder/FollowsViewHolder.java
-
25app/src/main/java/awais/instagrabber/adapters/viewholder/PostMediaViewHolder.java
-
8app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageAnimatedMediaViewHolder.java
-
18app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageItemViewHolder.java
-
2app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageLinkViewHolder.java
-
8app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageMediaShareViewHolder.java
-
4app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageMediaViewHolder.java
-
7app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageProfileViewHolder.java
-
4app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageRavenMediaViewHolder.java
-
4app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageReelShareViewHolder.java
-
5app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectMessageStoryShareViewHolder.java
-
45app/src/main/java/awais/instagrabber/customviews/helpers/PauseGlideOnFlingScrollListener.java
-
12app/src/main/java/awais/instagrabber/fragments/FollowViewerFragment.java
-
4app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageSettingsFragment.java
-
6app/src/main/res/layout/item_child_post.xml
-
12app/src/main/res/layout/item_follow.xml
-
6app/src/main/res/layout/layout_dm_animated_media.xml
-
6app/src/main/res/layout/layout_dm_link.xml
-
6app/src/main/res/layout/layout_dm_media.xml
-
6app/src/main/res/layout/layout_dm_media_share.xml
-
6app/src/main/res/layout/layout_dm_raven_media.xml
-
6app/src/main/res/layout/layout_dm_story_share.xml
@ -1,23 +1,45 @@ |
|||
package awais.instagrabber.adapters.viewholder; |
|||
|
|||
import android.view.View; |
|||
import android.widget.ImageView; |
|||
import android.widget.TextView; |
|||
|
|||
import androidx.annotation.NonNull; |
|||
import androidx.recyclerview.widget.RecyclerView; |
|||
|
|||
import awais.instagrabber.R; |
|||
import java.util.List; |
|||
|
|||
import awais.instagrabber.databinding.ItemFollowBinding; |
|||
import awais.instagrabber.models.FollowModel; |
|||
import awais.instagrabber.models.ProfileModel; |
|||
|
|||
public final class FollowsViewHolder extends RecyclerView.ViewHolder { |
|||
public final ImageView profileImage, isAdmin; |
|||
public final TextView tvFullName, tvUsername; |
|||
|
|||
public FollowsViewHolder(@NonNull final View itemView) { |
|||
super(itemView); |
|||
profileImage = itemView.findViewById(R.id.ivProfilePic); |
|||
tvFullName = itemView.findViewById(R.id.tvFullName); |
|||
tvUsername = itemView.findViewById(R.id.tvUsername); |
|||
isAdmin = itemView.findViewById(R.id.isAdmin); |
|||
|
|||
private final ItemFollowBinding binding; |
|||
|
|||
public FollowsViewHolder(final ItemFollowBinding binding) { |
|||
super(binding.getRoot()); |
|||
this.binding = binding; |
|||
} |
|||
|
|||
public void bind(final ProfileModel model, |
|||
final List<Long> 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()); |
|||
} |
|||
} |
@ -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()); |
|||
} |
|||
} |
@ -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(); |
|||
} |
|||
} |
|||
} |
|||
} |
@ -1,6 +1,6 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<androidx.appcompat.widget.AppCompatImageView xmlns:android="http://schemas.android.com/apk/res/android" |
|||
<com.facebook.drawee.view.SimpleDraweeView xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:id="@+id/ivAnimatedMessage" |
|||
android:layout_width="wrap_content" |
|||
android:maxHeight="@dimen/dm_media_img_max_height" |
|||
android:layout_height="wrap_content" /> |
|||
android:layout_height="wrap_content" |
|||
android:maxHeight="@dimen/dm_media_img_max_height" /> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue