mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 00:17:58 +01:00
adding an implementation of slideshow fade animations
This commit is contained in:
parent
cd261dc8e1
commit
2c9ac6e440
4 changed files with 40 additions and 3 deletions
|
@ -396,6 +396,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
if (getMediaForSlideshow()) {
|
if (getMediaForSlideshow()) {
|
||||||
view_pager.onGlobalLayout {
|
view_pager.onGlobalLayout {
|
||||||
if (!isDestroyed) {
|
if (!isDestroyed) {
|
||||||
|
if (config.slideshowAnimation == SLIDESHOW_ANIMATION_FADE) {
|
||||||
|
view_pager.setPageTransformer(false, FadePageTransformer())
|
||||||
|
}
|
||||||
|
|
||||||
hideSystemUI(true)
|
hideSystemUI(true)
|
||||||
mSlideshowInterval = config.slideshowInterval
|
mSlideshowInterval = config.slideshowInterval
|
||||||
mSlideshowMoveBackwards = config.slideshowMoveBackwards
|
mSlideshowMoveBackwards = config.slideshowMoveBackwards
|
||||||
|
@ -436,7 +440,13 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
animator.interpolator = DecelerateInterpolator()
|
if (config.slideshowAnimation == SLIDESHOW_ANIMATION_SLIDE) {
|
||||||
|
animator.interpolator = DecelerateInterpolator()
|
||||||
|
animator.duration = SLIDESHOW_SLIDE_DURATION
|
||||||
|
} else {
|
||||||
|
animator.duration = SLIDESHOW_FADE_DURATION
|
||||||
|
}
|
||||||
|
|
||||||
animator.addUpdateListener(object : ValueAnimator.AnimatorUpdateListener {
|
animator.addUpdateListener(object : ValueAnimator.AnimatorUpdateListener {
|
||||||
var oldDragPosition = 0
|
var oldDragPosition = 0
|
||||||
override fun onAnimationUpdate(animation: ValueAnimator) {
|
override fun onAnimationUpdate(animation: ValueAnimator) {
|
||||||
|
@ -453,7 +463,6 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
animator.duration = SLIDESHOW_SCROLL_DURATION
|
|
||||||
view_pager.beginFakeDrag()
|
view_pager.beginFakeDrag()
|
||||||
animator.start()
|
animator.start()
|
||||||
}
|
}
|
||||||
|
@ -473,6 +482,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
|
|
||||||
private fun stopSlideshow() {
|
private fun stopSlideshow() {
|
||||||
if (mIsSlideshowActive) {
|
if (mIsSlideshowActive) {
|
||||||
|
view_pager.setPageTransformer(false, DefaultPageTransformer())
|
||||||
mIsSlideshowActive = false
|
mIsSlideshowActive = false
|
||||||
showSystemUI(true)
|
showSystemUI(true)
|
||||||
mSlideshowHandler.removeCallbacksAndMessages(null)
|
mSlideshowHandler.removeCallbacksAndMessages(null)
|
||||||
|
|
|
@ -88,7 +88,8 @@ const val SLIDESHOW_MOVE_BACKWARDS = "slideshow_move_backwards"
|
||||||
const val SLIDESHOW_ANIMATION = "slideshow_animation"
|
const val SLIDESHOW_ANIMATION = "slideshow_animation"
|
||||||
const val SLIDESHOW_LOOP = "loop_slideshow"
|
const val SLIDESHOW_LOOP = "loop_slideshow"
|
||||||
const val SLIDESHOW_DEFAULT_INTERVAL = 5
|
const val SLIDESHOW_DEFAULT_INTERVAL = 5
|
||||||
const val SLIDESHOW_SCROLL_DURATION = 500L
|
const val SLIDESHOW_SLIDE_DURATION = 500L
|
||||||
|
const val SLIDESHOW_FADE_DURATION = 1500L
|
||||||
const val SLIDESHOW_START_ON_ENTER = "slideshow_start_on_enter"
|
const val SLIDESHOW_START_ON_ENTER = "slideshow_start_on_enter"
|
||||||
|
|
||||||
// slideshow animations
|
// slideshow animations
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.simplemobiletools.gallery.pro.helpers
|
||||||
|
|
||||||
|
import android.view.View
|
||||||
|
import androidx.viewpager.widget.ViewPager
|
||||||
|
|
||||||
|
class DefaultPageTransformer : ViewPager.PageTransformer {
|
||||||
|
override fun transformPage(view: View, position: Float) {}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.simplemobiletools.gallery.pro.helpers
|
||||||
|
|
||||||
|
import android.view.View
|
||||||
|
import androidx.viewpager.widget.ViewPager
|
||||||
|
|
||||||
|
class FadePageTransformer : ViewPager.PageTransformer {
|
||||||
|
override fun transformPage(view: View, position: Float) {
|
||||||
|
view.translationX = view.width * -position
|
||||||
|
|
||||||
|
view.alpha = if (position <= -1f || position >= 1f) {
|
||||||
|
0f
|
||||||
|
} else if (position == 0f) {
|
||||||
|
1f
|
||||||
|
} else {
|
||||||
|
1f - Math.abs(position)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue