1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-14 02:37:30 +00:00

reading exact child from dm media shares

https://t.me/barinsta_app/21890
This commit is contained in:
Austin Huang 2021-06-28 16:14:28 -04:00
parent 3f6ed5f78b
commit 8bf9f5f2cc
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
9 changed files with 29 additions and 15 deletions

View File

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

View File

@ -68,16 +68,27 @@ public class DirectItemMediaShareViewHolder extends DirectItemViewHolder {
setupTitle(media); setupTitle(media);
setupCaption(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(() -> { itemView.post(() -> {
final MediaItemType mediaType = media.getMediaType();
setupTypeIndicator(mediaType); setupTypeIndicator(mediaType);
if (mediaType == MediaItemType.MEDIA_TYPE_SLIDER) { setupPreview(toDisplay, messageDirection);
setupPreview(media.getCarouselMedia().get(0), messageDirection);
return;
}
setupPreview(media, messageDirection);
}); });
itemView.setOnClickListener(v -> openMedia(media)); itemView.setOnClickListener(v -> openMedia(media, index));
} }
private void setupTypeIndicator(final MediaItemType mediaType) { private void setupTypeIndicator(final MediaItemType mediaType) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -38,7 +38,8 @@ data class Media(
var isSidecarChild: Boolean = false, var isSidecarChild: Boolean = false,
var hasViewerSaved: Boolean = false, var hasViewerSaved: Boolean = false,
private val injected: Map<String, Any>? = null, 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 { ) : Serializable {
private var dateString: String? = null private var dateString: String? = null

View File

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