From 605cf6ae0fd8ef8e3de5195004a308da9472dd6c Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 4 Feb 2018 12:57:40 +0100 Subject: [PATCH] wteak the MediaSideScroll callback a bit --- .../gallery/fragments/PhotoFragment.kt | 10 +++++++++- .../gallery/fragments/VideoFragment.kt | 3 +-- .../gallery/helpers/MediaSideScroll.kt | 8 +++----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt index bed5b928a..0831224cb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -114,7 +114,15 @@ class PhotoFragment : ViewPagerFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - mediaSideScroll = MediaSideScroll(activity!!, view.slide_info) + mediaSideScroll = MediaSideScroll(activity!!, view.slide_info) { + view.apply { + if (subsampling_view.isVisible()) { + subsampling_view.performClick() + } else { + gif_view.performClick() + } + } + } } override fun onPause() { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt index 0cab540ba..a636bc715 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt @@ -87,8 +87,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - mediaSideScroll = MediaSideScroll(activity!!, view.slide_info) - mediaSideScroll.onClickOnSlider = { + mediaSideScroll = MediaSideScroll(activity!!, view.slide_info) { view.video_holder.performClick() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaSideScroll.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaSideScroll.kt index f94ae7411..652001ec1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaSideScroll.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaSideScroll.kt @@ -10,7 +10,7 @@ import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.activities.ViewPagerActivity import com.simplemobiletools.gallery.extensions.audioManager -class MediaSideScroll(val activity: Activity, val slideInfoView: TextView) { +class MediaSideScroll(val activity: Activity, val slideInfoView: TextView, val callback: () -> Unit) { private val CLICK_MAX_DURATION = 150 private val SLIDE_INFO_FADE_DELAY = 1000L private var mTouchDownX = 0f @@ -24,8 +24,6 @@ class MediaSideScroll(val activity: Activity, val slideInfoView: TextView) { private var mSlideInfoText = "" private var mSlideInfoFadeHandler = Handler() - var onClickOnSlider: (() -> Unit)? = null - fun handleVolumeTouched(event: MotionEvent) { when (event.action) { MotionEvent.ACTION_DOWN -> { @@ -57,7 +55,7 @@ class MediaSideScroll(val activity: Activity, val slideInfoView: TextView) { val diffX = Math.abs(event.x - mTouchDownX) val diffY = Math.abs(event.y - mTouchDownY) if (System.currentTimeMillis() - mTouchDownTime < CLICK_MAX_DURATION && diffX < 20 && diffY < 20) { - onClickOnSlider?.invoke() + callback() } } } @@ -95,7 +93,7 @@ class MediaSideScroll(val activity: Activity, val slideInfoView: TextView) { val diffX = Math.abs(event.x - mTouchDownX) val diffY = Math.abs(event.y - mTouchDownY) if (System.currentTimeMillis() - mTouchDownTime < CLICK_MAX_DURATION && diffX < 20 && diffY < 20) { - onClickOnSlider?.invoke() + callback() } mTouchDownBrightness = mTempBrightness }