mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2024-12-28 09:11:44 +01:00
couple slideshow improvements
This commit is contained in:
parent
422b1fb690
commit
46a143e4ac
@ -317,6 +317,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||
view_pager.apply {
|
||||
adapter = pagerAdapter
|
||||
currentItem = mPos
|
||||
removeOnPageChangeListener(this@ViewPagerActivity)
|
||||
addOnPageChangeListener(this@ViewPagerActivity)
|
||||
}
|
||||
}
|
||||
@ -351,10 +352,16 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||
}
|
||||
|
||||
override fun onAnimationEnd(animation: Animator?) {
|
||||
view_pager.endFakeDrag()
|
||||
if (view_pager.isFakeDragging) {
|
||||
try {
|
||||
view_pager.endFakeDrag()
|
||||
} catch (ignored: Exception) {
|
||||
stopSlideshow()
|
||||
}
|
||||
|
||||
if (view_pager.currentItem == oldPosition) {
|
||||
slideshowEnded(forward)
|
||||
if (view_pager.currentItem == oldPosition) {
|
||||
slideshowEnded(forward)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -374,7 +381,11 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||
val dragPosition = animation.animatedValue as Int
|
||||
val dragOffset = dragPosition - oldDragPosition
|
||||
oldDragPosition = dragPosition
|
||||
view_pager.fakeDragBy(dragOffset * (if (forward) 1f else -1f))
|
||||
try {
|
||||
view_pager.fakeDragBy(dragOffset * (if (forward) 1f else -1f))
|
||||
} catch (e: Exception) {
|
||||
stopSlideshow()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -399,8 +410,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||
|
||||
private fun stopSlideshow() {
|
||||
if (mIsSlideshowActive) {
|
||||
showSystemUI()
|
||||
mIsSlideshowActive = false
|
||||
showSystemUI()
|
||||
mSlideshowHandler.removeCallbacksAndMessages(null)
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user