android - Can't figure out how to hook fling using ImageViewTouch -
I am using the library () but I have a problem trying to remove the fling I have read other answers But they do not use the actual code while tilting the events.
I have tilted the events like this:
mImage SetOnTouchListener (new on-tailiston () {@ Override Public Boolean on Touch (see V, Motion Event Event ) {Return gesture detector.ToehEvent (Event);}}); Gesture detector = new gesture detector (this, new MyGestureDetector (getApplicationContext (), this)); MyGestureDetector Extends SimpleOnGestureListener I then override the OFFLING method.
The problem with this approach is that it disables 1 touch and therefore the pan functionality I'm sure is a better way to hook into fling events (so I can change the images), but I'm not sure how -Nub: (
What I see is the way to hook it is similar to other hooks provided by ImageViewZoom. In this way:
mImage = (ImageViewTouch) view.findViewById (R.id.image); mImage.setOnClickListener (this); // Set DI Log on to the default image display type mImage.setDisplayType (ImageViewTouchBase.DisplayType.FIT_TO_SCREEN); mImage.setSingleTapListener (New ImageViewTouch.OnImageViewTouchSingleTapListener) {@SingleTapConfirmed (), ("Log on," On-SingleTap Confirmed "), SetubblersVisible (! ITubularVijay ());}};
Note: I tested myself / coded So, it can not work out of the box.
I checked the source code for the ImageViewTouch - it's internally different To ray using SimpleOnGestureListener that is based functionality (single-tap and including Uble- tap hook). This does not provide a callback for the fling event, therefore, you have to code yourself which is itself Start by defining a new interface, say OnImageViewTouchFlingEventListener inside / out ImageViewTouch.java . For example - Define it after the line 320 of ImageViewTouch.java : The public interface OnImageViewTouchFlingEventListener {// can be defined as 'idle zero' (boolean left) `= = & Gt; If left == is true, then user / 'right to right' fling, and 'right to left'. Similarly, you can modify the parameters to add checks for up-to-down and down-to-up. Zero onFingEvent (); }
Next, add a member to ImageViewTouch.java after line 31:
Private Onisseuse viewfiguredigentlestner mFlingEventListener; Adding a public method to start mFlingEventListener after line 64:
Public Zero setFlingEventListener (OnImageViewTouchFlingEventListener Listener) {mFlingEventListener = Listener; } Line of 261 ImageViewTouch.java : Method onFling (.....) defines how ImageView fling Reaction organizes First of all, check whether you agree with the current functionality or not. For example, you mentioned that you want to change the images. If you look at line 266, then the fling event will not do anything for the current start 1 - it only returns false.
How ImageView works for a inclination (and in what circumstances) is something that you will need to decide. Say, you decide that throw will only replace images when large enough will be one - otherwise, this will be a pan, then the following modification 266 line should work:
if (getScale () == 1f) {if (! MFlingEventListener = null) {mFlingEventListener.onFlingEvent (); Back true; }} In your code, when you define a OnTouchListener on ImageViewTouch, it overtakes all touch functionality provided by handling the internal touch / gesture of ImageViewTouch - Therefore, no single / double tap callback is the reason why you can not apply fling event callback outside ImageViewTouch.java - well, you can - but then, you everything else gesture Along with
will be required to implement the changes. For your activity code:
mImage.setFlingEventListener (New ImageViewTouch.OnImageViewTouchFlingEventListener () {@Override: Member mFlingEventListener needs to be started On the public's zero-flingEvent () {Log D. (tag, "Brick shot on"); // Change the image to change}});
Comments
Post a Comment