Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ public class VideoDetailFragment
private ImageView thumbnailImageView;
private ImageView thumbnailPlayButton;
private AnimatedProgressBar positionView;
private ViewGroup playerPlaceholder;

private View videoTitleRoot;
private TextView videoTitleTextView;
Expand Down Expand Up @@ -705,6 +706,7 @@ protected void initViews(final View rootView, final Bundle savedInstanceState) {
thumbnailBackgroundButton = rootView.findViewById(R.id.detail_thumbnail_root_layout);
thumbnailImageView = rootView.findViewById(R.id.detail_thumbnail_image_view);
thumbnailPlayButton = rootView.findViewById(R.id.detail_thumbnail_play_button);
playerPlaceholder = rootView.findViewById(R.id.player_placeholder);

contentRootLayoutHiding = rootView.findViewById(R.id.detail_content_root_hiding);

Expand Down Expand Up @@ -1265,17 +1267,15 @@ private void addVideoPlayerView() {
return;
}

final FrameLayout viewHolder = getView().findViewById(R.id.player_placeholder);

// Check if viewHolder already contains a child
if (player.getRootView().getParent() != viewHolder) {
if (player.getRootView().getParent() != playerPlaceholder) {
removeVideoPlayerView();
}
setHeightThumbnail();

// Prevent from re-adding a view multiple times
if (player.getRootView().getParent() == null) {
viewHolder.addView(player.getRootView());
playerPlaceholder.addView(player.getRootView());
}
}

Expand All @@ -1290,9 +1290,8 @@ private void makeDefaultHeightForVideoPlaceholder() {
return;
}

final FrameLayout viewHolder = getView().findViewById(R.id.player_placeholder);
viewHolder.getLayoutParams().height = FrameLayout.LayoutParams.MATCH_PARENT;
viewHolder.requestLayout();
playerPlaceholder.getLayoutParams().height = FrameLayout.LayoutParams.MATCH_PARENT;
playerPlaceholder.requestLayout();
}

private void prepareDescription(final Description description) {
Expand Down Expand Up @@ -1770,9 +1769,19 @@ private void updateProgressInfo(@NonNull final StreamInfo info) {
private void showPlaybackProgress(final long progress, final long duration) {
final int progressSeconds = (int) TimeUnit.MILLISECONDS.toSeconds(progress);
final int durationSeconds = (int) TimeUnit.MILLISECONDS.toSeconds(duration);
// If the old and the new progress values have a big difference then use
// animation. Otherwise don't because it affects CPU
final boolean shouldAnimate = Math.abs(positionView.getProgress() - progressSeconds) > 2;
positionView.setMax(durationSeconds);
positionView.setProgressAnimated(progressSeconds);
detailPositionView.setText(Localization.getDurationString(progressSeconds));
if (shouldAnimate) {
positionView.setProgressAnimated(progressSeconds);
} else {
positionView.setProgress(progressSeconds);
}
final String position = Localization.getDurationString(progressSeconds);
if (position != detailPositionView.getText()) {
detailPositionView.setText(position);
}
if (positionView.getVisibility() != View.VISIBLE) {
animateView(positionView, true, 100);
animateView(detailPositionView, true, 100);
Expand Down Expand Up @@ -1949,7 +1958,7 @@ public void onMoreOptionsLongClicked() {
(CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams();
final AppBarLayout.Behavior behavior = (AppBarLayout.Behavior) params.getBehavior();
final ValueAnimator valueAnimator = ValueAnimator
.ofInt(0, -getView().findViewById(R.id.player_placeholder).getHeight());
.ofInt(0, -playerPlaceholder.getHeight());
valueAnimator.setInterpolator(new DecelerateInterpolator());
valueAnimator.addUpdateListener(animation -> {
behavior.setTopAndBottomOffset((int) animation.getAnimatedValue());
Expand Down