From fcd3fbb661960614b3a52a9329ef8b68fefc554a Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Sun, 1 Oct 2023 11:05:29 -0400 Subject: Fix changing playback speed not working in ViewImgurVideoFragment and ViewRedditGalleryVideoFragment when using bottom app bar. --- .../activities/ViewVideoActivity.java | 24 +++++++++++----------- .../fragments/ViewImgurVideoFragment.java | 20 +++++++++++++----- .../fragments/ViewRedditGalleryVideoFragment.java | 19 ++++++++++++----- 3 files changed, 41 insertions(+), 22 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java index 224e8211..2b047074 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java @@ -171,7 +171,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe @BindView(R.id.download_image_view_exo_playback_control_view) MaterialButton downloadButton; @BindView(R.id.playback_speed_image_view_exo_playback_control_view) - MaterialButton playbackSpeedImageView; + MaterialButton playbackSpeedButton; @BindView(R.id.lockable_nested_scroll_view_view_video_activity) LockableNestedScrollView nestedScrollView; @@ -335,12 +335,8 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe requestPermissionAndDownload(); }); - playbackSpeedImageView.setOnClickListener(view -> { - PlaybackSpeedBottomSheetFragment playbackSpeedBottomSheetFragment = new PlaybackSpeedBottomSheetFragment(); - Bundle bundle = new Bundle(); - bundle.putInt(PlaybackSpeedBottomSheetFragment.EXTRA_PLAYBACK_SPEED, playbackSpeed); - playbackSpeedBottomSheetFragment.setArguments(bundle); - playbackSpeedBottomSheetFragment.show(getSupportFragmentManager(), playbackSpeedBottomSheetFragment.getTag()); + playbackSpeedButton.setOnClickListener(view -> { + changePlaybackSpeed(); }); } else { ActionBar actionBar = getSupportActionBar(); @@ -699,6 +695,14 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe }); } + private void changePlaybackSpeed() { + PlaybackSpeedBottomSheetFragment playbackSpeedBottomSheetFragment = new PlaybackSpeedBottomSheetFragment(); + Bundle bundle = new Bundle(); + bundle.putInt(PlaybackSpeedBottomSheetFragment.EXTRA_PLAYBACK_SPEED, playbackSpeed); + playbackSpeedBottomSheetFragment.setArguments(bundle); + playbackSpeedBottomSheetFragment.show(getSupportFragmentManager(), playbackSpeedBottomSheetFragment.getTag()); + } + private int inferPrimaryTrackType(Format format) { int trackType = MimeTypes.getTrackType(format.sampleMimeType); if (trackType != C.TRACK_TYPE_UNKNOWN) { @@ -936,11 +940,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe requestPermissionAndDownload(); return true; } else if (itemId == R.id.action_playback_speed_view_video_activity) { - PlaybackSpeedBottomSheetFragment playbackSpeedBottomSheetFragment = new PlaybackSpeedBottomSheetFragment(); - Bundle bundle = new Bundle(); - bundle.putInt(PlaybackSpeedBottomSheetFragment.EXTRA_PLAYBACK_SPEED, playbackSpeed); - playbackSpeedBottomSheetFragment.setArguments(bundle); - playbackSpeedBottomSheetFragment.show(getSupportFragmentManager(), playbackSpeedBottomSheetFragment.getTag()); + changePlaybackSpeed(); return true; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurVideoFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurVideoFragment.java index 06eb7673..0652515d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurVideoFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurVideoFragment.java @@ -76,6 +76,8 @@ public class ViewImgurVideoFragment extends Fragment { MaterialButton backButton; @BindView(R.id.download_image_view_exo_playback_control_view) MaterialButton downloadButton; + @BindView(R.id.playback_speed_image_view_exo_playback_control_view) + MaterialButton playbackSpeedButton; private ViewImgurMediaActivity activity; private ImgurMedia imgurMedia; private ExoPlayer player; @@ -180,11 +182,23 @@ public class ViewImgurVideoFragment extends Fragment { isDownloading = true; requestPermissionAndDownload(); }); + + playbackSpeedButton.setOnClickListener(view -> { + changePlaybackSpeed(); + }); } return rootView; } + private void changePlaybackSpeed() { + PlaybackSpeedBottomSheetFragment playbackSpeedBottomSheetFragment = new PlaybackSpeedBottomSheetFragment(); + Bundle bundle = new Bundle(); + bundle.putInt(PlaybackSpeedBottomSheetFragment.EXTRA_PLAYBACK_SPEED, playbackSpeed); + playbackSpeedBottomSheetFragment.setArguments(bundle); + playbackSpeedBottomSheetFragment.show(getChildFragmentManager(), playbackSpeedBottomSheetFragment.getTag()); + } + @Override public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) { inflater.inflate(R.menu.view_imgur_video_fragment, menu); @@ -202,11 +216,7 @@ public class ViewImgurVideoFragment extends Fragment { requestPermissionAndDownload(); return true; } else if (item.getItemId() == R.id.action_playback_speed_view_imgur_video_fragment) { - PlaybackSpeedBottomSheetFragment playbackSpeedBottomSheetFragment = new PlaybackSpeedBottomSheetFragment(); - Bundle bundle = new Bundle(); - bundle.putInt(PlaybackSpeedBottomSheetFragment.EXTRA_PLAYBACK_SPEED, playbackSpeed); - playbackSpeedBottomSheetFragment.setArguments(bundle); - playbackSpeedBottomSheetFragment.show(getChildFragmentManager(), playbackSpeedBottomSheetFragment.getTag()); + changePlaybackSpeed(); return true; } return false; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryVideoFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryVideoFragment.java index 02560a7f..ba165592 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryVideoFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryVideoFragment.java @@ -79,6 +79,8 @@ public class ViewRedditGalleryVideoFragment extends Fragment { MaterialButton backButton; @BindView(R.id.download_image_view_exo_playback_control_view) MaterialButton downloadButton; + @BindView(R.id.playback_speed_image_view_exo_playback_control_view) + MaterialButton playbackSpeedButton; private ViewRedditGalleryActivity activity; private Post.Gallery galleryVideo; private String subredditName; @@ -185,11 +187,22 @@ public class ViewRedditGalleryVideoFragment extends Fragment { isDownloading = true; requestPermissionAndDownload(); }); + playbackSpeedButton.setOnClickListener(view -> { + changePlaybackSpeed(); + }); } return rootView; } + private void changePlaybackSpeed() { + PlaybackSpeedBottomSheetFragment playbackSpeedBottomSheetFragment = new PlaybackSpeedBottomSheetFragment(); + Bundle bundle = new Bundle(); + bundle.putInt(PlaybackSpeedBottomSheetFragment.EXTRA_PLAYBACK_SPEED, playbackSpeed); + playbackSpeedBottomSheetFragment.setArguments(bundle); + playbackSpeedBottomSheetFragment.show(getChildFragmentManager(), playbackSpeedBottomSheetFragment.getTag()); + } + @Override public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) { inflater.inflate(R.menu.view_reddit_gallery_video_fragment, menu); @@ -207,11 +220,7 @@ public class ViewRedditGalleryVideoFragment extends Fragment { requestPermissionAndDownload(); return true; } else if (item.getItemId() == R.id.action_playback_speed_view_reddit_gallery_video_fragment) { - PlaybackSpeedBottomSheetFragment playbackSpeedBottomSheetFragment = new PlaybackSpeedBottomSheetFragment(); - Bundle bundle = new Bundle(); - bundle.putInt(PlaybackSpeedBottomSheetFragment.EXTRA_PLAYBACK_SPEED, playbackSpeed); - playbackSpeedBottomSheetFragment.setArguments(bundle); - playbackSpeedBottomSheetFragment.show(getChildFragmentManager(), playbackSpeedBottomSheetFragment.getTag()); + return true; } return false; -- cgit v1.2.3