mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-25 22:18:00 +01:00
fade the timeholder together with the system ui
This commit is contained in:
parent
f8dfc3f423
commit
82241c250b
4 changed files with 39 additions and 4 deletions
|
@ -281,7 +281,7 @@ public class ViewPagerActivity extends AppCompatActivity
|
||||||
return myMedia;
|
return myMedia;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fragmentClicked() {
|
public boolean fragmentClicked() {
|
||||||
deleteFile();
|
deleteFile();
|
||||||
isFullScreen = !isFullScreen;
|
isFullScreen = !isFullScreen;
|
||||||
if (isFullScreen) {
|
if (isFullScreen) {
|
||||||
|
@ -289,6 +289,7 @@ public class ViewPagerActivity extends AppCompatActivity
|
||||||
} else {
|
} else {
|
||||||
showSystemUI();
|
showSystemUI();
|
||||||
}
|
}
|
||||||
|
return isFullScreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hideSystemUI() {
|
private void hideSystemUI() {
|
||||||
|
|
|
@ -15,8 +15,9 @@ import android.view.SurfaceHolder;
|
||||||
import android.view.SurfaceView;
|
import android.view.SurfaceView;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.animation.Animation;
|
||||||
|
import android.view.animation.AnimationUtils;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
@ -44,8 +45,10 @@ public class VideoFragment extends ViewPagerFragment
|
||||||
private Handler timerHandler;
|
private Handler timerHandler;
|
||||||
private SeekBar seekBar;
|
private SeekBar seekBar;
|
||||||
private Medium medium;
|
private Medium medium;
|
||||||
|
private View timeHolder;
|
||||||
private boolean isPlaying;
|
private boolean isPlaying;
|
||||||
private boolean isDragged;
|
private boolean isDragged;
|
||||||
|
private boolean isFullscreen;
|
||||||
private int currTime;
|
private int currTime;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,6 +59,8 @@ public class VideoFragment extends ViewPagerFragment
|
||||||
if (medium == null)
|
if (medium == null)
|
||||||
return view;
|
return view;
|
||||||
|
|
||||||
|
isFullscreen = (getActivity().getWindow().getDecorView().getSystemUiVisibility() & View.SYSTEM_UI_FLAG_FULLSCREEN) ==
|
||||||
|
View.SYSTEM_UI_FLAG_FULLSCREEN;
|
||||||
setupPlayer(view);
|
setupPlayer(view);
|
||||||
view.setOnClickListener(this);
|
view.setOnClickListener(this);
|
||||||
|
|
||||||
|
@ -82,7 +87,7 @@ public class VideoFragment extends ViewPagerFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initTimeHolder(View view) {
|
private void initTimeHolder(View view) {
|
||||||
RelativeLayout timeHolder = (RelativeLayout) view.findViewById(R.id.video_time_holder);
|
timeHolder = view.findViewById(R.id.video_time_holder);
|
||||||
final Resources res = getResources();
|
final Resources res = getResources();
|
||||||
final int height = Utils.getNavBarHeight(res);
|
final int height = Utils.getNavBarHeight(res);
|
||||||
final int left = timeHolder.getPaddingLeft();
|
final int left = timeHolder.getPaddingLeft();
|
||||||
|
@ -100,6 +105,9 @@ public class VideoFragment extends ViewPagerFragment
|
||||||
durationView = (TextView) view.findViewById(R.id.video_duration);
|
durationView = (TextView) view.findViewById(R.id.video_duration);
|
||||||
seekBar = (SeekBar) view.findViewById(R.id.video_seekbar);
|
seekBar = (SeekBar) view.findViewById(R.id.video_seekbar);
|
||||||
seekBar.setOnSeekBarChangeListener(this);
|
seekBar.setOnSeekBarChangeListener(this);
|
||||||
|
|
||||||
|
if (isFullscreen)
|
||||||
|
timeHolder.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupTimeHolder() {
|
private void setupTimeHolder() {
|
||||||
|
@ -138,10 +146,22 @@ public class VideoFragment extends ViewPagerFragment
|
||||||
togglePlayPause();
|
togglePlayPause();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
((ViewPagerActivity) getActivity()).fragmentClicked();
|
toggleFullscreen();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void toggleFullscreen() {
|
||||||
|
isFullscreen = ((ViewPagerActivity) getActivity()).fragmentClicked();
|
||||||
|
int anim = R.anim.fade_in;
|
||||||
|
if (isFullscreen) {
|
||||||
|
anim = R.anim.fade_out;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Animation animation = AnimationUtils.loadAnimation(getContext(), anim);
|
||||||
|
timeHolder.startAnimation(animation);
|
||||||
|
}
|
||||||
|
|
||||||
private void pauseVideo() {
|
private void pauseVideo() {
|
||||||
if (isPlaying) {
|
if (isPlaying) {
|
||||||
togglePlayPause();
|
togglePlayPause();
|
||||||
|
|
7
app/src/main/res/anim/fade_in.xml
Normal file
7
app/src/main/res/anim/fade_in.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:duration="150"
|
||||||
|
android:fillAfter="true"
|
||||||
|
android:fromAlpha="0.0"
|
||||||
|
android:interpolator="@android:anim/accelerate_interpolator"
|
||||||
|
android:toAlpha="1.0"/>
|
7
app/src/main/res/anim/fade_out.xml
Normal file
7
app/src/main/res/anim/fade_out.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:duration="150"
|
||||||
|
android:fillAfter="true"
|
||||||
|
android:fromAlpha="1.0"
|
||||||
|
android:interpolator="@android:anim/accelerate_interpolator"
|
||||||
|
android:toAlpha="0.0"/>
|
Loading…
Reference in a new issue