send a more advanced click event with coordinates at clicking side slider
This commit is contained in:
parent
db8a88cbfe
commit
0616117f36
4 changed files with 21 additions and 8 deletions
|
@ -0,0 +1,13 @@
|
|||
package com.simplemobiletools.gallery.extensions
|
||||
|
||||
import android.os.SystemClock
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
|
||||
fun View.sendFakeClick(x: Float, y: Float) {
|
||||
val uptime = SystemClock.uptimeMillis()
|
||||
val event = MotionEvent.obtain(uptime, uptime, MotionEvent.ACTION_DOWN, x, y, 0)
|
||||
dispatchTouchEvent(event)
|
||||
event.action = MotionEvent.ACTION_UP
|
||||
dispatchTouchEvent(event)
|
||||
}
|
|
@ -62,12 +62,12 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
instant_prev_item.parentView = container
|
||||
instant_next_item.parentView = container
|
||||
|
||||
photo_brightness_controller.initialize(activity!!, slide_info, true, container) {
|
||||
photo_brightness_controller.initialize(activity!!, slide_info, true, container) { x, y ->
|
||||
view.apply {
|
||||
if (subsampling_view.isVisible()) {
|
||||
subsampling_view.performClick()
|
||||
subsampling_view.sendFakeClick(x, y)
|
||||
} else {
|
||||
gif_view.performClick()
|
||||
gif_view.sendFakeClick(x, y)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,12 +85,12 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
|
||||
mView!!.apply {
|
||||
brightnessSideScroll = video_brightness_controller
|
||||
brightnessSideScroll.initialize(activity!!, slide_info, true, container) {
|
||||
brightnessSideScroll.initialize(activity!!, slide_info, true, container) { x, y ->
|
||||
video_holder.performClick()
|
||||
}
|
||||
|
||||
volumeSideScroll = video_volume_controller
|
||||
volumeSideScroll.initialize(activity!!, slide_info, false, container) {
|
||||
volumeSideScroll.initialize(activity!!, slide_info, false, container) { x, y ->
|
||||
video_holder.performClick()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,9 +33,9 @@ class MediaSideScroll(context: Context, attrs: AttributeSet) : RelativeLayout(co
|
|||
|
||||
private lateinit var activity: Activity
|
||||
private lateinit var slideInfoView: TextView
|
||||
private lateinit var callback: () -> Unit
|
||||
private lateinit var callback: (Float, Float) -> Unit
|
||||
|
||||
fun initialize(activity: Activity, slideInfoView: TextView, isBrightness: Boolean, parentView: ViewGroup?, callback: () -> Unit) {
|
||||
fun initialize(activity: Activity, slideInfoView: TextView, isBrightness: Boolean, parentView: ViewGroup?, callback: (x: Float, y: Float) -> Unit) {
|
||||
this.activity = activity
|
||||
this.slideInfoView = slideInfoView
|
||||
this.callback = callback
|
||||
|
@ -101,7 +101,7 @@ class MediaSideScroll(context: Context, attrs: AttributeSet) : RelativeLayout(co
|
|||
}
|
||||
MotionEvent.ACTION_UP -> {
|
||||
if (System.currentTimeMillis() - mTouchDownTime < CLICK_MAX_DURATION) {
|
||||
callback()
|
||||
callback(event.rawX, event.rawY)
|
||||
}
|
||||
|
||||
if (mIsBrightnessScroll) {
|
||||
|
|
Loading…
Reference in a new issue