Browse Source

reading exact child from dm media shares

https://t.me/barinsta_app/21890
renovate/org.robolectric-robolectric-4.x
Austin Huang 4 years ago
parent
commit
8bf9f5f2cc
No known key found for this signature in database GPG Key ID: 84C23AA04587A91F
  1. 2
      app/src/main/java/awais/instagrabber/adapters/DirectItemsAdapter.java
  2. 25
      app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemMediaShareViewHolder.java
  3. 2
      app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemMediaViewHolder.java
  4. 2
      app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemRavenMediaViewHolder.java
  5. 2
      app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemReelShareViewHolder.java
  6. 4
      app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemViewHolder.java
  7. 3
      app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageThreadFragment.java
  8. 3
      app/src/main/java/awais/instagrabber/repositories/responses/Media.kt
  9. 1
      app/src/main/java/awais/instagrabber/utils/ResponseBodyUtils.java

2
app/src/main/java/awais/instagrabber/adapters/DirectItemsAdapter.java

@ -401,7 +401,7 @@ public final class DirectItemsAdapter extends RecyclerView.Adapter<RecyclerView.
void onEmailClick(String email);
void onMediaClick(Media media);
void onMediaClick(Media media, int index);
void onStoryClick(DirectItemStoryShare storyShare);

25
app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemMediaShareViewHolder.java

@ -68,16 +68,27 @@ public class DirectItemMediaShareViewHolder extends DirectItemViewHolder {
setupTitle(media);
setupCaption(media);
});
final int index;
final Media toDisplay;
final MediaItemType mediaType = media.getMediaType();
switch (mediaType) {
case MEDIA_TYPE_SLIDER:
toDisplay = media.getCarouselMedia().stream()
.filter(m -> media.getCarouselShareChildMediaId() != null &&
media.getCarouselShareChildMediaId().equals(m.getId()))
.findAny()
.orElse(media.getCarouselMedia().get(0));
index = media.getCarouselMedia().indexOf(toDisplay);
break;
default:
toDisplay = media;
index = 0;
}
itemView.post(() -> {
final MediaItemType mediaType = media.getMediaType();
setupTypeIndicator(mediaType);
if (mediaType == MediaItemType.MEDIA_TYPE_SLIDER) {
setupPreview(media.getCarouselMedia().get(0), messageDirection);
return;
}
setupPreview(media, messageDirection);
setupPreview(toDisplay, messageDirection);
});
itemView.setOnClickListener(v -> openMedia(media));
itemView.setOnClickListener(v -> openMedia(media, index));
}
private void setupTypeIndicator(final MediaItemType mediaType) {

2
app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemMediaViewHolder.java

@ -47,7 +47,7 @@ public class DirectItemMediaViewHolder extends DirectItemViewHolder {
.setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP)
.build());
final Media media = directItemModel.getMedia();
itemView.setOnClickListener(v -> openMedia(media));
itemView.setOnClickListener(v -> openMedia(media, -1));
final MediaItemType modelMediaType = media.getMediaType();
binding.typeIcon.setVisibility(modelMediaType == MediaItemType.MEDIA_TYPE_VIDEO || modelMediaType == MediaItemType.MEDIA_TYPE_SLIDER
? View.VISIBLE

2
app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemRavenMediaViewHolder.java

@ -50,7 +50,7 @@ public class DirectItemRavenMediaViewHolder extends DirectItemViewHolder {
setPreview(visualMedia, messageDirection);
final boolean expired = TextUtils.isEmpty(media.getId());
if (expired) return;
itemView.setOnClickListener(v -> openMedia(media));
itemView.setOnClickListener(v -> openMedia(media, -1));
/*final boolean isExpired = visualMedia == null || (mediaModel = visualMedia.getMedia()) == null ||
TextUtils.isEmpty(mediaModel.getThumbUrl()) && mediaModel.getPk() < 1;

2
app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemReelShareViewHolder.java

@ -76,7 +76,7 @@ public class DirectItemReelShareViewHolder extends DirectItemViewHolder {
}
if (!expired) {
setPreview(media);
itemView.setOnClickListener(v -> openMedia(media));
itemView.setOnClickListener(v -> openMedia(media, -1));
}
}

4
app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemViewHolder.java

@ -501,8 +501,8 @@ public abstract class DirectItemViewHolder extends RecyclerView.ViewHolder imple
callback.onURLClick(url);
}
protected void openMedia(final Media media) {
callback.onMediaClick(media);
protected void openMedia(final Media media, final int index) {
callback.onMediaClick(media, index);
}
protected void openStory(final DirectItemStoryShare storyShare) {

3
app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageThreadFragment.java

@ -220,7 +220,7 @@ public class DirectMessageThreadFragment extends Fragment implements DirectReact
}
@Override
public void onMediaClick(final Media media) {
public void onMediaClick(final Media media, final int index) {
if (media.isReelMedia()) {
final String pk = media.getPk();
try {
@ -239,6 +239,7 @@ public class DirectMessageThreadFragment extends Fragment implements DirectReact
final NavController navController = NavHostFragment.findNavController(DirectMessageThreadFragment.this);
final Bundle bundle = new Bundle();
bundle.putSerializable(PostViewV2Fragment.ARG_MEDIA, media);
bundle.putInt(PostViewV2Fragment.ARG_SLIDER_POSITION, index);
try {
navController.navigate(R.id.action_global_post_view, bundle);
} catch (Exception e) {

3
app/src/main/java/awais/instagrabber/repositories/responses/Media.kt

@ -38,7 +38,8 @@ data class Media(
var isSidecarChild: Boolean = false,
var hasViewerSaved: Boolean = false,
private val injected: Map<String, Any>? = null,
val endOfFeedDemarcator: EndOfFeedDemarcator? = null
val endOfFeedDemarcator: EndOfFeedDemarcator? = null,
val carouselShareChildMediaId: String? = null // which specific child should dm show first
) : Serializable {
private var dateString: String? = null

1
app/src/main/java/awais/instagrabber/utils/ResponseBodyUtils.java

@ -271,6 +271,7 @@ public final class ResponseBodyUtils {
false,
false,
null,
null,
null
);
}

Loading…
Cancel
Save