Hide and show video players as content changes.

This commit is contained in:
Alex Hart
2021-04-26 15:03:06 -03:00
parent 8572a2d262
commit f89daefd43
3 changed files with 15 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.giph.mp4;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
@@ -63,6 +64,14 @@ public final class GiphyMp4ProjectionPlayerHolder implements Player.EventListene
this.onPlaybackReady = onPlaybackReady;
}
public void hide() {
container.setVisibility(View.GONE);
}
public void show() {
container.setVisibility(View.VISIBLE);
}
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
if (playbackState == Player.STATE_READY) {

View File

@@ -77,6 +77,10 @@ public final class GiphyMp4ProjectionRecycler implements GiphyMp4PlaybackControl
for (final Integer key : markedForDeletion) {
playing.remove(key);
}
for (int i = 0; i < notPlaying.size(); i++) {
notPlaying.valueAt(i).hide();
}
}
private void updateDisplay(@NonNull RecyclerView recyclerView, @NonNull GiphyMp4ProjectionPlayerHolder holder, @NonNull GiphyMp4Playable giphyMp4Playable) {
@@ -100,6 +104,7 @@ public final class GiphyMp4ProjectionRecycler implements GiphyMp4PlaybackControl
holder.setOnPlaybackReady(null);
giphyMp4Playable.showProjectionArea();
holder.show();
holder.setOnPlaybackReady(giphyMp4Playable::hideProjectionArea);
holder.playContent(giphyMp4Playable.getMediaSource(), giphyMp4Playable.getPlaybackPolicyEnforcer());
}

View File

@@ -24,6 +24,7 @@
style="@style/Signal.Text.Body"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:windowBackground"
android:gravity="center"
android:text="@string/giphy_fragment__nothing_found"
android:visibility="gone" />