shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package androidx.ui.core.gesture |
| 17 | |
| 18 | import android.view.MotionEvent |
| 19 | import android.view.View |
| 20 | import android.view.ViewGroup |
Louis Pullen-Freilich | e46bcf0 | 2020-02-12 16:06:21 +0000 | [diff] [blame] | 21 | import androidx.compose.emptyContent |
Shep Shapard | bf513c5 | 2019-12-16 17:06:51 -0800 | [diff] [blame] | 22 | import androidx.test.filters.LargeTest |
Shep Shapard | bf513c5 | 2019-12-16 17:06:51 -0800 | [diff] [blame] | 23 | import androidx.ui.core.Layout |
Shep Shapard | 70a8cfe | 2020-03-30 16:17:26 -0700 | [diff] [blame] | 24 | import androidx.ui.core.Modifier |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 25 | import androidx.ui.core.setContent |
| 26 | import androidx.ui.framework.test.TestActivity |
Louis Pullen-Freilich | 623e405 | 2020-07-19 20:24:03 +0100 | [diff] [blame] | 27 | import androidx.compose.foundation.layout.Stack |
Nader Jawad | 6df0612 | 2020-06-03 15:27:08 -0700 | [diff] [blame] | 28 | import androidx.ui.geometry.Offset |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 29 | import com.nhaarman.mockitokotlin2.any |
Shep Shapard | bf513c5 | 2019-12-16 17:06:51 -0800 | [diff] [blame] | 30 | import com.nhaarman.mockitokotlin2.inOrder |
| 31 | import com.nhaarman.mockitokotlin2.spy |
| 32 | import com.nhaarman.mockitokotlin2.times |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 33 | import com.nhaarman.mockitokotlin2.verify |
| 34 | import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions |
| 35 | import org.junit.Assert.assertTrue |
| 36 | import org.junit.Before |
| 37 | import org.junit.Rule |
| 38 | import org.junit.Test |
| 39 | import org.junit.runner.RunWith |
| 40 | import org.junit.runners.JUnit4 |
| 41 | import java.util.concurrent.CountDownLatch |
| 42 | import java.util.concurrent.TimeUnit |
Shep Shapard | bf513c5 | 2019-12-16 17:06:51 -0800 | [diff] [blame] | 43 | |
| 44 | // TODO(shepshapard): Figure out how to test composite gesture detectors better. There should be |
| 45 | // more tests, but hopefully they can also be easier to write then what is currently available. |
| 46 | // Should possibly wait till we have host side testing that does not require the Android runtime. |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 47 | |
| 48 | @LargeTest |
| 49 | @RunWith(JUnit4::class) |
Shep Shapard | ad4e815 | 2020-04-03 13:22:08 -0700 | [diff] [blame] | 50 | class LongPressDragGestureFilterTest { |
Aurimas Liutikas | 506ab64d | 2020-06-02 14:37:26 -0700 | [diff] [blame] | 51 | @Suppress("DEPRECATION") |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 52 | @get:Rule |
Aurimas Liutikas | 506ab64d | 2020-06-02 14:37:26 -0700 | [diff] [blame] | 53 | val activityTestRule = androidx.test.rule.ActivityTestRule<TestActivity>( |
| 54 | TestActivity::class.java |
| 55 | ) |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 56 | private lateinit var longPressDragObserver: LongPressDragObserver |
| 57 | private lateinit var longPressCountDownLatch: CountDownLatch |
| 58 | private lateinit var view: View |
| 59 | |
| 60 | @Before |
| 61 | fun setup() { |
| 62 | longPressDragObserver = spy(MyLongPressDragObserver { |
| 63 | longPressCountDownLatch.countDown() |
| 64 | }) |
| 65 | |
| 66 | val activity = activityTestRule.activity |
Adam Powell | a1f55b9 | 2020-04-20 16:32:38 -0700 | [diff] [blame] | 67 | assertTrue("timed out waiting for activity focus", |
| 68 | activity.hasFocusLatch.await(5, TimeUnit.SECONDS)) |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 69 | |
| 70 | val setupLatch = CountDownLatch(2) |
| 71 | activityTestRule.runOnUiThreadIR { |
| 72 | activity.setContent { |
Mihai Popa | 376868d | 2020-03-30 10:27:56 +0100 | [diff] [blame] | 73 | Stack { |
| 74 | Layout( |
| 75 | modifier = Modifier.longPressDragGestureFilter(longPressDragObserver), |
Anastasia Soboleva | 5e382dd | 2020-06-17 21:51:38 +0100 | [diff] [blame] | 76 | measureBlock = { _, _ -> |
George Mount | 8f23757 | 2020-04-30 12:08:30 -0700 | [diff] [blame] | 77 | layout(100, 100) { |
Mihai Popa | 376868d | 2020-03-30 10:27:56 +0100 | [diff] [blame] | 78 | setupLatch.countDown() |
| 79 | } |
| 80 | }, children = emptyContent() |
| 81 | ) |
| 82 | } |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | view = activity.findViewById<ViewGroup>(android.R.id.content) |
| 86 | setupLatch.countDown() |
| 87 | } |
Adam Powell | a1f55b9 | 2020-04-20 16:32:38 -0700 | [diff] [blame] | 88 | assertTrue("timed out waiting for setup completion", |
| 89 | setupLatch.await(1000, TimeUnit.SECONDS)) |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 90 | } |
| 91 | |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 92 | @Test |
| 93 | fun ui_downMoveUpBeforeLongPressTimeout_noCallbacksCalled() { |
| 94 | |
| 95 | val down = MotionEvent( |
| 96 | 0, |
| 97 | MotionEvent.ACTION_DOWN, |
| 98 | 1, |
| 99 | 0, |
| 100 | arrayOf(PointerProperties(0)), |
Shep Shapard | e87a100 | 2020-07-16 12:32:35 -0700 | [diff] [blame] | 101 | arrayOf(PointerCoords(50f, 50f)), |
| 102 | view |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 103 | ) |
| 104 | val move = MotionEvent( |
| 105 | 0, |
| 106 | MotionEvent.ACTION_MOVE, |
| 107 | 1, |
| 108 | 0, |
| 109 | arrayOf(PointerProperties(0)), |
Shep Shapard | e87a100 | 2020-07-16 12:32:35 -0700 | [diff] [blame] | 110 | arrayOf(PointerCoords(51f, 50f)), |
| 111 | view |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 112 | ) |
| 113 | val up = MotionEvent( |
| 114 | 0, |
| 115 | MotionEvent.ACTION_UP, |
| 116 | 1, |
| 117 | 0, |
| 118 | arrayOf(PointerProperties(0)), |
Shep Shapard | e87a100 | 2020-07-16 12:32:35 -0700 | [diff] [blame] | 119 | arrayOf(PointerCoords(51f, 50f)), |
| 120 | view |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 121 | ) |
| 122 | activityTestRule.runOnUiThreadIR { |
| 123 | view.dispatchTouchEvent(down) |
| 124 | view.dispatchTouchEvent(move) |
| 125 | view.dispatchTouchEvent(up) |
| 126 | } |
| 127 | |
| 128 | verifyNoMoreInteractions(longPressDragObserver) |
| 129 | } |
| 130 | |
Shep Shapard | bf513c5 | 2019-12-16 17:06:51 -0800 | [diff] [blame] | 131 | @Test |
| 132 | fun ui_downMoveCancelBeforeLongPressTimeout_noCallbacksCalled() { |
| 133 | |
| 134 | val down = MotionEvent( |
| 135 | 0, |
| 136 | MotionEvent.ACTION_DOWN, |
| 137 | 1, |
| 138 | 0, |
| 139 | arrayOf(PointerProperties(0)), |
Shep Shapard | e87a100 | 2020-07-16 12:32:35 -0700 | [diff] [blame] | 140 | arrayOf(PointerCoords(50f, 50f)), |
| 141 | view |
Shep Shapard | bf513c5 | 2019-12-16 17:06:51 -0800 | [diff] [blame] | 142 | ) |
| 143 | val move = MotionEvent( |
| 144 | 0, |
| 145 | MotionEvent.ACTION_MOVE, |
| 146 | 1, |
| 147 | 0, |
| 148 | arrayOf(PointerProperties(0)), |
Shep Shapard | e87a100 | 2020-07-16 12:32:35 -0700 | [diff] [blame] | 149 | arrayOf(PointerCoords(51f, 50f)), |
| 150 | view |
Shep Shapard | bf513c5 | 2019-12-16 17:06:51 -0800 | [diff] [blame] | 151 | ) |
| 152 | val cancel = MotionEvent( |
| 153 | 0, |
| 154 | MotionEvent.ACTION_CANCEL, |
| 155 | 1, |
| 156 | 0, |
| 157 | arrayOf(PointerProperties(0)), |
Shep Shapard | e87a100 | 2020-07-16 12:32:35 -0700 | [diff] [blame] | 158 | arrayOf(PointerCoords(51f, 50f)), |
| 159 | view |
Shep Shapard | bf513c5 | 2019-12-16 17:06:51 -0800 | [diff] [blame] | 160 | ) |
| 161 | activityTestRule.runOnUiThreadIR { |
| 162 | view.dispatchTouchEvent(down) |
| 163 | view.dispatchTouchEvent(move) |
| 164 | view.dispatchTouchEvent(cancel) |
| 165 | } |
| 166 | |
| 167 | verifyNoMoreInteractions(longPressDragObserver) |
| 168 | } |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 169 | |
| 170 | @Test |
Shep Shapard | bf513c5 | 2019-12-16 17:06:51 -0800 | [diff] [blame] | 171 | fun ui_downWaitForLongPress_onlyOnLongPressCalled() { |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 172 | |
| 173 | val down = MotionEvent( |
| 174 | 0, |
| 175 | MotionEvent.ACTION_DOWN, |
| 176 | 1, |
| 177 | 0, |
| 178 | arrayOf(PointerProperties(0)), |
Shep Shapard | e87a100 | 2020-07-16 12:32:35 -0700 | [diff] [blame] | 179 | arrayOf(PointerCoords(50f, 50f)), |
| 180 | view |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 181 | ) |
| 182 | waitForLongPress { |
| 183 | view.dispatchTouchEvent(down) |
| 184 | } |
| 185 | |
| 186 | verify(longPressDragObserver).onLongPress(any()) |
| 187 | verifyNoMoreInteractions(longPressDragObserver) |
| 188 | } |
| 189 | |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 190 | @Test |
Shep Shapard | bf513c5 | 2019-12-16 17:06:51 -0800 | [diff] [blame] | 191 | fun ui_downWaitForLongPressMove_callbacksCorrect() { |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 192 | |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 193 | val down = MotionEvent( |
| 194 | 0, |
| 195 | MotionEvent.ACTION_DOWN, |
| 196 | 1, |
| 197 | 0, |
| 198 | arrayOf(PointerProperties(0)), |
Shep Shapard | e87a100 | 2020-07-16 12:32:35 -0700 | [diff] [blame] | 199 | arrayOf(PointerCoords(50f, 50f)), |
| 200 | view |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 201 | ) |
| 202 | waitForLongPress { |
| 203 | view.dispatchTouchEvent(down) |
| 204 | } |
| 205 | val move = MotionEvent( |
| 206 | 0, |
| 207 | MotionEvent.ACTION_MOVE, |
| 208 | 1, |
| 209 | 0, |
| 210 | arrayOf(PointerProperties(0)), |
Shep Shapard | e87a100 | 2020-07-16 12:32:35 -0700 | [diff] [blame] | 211 | arrayOf(PointerCoords(51f, 50f)), |
| 212 | view |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 213 | ) |
| 214 | view.dispatchTouchEvent(move) |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 215 | |
Shep Shapard | bf513c5 | 2019-12-16 17:06:51 -0800 | [diff] [blame] | 216 | inOrder(longPressDragObserver) { |
| 217 | verify(longPressDragObserver).onLongPress(any()) |
| 218 | verify(longPressDragObserver).onDragStart() |
| 219 | // Twice because DragGestureDetector dispatches onDrag during 2 passes. |
| 220 | verify(longPressDragObserver, times(2)).onDrag(any()) |
| 221 | } |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 222 | verifyNoMoreInteractions(longPressDragObserver) |
| 223 | } |
| 224 | |
| 225 | @Test |
Shep Shapard | bf513c5 | 2019-12-16 17:06:51 -0800 | [diff] [blame] | 226 | fun ui_downWaitForLongPressUp_callbacksCorrect() { |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 227 | |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 228 | val down = MotionEvent( |
| 229 | 0, |
| 230 | MotionEvent.ACTION_DOWN, |
| 231 | 1, |
| 232 | 0, |
| 233 | arrayOf(PointerProperties(0)), |
Shep Shapard | e87a100 | 2020-07-16 12:32:35 -0700 | [diff] [blame] | 234 | arrayOf(PointerCoords(50f, 50f)), |
| 235 | view |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 236 | ) |
| 237 | waitForLongPress { |
| 238 | view.dispatchTouchEvent(down) |
| 239 | } |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 240 | val up = MotionEvent( |
| 241 | 0, |
| 242 | MotionEvent.ACTION_UP, |
| 243 | 1, |
| 244 | 0, |
| 245 | arrayOf(PointerProperties(0)), |
Shep Shapard | e87a100 | 2020-07-16 12:32:35 -0700 | [diff] [blame] | 246 | arrayOf(PointerCoords(51f, 50f)), |
| 247 | view |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 248 | ) |
| 249 | view.dispatchTouchEvent(up) |
| 250 | |
| 251 | // Assert. |
Shep Shapard | bf513c5 | 2019-12-16 17:06:51 -0800 | [diff] [blame] | 252 | inOrder(longPressDragObserver) { |
| 253 | verify(longPressDragObserver).onLongPress(any()) |
| 254 | verify(longPressDragObserver).onStop(any()) |
| 255 | } |
| 256 | verifyNoMoreInteractions(longPressDragObserver) |
| 257 | } |
| 258 | |
| 259 | @Test |
| 260 | fun ui_downWaitForLongPressMoveUp_callbacksCorrect() { |
| 261 | |
| 262 | val down = MotionEvent( |
| 263 | 0, |
| 264 | MotionEvent.ACTION_DOWN, |
| 265 | 1, |
| 266 | 0, |
| 267 | arrayOf(PointerProperties(0)), |
Shep Shapard | e87a100 | 2020-07-16 12:32:35 -0700 | [diff] [blame] | 268 | arrayOf(PointerCoords(50f, 50f)), |
| 269 | view |
Shep Shapard | bf513c5 | 2019-12-16 17:06:51 -0800 | [diff] [blame] | 270 | ) |
| 271 | waitForLongPress { |
| 272 | view.dispatchTouchEvent(down) |
| 273 | } |
| 274 | val move = MotionEvent( |
| 275 | 0, |
| 276 | MotionEvent.ACTION_MOVE, |
| 277 | 1, |
| 278 | 0, |
| 279 | arrayOf(PointerProperties(0)), |
Shep Shapard | e87a100 | 2020-07-16 12:32:35 -0700 | [diff] [blame] | 280 | arrayOf(PointerCoords(51f, 50f)), |
| 281 | view |
Shep Shapard | bf513c5 | 2019-12-16 17:06:51 -0800 | [diff] [blame] | 282 | ) |
| 283 | view.dispatchTouchEvent(move) |
| 284 | val up = MotionEvent( |
| 285 | 0, |
| 286 | MotionEvent.ACTION_UP, |
| 287 | 1, |
| 288 | 0, |
| 289 | arrayOf(PointerProperties(0)), |
Shep Shapard | e87a100 | 2020-07-16 12:32:35 -0700 | [diff] [blame] | 290 | arrayOf(PointerCoords(51f, 50f)), |
| 291 | view |
Shep Shapard | bf513c5 | 2019-12-16 17:06:51 -0800 | [diff] [blame] | 292 | ) |
| 293 | view.dispatchTouchEvent(up) |
| 294 | |
| 295 | inOrder(longPressDragObserver) { |
| 296 | verify(longPressDragObserver).onLongPress(any()) |
| 297 | verify(longPressDragObserver).onDragStart() |
| 298 | // Twice because DragGestureDetector dispatches onDrag during 2 passes. |
| 299 | verify(longPressDragObserver, times(2)).onDrag(any()) |
| 300 | verify(longPressDragObserver).onStop(any()) |
| 301 | } |
| 302 | verifyNoMoreInteractions(longPressDragObserver) |
| 303 | } |
| 304 | |
| 305 | @Test |
| 306 | fun ui_downWaitForLongPressCancel_callbacksCorrect() { |
| 307 | |
| 308 | val down = MotionEvent( |
| 309 | 0, |
| 310 | MotionEvent.ACTION_DOWN, |
| 311 | 1, |
| 312 | 0, |
| 313 | arrayOf(PointerProperties(0)), |
Shep Shapard | e87a100 | 2020-07-16 12:32:35 -0700 | [diff] [blame] | 314 | arrayOf(PointerCoords(50f, 50f)), |
| 315 | view |
Shep Shapard | bf513c5 | 2019-12-16 17:06:51 -0800 | [diff] [blame] | 316 | ) |
| 317 | waitForLongPress { |
| 318 | view.dispatchTouchEvent(down) |
| 319 | } |
| 320 | val cancel = MotionEvent( |
| 321 | 0, |
| 322 | MotionEvent.ACTION_CANCEL, |
| 323 | 1, |
| 324 | 0, |
| 325 | arrayOf(PointerProperties(0)), |
Shep Shapard | e87a100 | 2020-07-16 12:32:35 -0700 | [diff] [blame] | 326 | arrayOf(PointerCoords(50f, 50f)), |
| 327 | view |
Shep Shapard | bf513c5 | 2019-12-16 17:06:51 -0800 | [diff] [blame] | 328 | ) |
| 329 | view.dispatchTouchEvent(cancel) |
| 330 | |
| 331 | inOrder(longPressDragObserver) { |
| 332 | verify(longPressDragObserver).onLongPress(any()) |
| 333 | verify(longPressDragObserver).onCancel() |
| 334 | } |
| 335 | verifyNoMoreInteractions(longPressDragObserver) |
| 336 | } |
| 337 | |
| 338 | @Test |
| 339 | fun ui_downWaitForLongPressMoveCancel_callbacksCorrect() { |
| 340 | |
| 341 | val down = MotionEvent( |
| 342 | 0, |
| 343 | MotionEvent.ACTION_DOWN, |
| 344 | 1, |
| 345 | 0, |
| 346 | arrayOf(PointerProperties(0)), |
Shep Shapard | e87a100 | 2020-07-16 12:32:35 -0700 | [diff] [blame] | 347 | arrayOf(PointerCoords(50f, 50f)), |
| 348 | view |
Shep Shapard | bf513c5 | 2019-12-16 17:06:51 -0800 | [diff] [blame] | 349 | ) |
| 350 | waitForLongPress { |
| 351 | view.dispatchTouchEvent(down) |
| 352 | } |
| 353 | val move = MotionEvent( |
| 354 | 0, |
| 355 | MotionEvent.ACTION_MOVE, |
| 356 | 1, |
| 357 | 0, |
| 358 | arrayOf(PointerProperties(0)), |
Shep Shapard | e87a100 | 2020-07-16 12:32:35 -0700 | [diff] [blame] | 359 | arrayOf(PointerCoords(51f, 50f)), |
| 360 | view |
Shep Shapard | bf513c5 | 2019-12-16 17:06:51 -0800 | [diff] [blame] | 361 | ) |
| 362 | view.dispatchTouchEvent(move) |
| 363 | val cancel = MotionEvent( |
| 364 | 0, |
| 365 | MotionEvent.ACTION_CANCEL, |
| 366 | 1, |
| 367 | 0, |
| 368 | arrayOf(PointerProperties(0)), |
Shep Shapard | e87a100 | 2020-07-16 12:32:35 -0700 | [diff] [blame] | 369 | arrayOf(PointerCoords(51f, 50f)), |
| 370 | view |
Shep Shapard | bf513c5 | 2019-12-16 17:06:51 -0800 | [diff] [blame] | 371 | ) |
| 372 | view.dispatchTouchEvent(cancel) |
| 373 | |
| 374 | inOrder(longPressDragObserver) { |
| 375 | verify(longPressDragObserver).onLongPress(any()) |
| 376 | verify(longPressDragObserver).onDragStart() |
| 377 | // Twice because DragGestureDetector dispatches onDrag during 2 passes. |
| 378 | verify(longPressDragObserver, times(2)).onDrag(any()) |
| 379 | verify(longPressDragObserver).onCancel() |
| 380 | } |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 381 | verifyNoMoreInteractions(longPressDragObserver) |
| 382 | } |
| 383 | |
| 384 | private fun waitForLongPress(block: () -> Unit) { |
| 385 | longPressCountDownLatch = CountDownLatch(1) |
Louis Pullen-Freilich | 54b4c11 | 2019-10-23 19:05:56 +0100 | [diff] [blame] | 386 | activityTestRule.runOnUiThreadIR(block) |
Adam Powell | a1f55b9 | 2020-04-20 16:32:38 -0700 | [diff] [blame] | 387 | assertTrue("timed out waiting for long press", |
| 388 | longPressCountDownLatch.await(750, TimeUnit.MILLISECONDS)) |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 389 | } |
| 390 | } |
| 391 | |
| 392 | @Suppress("RedundantOverride") |
| 393 | open class MyLongPressDragObserver(val onLongPress: () -> Unit) : LongPressDragObserver { |
Nader Jawad | 6df0612 | 2020-06-03 15:27:08 -0700 | [diff] [blame] | 394 | override fun onLongPress(pxPosition: Offset) { |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 395 | onLongPress() |
| 396 | } |
| 397 | |
Shep Shapard | bf513c5 | 2019-12-16 17:06:51 -0800 | [diff] [blame] | 398 | override fun onDragStart() {} |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 399 | |
Nader Jawad | 6df0612 | 2020-06-03 15:27:08 -0700 | [diff] [blame] | 400 | override fun onDrag(dragDistance: Offset): Offset { |
shepshapard | d9f0523 | 2019-08-08 10:21:47 -0700 | [diff] [blame] | 401 | return super.onDrag(dragDistance) |
| 402 | } |
| 403 | |
Nader Jawad | 6df0612 | 2020-06-03 15:27:08 -0700 | [diff] [blame] | 404 | override fun onStop(velocity: Offset) {} |
shepshapard | b14d643 | 2019-08-05 17:13:22 -0700 | [diff] [blame] | 405 | } |