mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +01:00
minor refactoring
This commit is contained in:
parent
07b60e0afb
commit
37bda0c72e
1 changed files with 23 additions and 19 deletions
|
@ -190,34 +190,38 @@ public class VideoFragment extends ViewPagerFragment
|
||||||
mTimeHolder.startAnimation(animation);
|
mTimeHolder.startAnimation(animation);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pauseVideo() {
|
|
||||||
if (mIsPlaying) {
|
|
||||||
togglePlayPause();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void togglePlayPause() {
|
private void togglePlayPause() {
|
||||||
if (getActivity() == null)
|
if (getActivity() == null || !isAdded())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mIsPlaying = !mIsPlaying;
|
mIsPlaying = !mIsPlaying;
|
||||||
if (mIsPlaying) {
|
if (mIsPlaying) {
|
||||||
if (mMediaPlayer != null) {
|
playVideo();
|
||||||
mMediaPlayer.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
mPlayOutline.setImageDrawable(null);
|
|
||||||
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
||||||
} else {
|
} else {
|
||||||
if (mMediaPlayer != null) {
|
pauseVideo();
|
||||||
mMediaPlayer.pause();
|
|
||||||
}
|
|
||||||
|
|
||||||
mPlayOutline.setImageDrawable(getResources().getDrawable(R.mipmap.play_outline_big));
|
|
||||||
getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void playVideo() {
|
||||||
|
mIsPlaying = true;
|
||||||
|
if (mMediaPlayer != null) {
|
||||||
|
mMediaPlayer.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
mPlayOutline.setImageDrawable(null);
|
||||||
|
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void pauseVideo() {
|
||||||
|
mIsPlaying = false;
|
||||||
|
if (mMediaPlayer != null) {
|
||||||
|
mMediaPlayer.pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
mPlayOutline.setImageDrawable(getResources().getDrawable(R.mipmap.play_outline_big));
|
||||||
|
getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
|
}
|
||||||
|
|
||||||
private void initMediaPlayer() {
|
private void initMediaPlayer() {
|
||||||
if (mMediaPlayer != null)
|
if (mMediaPlayer != null)
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue