Auto hide gallery slider
This commit is contained in:
1 parent
bdace936fc
commit
8faf0131c2
2 files changed
+56
-10
No files matched your search
@@ -68,6 +68,9 @@ public class GalleryActivity extends AppCompatActivity
|
||||
public static final String KEY_GALLERY_INFO = "gallery_info";
|
||||
public static final String KEY_SHOWING = "showing";
|
||||
|
||||
private static final long SLIDER_ANIMATION_DURING = 150;
|
||||
private static final long HIDE_SLIDER_DELAY = 3000;
|
||||
|
||||
private String mAction;
|
||||
private String mFilename;
|
||||
private GalleryInfo mGalleryInfo;
|
||||
@@ -121,6 +124,15 @@ public class GalleryActivity extends AppCompatActivity
|
||||
}
|
||||
};
|
||||
|
||||
private final Runnable mHideSliderRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mSliderPanel != null) {
|
||||
hideSlider(mSliderPanel);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private void buildProvider() {
|
||||
if (mGalleryProvider != null) {
|
||||
return;
|
||||
@@ -459,6 +471,16 @@ public class GalleryActivity extends AppCompatActivity
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFingerDown() {
|
||||
SimpleHandler.getInstance().removeCallbacks(mHideSliderRunnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFingerUp() {
|
||||
SimpleHandler.getInstance().postDelayed(mHideSliderRunnable, HIDE_SLIDER_DELAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateCurrentIndex(int index) {
|
||||
NotifyTask task = mNotifyTaskPool.pop();
|
||||
@@ -499,6 +521,22 @@ public class GalleryActivity extends AppCompatActivity
|
||||
SimpleHandler.getInstance().post(task);
|
||||
}
|
||||
|
||||
private void showSlider(View sliderPanel) {
|
||||
sliderPanel.setTranslationY(sliderPanel.getHeight());
|
||||
sliderPanel.setVisibility(View.VISIBLE);
|
||||
sliderPanel.animate().translationY(0.0f).setDuration(SLIDER_ANIMATION_DURING)
|
||||
.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR)
|
||||
.setListener(null).start();
|
||||
// Request layout ensure show it
|
||||
SimpleHandler.getInstance().post(mRequestLayoutSliderTask);
|
||||
}
|
||||
|
||||
private void hideSlider(View sliderPanel) {
|
||||
sliderPanel.animate().translationY(sliderPanel.getHeight()).setDuration(SLIDER_ANIMATION_DURING)
|
||||
.setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR)
|
||||
.setListener(mHideSliderListener).start();
|
||||
}
|
||||
|
||||
private class GalleryMenuHelper implements DialogInterface.OnClickListener {
|
||||
|
||||
private final View mView;
|
||||
@@ -595,18 +633,13 @@ public class GalleryActivity extends AppCompatActivity
|
||||
return;
|
||||
}
|
||||
|
||||
SimpleHandler.getInstance().removeCallbacks(mHideSliderRunnable);
|
||||
|
||||
if (mSliderPanel.getVisibility() == View.VISIBLE) {
|
||||
mSliderPanel.animate().translationY(mSliderPanel.getHeight()).setDuration(150)
|
||||
.setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR)
|
||||
.setListener(mHideSliderListener).start();
|
||||
hideSlider(mSliderPanel);
|
||||
} else {
|
||||
mSliderPanel.setTranslationY(mSliderPanel.getHeight());
|
||||
mSliderPanel.setVisibility(View.VISIBLE);
|
||||
mSliderPanel.animate().translationY(0.0f).setDuration(150)
|
||||
.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR)
|
||||
.setListener(null).start();
|
||||
// Request layout ensure show it
|
||||
SimpleHandler.getInstance().post(mRequestLayoutSliderTask);
|
||||
showSlider(mSliderPanel);
|
||||
SimpleHandler.getInstance().postDelayed(mHideSliderRunnable, HIDE_SLIDER_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -400,6 +400,15 @@ public class Slider extends View {
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
|
||||
if (mListener != null) {
|
||||
if (action == MotionEvent.ACTION_DOWN) {
|
||||
mListener.onFingerDown();
|
||||
} else if (action == MotionEvent.ACTION_UP) {
|
||||
mListener.onFingerUp();
|
||||
}
|
||||
}
|
||||
|
||||
int paddingLeft = getPaddingLeft();
|
||||
int paddingRight = getPaddingRight();
|
||||
float radius = mRadius;
|
||||
@@ -507,6 +516,10 @@ public class Slider extends View {
|
||||
public interface OnSetProgressListener {
|
||||
|
||||
void onSetProgress(Slider slider, int newProgress, int oldProgress, boolean byUser, boolean confirm);
|
||||
|
||||
void onFingerDown();
|
||||
|
||||
void onFingerUp();
|
||||
}
|
||||
|
||||
private final class CheckForShowBubble implements Runnable {
|
||||
|
||||
Reference in new issue
Block a user