Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
  • Loading branch information
tobiasKaminsky committed May 6, 2021
1 parent 0492601 commit 086043f
Showing 1 changed file with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,10 @@ public static PreviewMediaFragment newInstance(OCFile fileToDetail,
/**
* Creates an empty fragment for previews.
* <p/>
* 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).
* <p/>
* 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();
Expand Down Expand Up @@ -268,7 +267,7 @@ private void extractAndSetCoverArt(OCFile file) {
}
}
}

private void setThumbnailForAudio(OCFile file) {
Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(
ThumbnailsCacheManager.PREFIX_THUMBNAIL + file.getRemoteId());
Expand All @@ -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());
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -538,7 +537,7 @@ private class VideoHelper implements OnCompletionListener, OnPreparedListener, O
* <p/>
* 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) {
Expand Down Expand Up @@ -608,6 +607,9 @@ public void onResume() {

@Override
public void onDestroy() {



Log_OC.v(TAG, "onDestroy");
super.onDestroy();
}
Expand All @@ -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();
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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();
}
}

0 comments on commit 086043f

Please sign in to comment.