properly update the neighbour time holder visibility too

This commit is contained in:
tibbi 2016-06-09 18:02:31 +02:00
parent 82241c250b
commit 825e40595d
5 changed files with 35 additions and 5 deletions

View file

@ -281,7 +281,7 @@ public class ViewPagerActivity extends AppCompatActivity
return myMedia; return myMedia;
} }
public boolean fragmentClicked() { public void fragmentClicked() {
deleteFile(); deleteFile();
isFullScreen = !isFullScreen; isFullScreen = !isFullScreen;
if (isFullScreen) { if (isFullScreen) {
@ -289,7 +289,6 @@ public class ViewPagerActivity extends AppCompatActivity
} else { } else {
showSystemUI(); showSystemUI();
} }
return isFullScreen;
} }
private void hideSystemUI() { private void hideSystemUI() {
@ -361,6 +360,9 @@ public class ViewPagerActivity extends AppCompatActivity
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) { if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
isFullScreen = false; isFullScreen = false;
} }
final MyPagerAdapter adapter = (MyPagerAdapter) pager.getAdapter();
adapter.updateUiVisibility(isFullScreen, pos);
} }
@Override @Override

View file

@ -54,6 +54,15 @@ public class MyPagerAdapter extends FragmentStatePagerAdapter {
} }
} }
public void updateUiVisibility(boolean isFullscreen, int pos) {
for (int i = -1; i <= 1; i++) {
ViewPagerFragment fragment = fragments.get(pos + i);
if (fragment != null) {
fragment.systemUiVisibilityChanged(isFullscreen);
}
}
}
public void updateItems(List<Medium> newPaths) { public void updateItems(List<Medium> newPaths) {
media.clear(); media.clear();
media.addAll(newPaths); media.addAll(newPaths);

View file

@ -45,4 +45,9 @@ public class PhotoFragment extends ViewPagerFragment implements View.OnClickList
public void itemDragged() { public void itemDragged() {
} }
@Override
public void systemUiVisibilityChanged(boolean toFullscreen) {
}
} }

View file

@ -86,6 +86,14 @@ public class VideoFragment extends ViewPagerFragment
pauseVideo(); pauseVideo();
} }
@Override
public void systemUiVisibilityChanged(boolean toFullscreen) {
if (isFullscreen != toFullscreen) {
isFullscreen = toFullscreen;
checkFullscreen();
}
}
private void initTimeHolder(View view) { private void initTimeHolder(View view) {
timeHolder = view.findViewById(R.id.video_time_holder); timeHolder = view.findViewById(R.id.video_time_holder);
final Resources res = getResources(); final Resources res = getResources();
@ -146,16 +154,20 @@ public class VideoFragment extends ViewPagerFragment
togglePlayPause(); togglePlayPause();
break; break;
default: default:
toggleFullscreen(); isFullscreen = !isFullscreen;
checkFullscreen();
((ViewPagerActivity) getActivity()).fragmentClicked();
break; break;
} }
} }
private void toggleFullscreen() { private void checkFullscreen() {
isFullscreen = ((ViewPagerActivity) getActivity()).fragmentClicked();
int anim = R.anim.fade_in; int anim = R.anim.fade_in;
if (isFullscreen) { if (isFullscreen) {
anim = R.anim.fade_out; anim = R.anim.fade_out;
seekBar.setOnSeekBarChangeListener(null);
} else {
seekBar.setOnSeekBarChangeListener(this);
} }
final Animation animation = AnimationUtils.loadAnimation(getContext(), anim); final Animation animation = AnimationUtils.loadAnimation(getContext(), anim);

View file

@ -4,4 +4,6 @@ import android.support.v4.app.Fragment;
public abstract class ViewPagerFragment extends Fragment { public abstract class ViewPagerFragment extends Fragment {
public abstract void itemDragged(); public abstract void itemDragged();
public abstract void systemUiVisibilityChanged(boolean toFullscreen);
} }