From 086043f7cbf1e25c66df561abb68b2ba8545bb92 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Thu, 6 May 2021 10:57:44 +0200 Subject: [PATCH] wip Signed-off-by: tobiasKaminsky --- .../ui/preview/PreviewMediaFragment.java | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java b/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java index 9d0b392ae586..69f321c249f9 100644 --- a/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java +++ b/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java @@ -150,11 +150,10 @@ public static PreviewMediaFragment newInstance(OCFile fileToDetail, /** * Creates an empty fragment for previews. *

- * MUST BE KEPT: the system uses it when tries to reinstantiate a fragment automatically - * (for instance, when the device is turned a aside). + * MUST BE KEPT: the system uses it when tries to reinstantiate a fragment automatically (for instance, when the + * device is turned a aside). *

- * DO NOT CALL IT: an {@link OCFile} and {@link Account} must be provided for a successful - * construction + * DO NOT CALL IT: an {@link OCFile} and {@link Account} must be provided for a successful construction */ public PreviewMediaFragment() { super(); @@ -268,7 +267,7 @@ private void extractAndSetCoverArt(OCFile file) { } } } - + private void setThumbnailForAudio(OCFile file) { Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache( ThumbnailsCacheManager.PREFIX_THUMBNAIL + file.getRemoteId()); @@ -295,7 +294,7 @@ public void onSaveInstanceState(@NonNull Bundle outState) { outState.putLong(EXTRA_PLAY_POSITION, savedPlaybackPosition); outState.putBoolean(EXTRA_PLAYING, autoplay); } - } else if(mediaPlayerServiceConnection.isConnected()) { + } else if (mediaPlayerServiceConnection.isConnected()) { outState.putInt(EXTRA_PLAY_POSITION, mediaPlayerServiceConnection.getCurrentPosition()); outState.putBoolean(EXTRA_PLAYING, mediaPlayerServiceConnection.isPlaying()); } @@ -400,10 +399,10 @@ public void onPrepareOptionsMenu(@NonNull Menu menu) { item.setEnabled(false); } - if(getFile().isSharedWithMe() && !getFile().canReshare()){ + if (getFile().isSharedWithMe() && !getFile().canReshare()) { // additional restriction for this fragment item = menu.findItem(R.id.action_send_share_file); - if(item != null){ + if (item != null) { item.setVisible(false); item.setEnabled(false); } @@ -436,7 +435,7 @@ public boolean onOptionsItemSelected(MenuItem item) { /** * Update the file of the fragment with file value * - * @param file Replaces the held file with a new one + * @param file Replaces the held file with a new one */ public void updateFile(OCFile file) { setFile(file); @@ -538,7 +537,7 @@ private class VideoHelper implements OnCompletionListener, OnPreparedListener, O *

* Just starts the playback. * - * @param vp {@link MediaPlayer} instance performing the playback. + * @param vp {@link MediaPlayer} instance performing the playback. */ @Override public void onPrepared(MediaPlayer vp) { @@ -608,6 +607,9 @@ public void onResume() { @Override public void onDestroy() { + + + Log_OC.v(TAG, "onDestroy"); super.onDestroy(); } @@ -622,6 +624,10 @@ public void onDestroyView() { @Override public void onStop() { Log_OC.v(TAG, "onStop"); + if (!mediaPlayerServiceConnection.isPlaying()) { + stopAudio(); + } + mediaPlayerServiceConnection.unbind(); toggleDrawerLockMode(containerActivity, DrawerLayout.LOCK_MODE_UNLOCKED); super.onStop(); @@ -676,8 +682,7 @@ private void openFile() { } /** - * Helper method to test if an {@link OCFile} can be passed to a {@link PreviewMediaFragment} - * to be previewed. + * Helper method to test if an {@link OCFile} can be passed to a {@link PreviewMediaFragment} to be previewed. * * @param file File to test if can be previewed. * @return 'True' if the file can be handled by the fragment. @@ -719,13 +724,10 @@ private void toggleDrawerLockMode(ContainerActivity containerActivity, int lockM @Override public void onDetach() { - super.onDetach(); - + exoPlayer.stop(); exoPlayer.release(); - - if (!mediaPlayerServiceConnection.isPlaying()) { - stopAudio(); - } + + super.onDetach(); } }