Using TouchImageView in RecyclerView attached with PageSnapHelper? - android-recyclerview

My app is doing a gallery which uses TouchImageView on RecyclerView.
I was trying to use this class to display multiple fullscreen images in a RecyclerView attached with PageSnapHelper
This works fine, but the zooming is very awkward to use .If I try to pinch zoom , the image moving left and right but not zooming. Only double Tap works.
I think there is a conflict with the swiping and scrolling of the RecyclerView attached with PageSnapHelper .
How can I make the TouchImageView touch events override the PageSnapHelper events when pinch zoomed byt swiping also works when swiped?
To be simple , I want the same behavior of Chat Apps(Whatsapp and telegram) Image Slider which supports both swiping and pinch zooming
Note , I searched the stackoverflow but there are only solutions for ViewPagers but no recyclerview

Im not exactly sure what you are asking here, but if I got it right, the problem is you can't pinch zoom because the RecyclerView is recognising your pinch action as a swipe.
If you wanted, you could always disallow the RecyclerView from intercepting the touch event (and handle the event yourself) by calling:
view.parent.requestDisallowInterceptTouchEvent(true)
inside the onTouch method of the PrivateOnTouchListener.
If you want a simpler solution, you could also check if the current view is zoomed or if at least 2 fingers are touching the view. If yes, disallow the parent to intercept the touch event. The inside the PrivateOnTouchListener code would then look like this:
if (isZoomed || event.pointerCount >= 2) {
v.parent.requestDisallowInterceptTouchEvent(true)
}
The parent will now only be allowed to intercept the touch event if the view isn't zoomed and if only one finger is touching the view.

Related

React Native Slider should receive swipe and touch gestures, but these are sent to parent ScrollView on Android

In my app, I have horizontal FlatList which is used for swiping between several sub-pages of a screen. This works great.
However, on one of the pages, I have a Slider component. On iOS it works fine, but on Android, the parent ScrollView of the FlatList seems to "steal" the swipe gesture. I am only able to adjust the Slider by clicking very precisely on its thin line, but I cannot adjust it by sliding.
What I need is something like one of these
A view that wraps the Slider component and stops swipe gestures from being propagated to the parent ScrollView
A way to make the FlatList/ScrollView not consume swipes directly on elements that responds to horizontal swipes themself
Somehow adjust the area of which the Slider component will eat the touches around it (it's very small and hard to hit directly). I already tried adding a hitSlop prop, with no luck.
Any suggestions for a solution are very appreciated :)
Check example code and result here.
https://snack.expo.io/#esbenvb/mad-yogurt

How to forward pointer events

I was able to get this working in iOS but I am having trouble with Win 8. What I need to do is this:
I have a drawing view that is the forward most child of a ScrollViewer. When I enable drawing mode from a button in the app bar, this view becomes active. With one touch, I want the user to be able to perform the current drawing action, but with two touches I want the touches to go to the scroll view instead for scrolling and zooming. I am able to distinguish between 1 and 2 (or more) fingers, but I don't know what to do after that point.
I tried removing the manipulation mode from the drawing view so that it would not block the scroll view, but the touches continued to be swallowed by the drawing view. I also tried calling ReleasePointerCapture but that had no effect either. How can I forward touch events using the WinRT API?
For some more information, I am making use of the PointerPressed, PointerChanged, etc events in the drawing view.

UIButton not responsive while scrolling

I have a subview with a UIButton added to a UIScrollView.
The button is working perfectly as long as the user isn't scrolling.
If the UIScrollView is still scrolling when the user clicks on the button, it just stops the scrolling instead(like if a row had been clicked).
Anyone know how to fix this?
First, make sure this really is the behavior you want - iOS users are used to scrolling views and touching to stop them with a tap without triggering button presses. Non-standard behavior (even when you think its better then the standard behavior) can be confusing to users used to how things work in other iOS apps - it can violate their mental model. Ok, note of caution over.
So how do you fix this? UIScrollView delays sending touch events until it knows if those touches are scroll events. You problem is a user tapping is a scroll event when the UIScrollView is moving. Two possible solutions:
Stop the UIScrollView from delaying any touch events it gets. You can set any scroll views delaysContentTouches to NO, which will stop the delaying action and should allow your buttons to be tapped while scrolling. You can read about it in the UIScrollView class documentation. You will also want to read up on canCancelContentTouches there as well.
Subclass the UIScrollView to add your own logic about where touch events should go. Here is a blog post that discusses how to do this.

UIPanGestureRecognizer with UIPageViewController

I am using a UIPageViewController to display certain content. I want to be able to display additional content when the user pulls down on the page using a UIPanGestureRecognizer. I can't seem to figure out what I should add my gesture recognizer to such that it does not cancel any of the pageviewcontroller's actions.
One of the apps I worked on has functionality similar to this. It shows a full-screen UIPageViewController, but if the user drags down on a ribbon on the top right corner, it will slide the whole thing down to reveal a view behind (for settings and other stuff).
I think your problem is that the built-in gesture recognizers are for the page turns. So what you'd want to do is either have something to drag on (such as the ribbon on the top left in my app) that will have its own gestures. OR you can iterate through the gesture recognizers that are assigned to UIPageViewController and get the one that matches the PanGesture, then override it with your own functionality to either delegate the event to the UIPageViewController or do the slide down, based on the type of pan.
Hope that helps.

ios simulator: simulate swipe and drag

I have a UIView within a UIScrollView. When i want to simulate the drag event on the UIView, swipe event on the UIScrollView is being triggered.
As per the documentation , there isn't much of a difference between swipe and drag.
Swipe
1- Place the pointer at the start position.
2- Hold the mouse button.
3- Move the pointer in the swipe direction and release the mouse button.
Drag
1- Place the pointer at the start position.
2- Hold down the mouse button.
3- Move the pointer in the drag direction.
On an ipad I can use two fingers two swipe and one finger to drag. Now, how do i go about doing something similar on the simulator; drag instead of a swipe?
Edit 1:
I should have been clearer first up. Anyway, my problem is that the mouse drag is firing the swipe instead of drag, thereby scrolling the scroll view instead of passing on the drag event to the UIView contained by the scroll view.
I am on macbook pro. Two-finger swipe on the touchpad is being ignored. Touch and drag is causing the same thing as mouse-drag.
Thanks
See Jeff LaMarche's quick note on how to do this. It's documented in the same page you're reading, but Jeff's explanation is clearer.
If you want to simulate a two-finger gesture in the iPhone simulator, hold down the option key. You will get two dots on the screen instead of one. The two dots will default to pinching - if you bring the dot closer to the center of the screen, the other dot comes toward the center, making it easy to simulate a pinch in or pinch out.
If you want to do a different two-finger gesture, get the two dots the distance apart that you want them to be, then hold down the shift key, while still holding down the option key. That will lock the position of the two finger presses together so you can do, for example, a two-finger swipe.
see this documentation below:
iOS Simulator User Guide
Just use the mouse to drag the view, aka, left click the view then move the mouse
I ended up disabling the scrolling from the UI and added two buttons to scroll the scroll view. Since this is a work around only for the emulator, I have used #ifndef to hide the buttons while building for the device.