Fix MP4 Gif crash with ConversationUpdateItem

Due to adapter positions changing due to deletes and other such
nonsense, there are cases where update items are all of a sudden in our
playing or notplaying arrays. Checking for playable content before
trying to update positioning information seems to have fixed the issue.
This commit is contained in:
Alex Hart 2021-08-06 16:37:33 -03:00
parent 0762a93787
commit 89af85c893
2 changed files with 12 additions and 5 deletions

View file

@ -512,7 +512,7 @@ public class ConversationFragment extends LoggingFragment {
private void onViewHolderPositionTranslated(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
if (viewHolder instanceof GiphyMp4Playable) {
giphyMp4ProjectionRecycler.updateDisplay(recyclerView, (GiphyMp4Playable) viewHolder);
giphyMp4ProjectionRecycler.updateVideoDisplayPositionAndSize(recyclerView, (GiphyMp4Playable) viewHolder);
}
if (colorizer != null) {

View file

@ -46,14 +46,14 @@ public final class GiphyMp4ProjectionRecycler implements GiphyMp4PlaybackControl
}
for (final GiphyMp4Playable holder : holders) {
updateDisplay(recyclerView, holder);
updateVideoDisplayPositionAndSize(recyclerView, holder);
}
}
public void updateDisplay(@NonNull RecyclerView recyclerView, @NonNull GiphyMp4Playable holder) {
public void updateVideoDisplayPositionAndSize(@NonNull RecyclerView recyclerView, @NonNull GiphyMp4Playable holder) {
GiphyMp4ProjectionPlayerHolder playerHolder = getCurrentHolder(holder.getAdapterPosition());
if (playerHolder != null) {
updateDisplay(recyclerView, playerHolder, holder);
updateVideoDisplayPositionAndSize(recyclerView, playerHolder, holder);
}
}
@ -84,7 +84,14 @@ public final class GiphyMp4ProjectionRecycler implements GiphyMp4PlaybackControl
}
}
private void updateDisplay(@NonNull RecyclerView recyclerView, @NonNull GiphyMp4ProjectionPlayerHolder holder, @NonNull GiphyMp4Playable giphyMp4Playable) {
private void updateVideoDisplayPositionAndSize(@NonNull RecyclerView recyclerView,
@NonNull GiphyMp4ProjectionPlayerHolder holder,
@NonNull GiphyMp4Playable giphyMp4Playable)
{
if (!giphyMp4Playable.canPlayContent()) {
return;
}
Projection projection = giphyMp4Playable.getGiphyMp4PlayableProjection(recyclerView);
holder.getContainer().setX(projection.getX());