From 825e40595dbd9a8b03a283dc66d38a66429ff99b Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 9 Jun 2016 18:02:31 +0200 Subject: [PATCH] properly update the neighbour time holder visibility too --- .../gallery/activities/ViewPagerActivity.java | 6 ++++-- .../gallery/adapters/MyPagerAdapter.java | 9 +++++++++ .../gallery/fragments/PhotoFragment.java | 5 +++++ .../gallery/fragments/VideoFragment.java | 18 +++++++++++++++--- .../gallery/fragments/ViewPagerFragment.java | 2 ++ 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java index 28adc6230..8cda938c6 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java @@ -281,7 +281,7 @@ public class ViewPagerActivity extends AppCompatActivity return myMedia; } - public boolean fragmentClicked() { + public void fragmentClicked() { deleteFile(); isFullScreen = !isFullScreen; if (isFullScreen) { @@ -289,7 +289,6 @@ public class ViewPagerActivity extends AppCompatActivity } else { showSystemUI(); } - return isFullScreen; } private void hideSystemUI() { @@ -361,6 +360,9 @@ public class ViewPagerActivity extends AppCompatActivity if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) { isFullScreen = false; } + + final MyPagerAdapter adapter = (MyPagerAdapter) pager.getAdapter(); + adapter.updateUiVisibility(isFullScreen, pos); } @Override diff --git a/app/src/main/java/com/simplemobiletools/gallery/adapters/MyPagerAdapter.java b/app/src/main/java/com/simplemobiletools/gallery/adapters/MyPagerAdapter.java index 6847adcb1..16f0452ec 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/adapters/MyPagerAdapter.java +++ b/app/src/main/java/com/simplemobiletools/gallery/adapters/MyPagerAdapter.java @@ -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 newPaths) { media.clear(); media.addAll(newPaths); diff --git a/app/src/main/java/com/simplemobiletools/gallery/fragments/PhotoFragment.java b/app/src/main/java/com/simplemobiletools/gallery/fragments/PhotoFragment.java index 90a3a760b..00e4c5c15 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/fragments/PhotoFragment.java +++ b/app/src/main/java/com/simplemobiletools/gallery/fragments/PhotoFragment.java @@ -45,4 +45,9 @@ public class PhotoFragment extends ViewPagerFragment implements View.OnClickList public void itemDragged() { } + + @Override + public void systemUiVisibilityChanged(boolean toFullscreen) { + + } } diff --git a/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java b/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java index 18c773927..c666031b0 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java +++ b/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java @@ -86,6 +86,14 @@ public class VideoFragment extends ViewPagerFragment pauseVideo(); } + @Override + public void systemUiVisibilityChanged(boolean toFullscreen) { + if (isFullscreen != toFullscreen) { + isFullscreen = toFullscreen; + checkFullscreen(); + } + } + private void initTimeHolder(View view) { timeHolder = view.findViewById(R.id.video_time_holder); final Resources res = getResources(); @@ -146,16 +154,20 @@ public class VideoFragment extends ViewPagerFragment togglePlayPause(); break; default: - toggleFullscreen(); + isFullscreen = !isFullscreen; + checkFullscreen(); + ((ViewPagerActivity) getActivity()).fragmentClicked(); break; } } - private void toggleFullscreen() { - isFullscreen = ((ViewPagerActivity) getActivity()).fragmentClicked(); + private void checkFullscreen() { int anim = R.anim.fade_in; if (isFullscreen) { anim = R.anim.fade_out; + seekBar.setOnSeekBarChangeListener(null); + } else { + seekBar.setOnSeekBarChangeListener(this); } final Animation animation = AnimationUtils.loadAnimation(getContext(), anim); diff --git a/app/src/main/java/com/simplemobiletools/gallery/fragments/ViewPagerFragment.java b/app/src/main/java/com/simplemobiletools/gallery/fragments/ViewPagerFragment.java index 53bf8c617..e179d702b 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/fragments/ViewPagerFragment.java +++ b/app/src/main/java/com/simplemobiletools/gallery/fragments/ViewPagerFragment.java @@ -4,4 +4,6 @@ import android.support.v4.app.Fragment; public abstract class ViewPagerFragment extends Fragment { public abstract void itemDragged(); + + public abstract void systemUiVisibilityChanged(boolean toFullscreen); }