Handle Swipe Left, Right, Top, Bottom gesture events in Android Kotlin Example

  Рет қаралды 8,431

Brandan Jones

Brandan Jones

Күн бұрын

Пікірлер: 18
@olamao
@olamao 4 жыл бұрын
Excellent explanations. I am trying to use this code on a fragment but there is no onTouchEvent to override and then I got stocked. I have tried but failed miserably. I would appreciate if you have a suggestion.
@josenicolasjohnengonzalez2954
@josenicolasjohnengonzalez2954 3 жыл бұрын
@Alon Mittelman Can you expand on that?
@algodextrous
@algodextrous 3 жыл бұрын
how to add onLongTouch Event listerner to a image view in this so it doesnt override swipe gestures?
@gckoch1
@gckoch1 3 жыл бұрын
Thanks, Brandan, for the _working_ code based on the recent Gesturexxx object from Jetbrains. How did you find that object? Is there a new object list someplace? You're right about swipe direction: flings ought to follow the "natural" direction a finger takes while turning the page of a book. (BTW I want to add the point this comment comes from someone bothered by the antiquated call icon on smartphones...)
@discospiff
@discospiff 3 жыл бұрын
Thanks for the feedback! How did I find which object? As I recall, I used Model View View Model in this video, so the ViewModel owns the state. It gets a bit tricky with Activity versus View, though, as there has to be a way for them to communicate state with each other. I remember old school phones with earpiece and receiver. And floppy disks that were not save icons. Things were better back then... pre-COVID, pre-9/11, pre-financial crisis. I'd go back if I could. :)
@mhndalof2872
@mhndalof2872 2 жыл бұрын
is this applicable on wear app?
@marquisrobinson1409
@marquisrobinson1409 3 жыл бұрын
Say I wanted to have the background color change each swipe from right to left. Red if going towards left and violet if swiping towards right. How would I implement that into code?
@marquisrobinson1409
@marquisrobinson1409 3 жыл бұрын
Great video btw very helpful
@marquisrobinson1409
@marquisrobinson1409 3 жыл бұрын
I know I can use theLayout.setBackgroundColor (Color.rgb(Random.nextInt(until: 256),Random.nextInt(until: 256),Random.nextInt(until:256)))
@yahianad
@yahianad 4 жыл бұрын
Great video of Great Master !
@discospiff
@discospiff 4 жыл бұрын
Thanks!
@yahianad
@yahianad 4 жыл бұрын
@@discospiff I think it works too if we override "onDispatchTouchEvent" instead of "onTouchEvent" ?
@wenhaochong7466
@wenhaochong7466 4 жыл бұрын
Awesome video! Btw, I noticed that the swipes wouldn't register when I start swiping from an image button. Is there a way to overcome this?
@discospiff
@discospiff 4 жыл бұрын
Funny enough, I noticed the same thing about recyclerview today. You can tell it to ignore touch events, but then the button or recyclerview won't do what it's supposed to do, either. I'm looking for a solution tonight or tomorrow, will let you know what I find.
@wenhaochong7466
@wenhaochong7466 4 жыл бұрын
@@discospiff Thanks!
@wenhaochong7466
@wenhaochong7466 4 жыл бұрын
@@discospiff I finally got it! Swipe from and tapping on an image button was possible after setting ontouchlistener to the button and adding onSingleTapConfirmed to the gesture listener. For my calendar app with 35 cells, I added this: for (i in 0..34) { cellList[i].box.setOnTouchListener(View.OnTouchListener(fun(view: View, event: MotionEvent): Boolean { if (detector.onTouchEvent(event)) { return false } else if (appGestureListener().onSingleTapConfirmed(event)) { return false } return true })) }
@khaxbiker
@khaxbiker 3 жыл бұрын
Great video, Like and Subs. Now let see if I´m able to adapt to my fragment :-)
@discospiff
@discospiff 3 жыл бұрын
Thanks. Good luck, let me know how it goes!
5 Fatal Coroutine Mistakes Nobody Tells You About
18:15
Philipp Lackner
Рет қаралды 88 М.
Implement swipe up down left right with onFling Android
17:31
Brandan Jones
Рет қаралды 27 М.
Triple kill😹
00:18
GG Animation
Рет қаралды 18 МЛН
My MEAN sister annoys me! 😡 Use this gadget #hack
00:24
PRANK😂 rate Mark’s kick 1-10 🤕
00:14
Diana Belitskay
Рет қаралды 9 МЛН
Disrespect or Respect 💔❤️
00:27
Thiago Productions
Рет қаралды 37 МЛН
droidcon SF 2017 - Canvas Drawing for Fun and Profit
40:39
droidcon SF
Рет қаралды 14 М.
Functional Programming in 40 Minutes • Russ Olsen • GOTO 2018
41:35
GOTO Conferences
Рет қаралды 818 М.
Full Guide to Jetpack Compose Effect Handlers
24:56
Philipp Lackner
Рет қаралды 97 М.
Activity Result API , Kotlin Ep.24
35:28
Caege
Рет қаралды 21
How to Migrate XML ↔ Compose - Android Studio Tutorial
11:33
Philipp Lackner
Рет қаралды 30 М.
Android Gestures: Getting Started
19:16
CodingWithMitch
Рет қаралды 55 М.
Spring Data JPA Tutorial | Full In-depth Course
2:20:14
Daily Code Buffer
Рет қаралды 391 М.
Delegating delegates - Kotlin Vocabulary
8:44
Android Developers
Рет қаралды 26 М.
Triple kill😹
00:18
GG Animation
Рет қаралды 18 МЛН