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.
@josenicolasjohnengonzalez29543 жыл бұрын
@Alon Mittelman Can you expand on that?
@algodextrous3 жыл бұрын
how to add onLongTouch Event listerner to a image view in this so it doesnt override swipe gestures?
@gckoch13 жыл бұрын
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...)
@discospiff3 жыл бұрын
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. :)
@mhndalof28722 жыл бұрын
is this applicable on wear app?
@marquisrobinson14093 жыл бұрын
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?
@marquisrobinson14093 жыл бұрын
Great video btw very helpful
@marquisrobinson14093 жыл бұрын
I know I can use theLayout.setBackgroundColor (Color.rgb(Random.nextInt(until: 256),Random.nextInt(until: 256),Random.nextInt(until:256)))
@yahianad4 жыл бұрын
Great video of Great Master !
@discospiff4 жыл бұрын
Thanks!
@yahianad4 жыл бұрын
@@discospiff I think it works too if we override "onDispatchTouchEvent" instead of "onTouchEvent" ?
@wenhaochong74664 жыл бұрын
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?
@discospiff4 жыл бұрын
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.
@wenhaochong74664 жыл бұрын
@@discospiff Thanks!
@wenhaochong74664 жыл бұрын
@@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 })) }
@khaxbiker3 жыл бұрын
Great video, Like and Subs. Now let see if I´m able to adapt to my fragment :-)