mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 00:29:11 +01:00
Fix gif display when list is changed and view holders are not reused.
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user