Austin Huang
4 years ago
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
9 changed files with
29 additions and
15 deletions
-
app/src/main/java/awais/instagrabber/adapters/DirectItemsAdapter.java
-
app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemMediaShareViewHolder.java
-
app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemMediaViewHolder.java
-
app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemRavenMediaViewHolder.java
-
app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemReelShareViewHolder.java
-
app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemViewHolder.java
-
app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageThreadFragment.java
-
app/src/main/java/awais/instagrabber/repositories/responses/Media.kt
-
app/src/main/java/awais/instagrabber/utils/ResponseBodyUtils.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); |
|
|
|
|
|
|
|
|
|
@ -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) { |
|
|
|
|
|
@ -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 |
|
|
|
|
|
@ -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; |
|
|
|
|
|
|
|
|
|
@ -76,7 +76,7 @@ public class DirectItemReelShareViewHolder extends DirectItemViewHolder { |
|
|
|
} |
|
|
|
if (!expired) { |
|
|
|
setPreview(media); |
|
|
|
itemView.setOnClickListener(v -> openMedia(media)); |
|
|
|
itemView.setOnClickListener(v -> openMedia(media, -1)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -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) { |
|
|
|
|
|
@ -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) { |
|
|
|
|
|
@ -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 |
|
|
|
|
|
|
|
|
|
@ -271,6 +271,7 @@ public final class ResponseBodyUtils { |
|
|
|
false, |
|
|
|
false, |
|
|
|
null, |
|
|
|
null, |
|
|
|
null |
|
|
|
); |
|
|
|
} |
|
|
|