mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-21 22:27:29 +00:00
reading exact child from dm media shares
https://t.me/barinsta_app/21890
This commit is contained in:
parent
3f6ed5f78b
commit
8bf9f5f2cc
@ -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
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user