Fix gif display when list is changed and view holders are not reused.

fork-5.53.8
Alex Hart 2021-09-20 11:19:33 -03:00
rodzic 82c12c2f6b
commit ccc96d5bfa
4 zmienionych plików z 11 dodań i 3 usunięć

Wyświetl plik

@ -302,8 +302,6 @@ public class ConversationFragment extends LoggingFragment implements Multiselect
typingView = (ConversationTypingView) inflater.inflate(R.layout.conversation_typing_view, container, false);
giphyMp4ProjectionRecycler = initializeGiphyMp4();
new ConversationItemSwipeCallback(
conversationMessage -> actionMode == null &&
MenuState.canReplyToMessage(recipient.get(),
@ -316,6 +314,7 @@ public class ConversationFragment extends LoggingFragment implements Multiselect
).attachToRecyclerView(list);
setupListLayoutListeners();
giphyMp4ProjectionRecycler = initializeGiphyMp4();
this.groupViewModel = ViewModelProviders.of(requireActivity(), new ConversationGroupViewModel.Factory()).get(ConversationGroupViewModel.class);
this.messageCountsViewModel = ViewModelProviders.of(requireActivity()).get(MessageCountsViewModel.class);

Wyświetl plik

@ -61,6 +61,9 @@ public final class GiphyMp4ProjectionPlayerHolder implements Player.Listener {
public void setOnPlaybackReady(@Nullable Runnable onPlaybackReady) {
this.onPlaybackReady = onPlaybackReady;
if (onPlaybackReady != null && player.getPlaybackState() == Player.STATE_READY) {
onPlaybackReady.run();
}
}
public void hide() {

Wyświetl plik

@ -95,7 +95,7 @@ public final class GiphyMp4ProjectionRecycler implements GiphyMp4PlaybackControl
Projection projection = giphyMp4Playable.getGiphyMp4PlayableProjection(recyclerView);
holder.getContainer().setX(projection.getX());
holder.getContainer().setY(projection.getY());
holder.getContainer().setY(projection.getY() + recyclerView.getTranslationY());
ViewGroup.LayoutParams params = holder.getContainer().getLayoutParams();
if (params.width != projection.getWidth() || params.height != projection.getHeight()) {
@ -115,6 +115,8 @@ public final class GiphyMp4ProjectionRecycler implements GiphyMp4PlaybackControl
holder.show();
holder.setOnPlaybackReady(giphyMp4Playable::hideProjectionArea);
holder.playContent(giphyMp4Playable.getMediaItem(), giphyMp4Playable.getPlaybackPolicyEnforcer());
} else {
holder.setOnPlaybackReady(giphyMp4Playable::hideProjectionArea);
}
}

Wyświetl plik

@ -69,6 +69,10 @@ public final class GiphyMp4VideoPlayer extends FrameLayout implements DefaultLif
this.exoPlayer = exoPlayer;
}
int getPlaybackState() {
return exoPlayer.getPlaybackState();
}
void setVideoItem(@NonNull MediaItem mediaItem) {
exoPlayer.setMediaItem(mediaItem);
exoPlayer.prepare();