List of usage examples for android.view GestureDetector GestureDetector
public GestureDetector(Context context, OnGestureListener listener)
From source file:org.protocoderrunner.apprunner.api.PUI.java
@ProtocoderScript @APIMethod(description = "Starts a gesture detector over a view", example = "") @APIParam(params = { "View", "function(data)" }) //http://stackoverflow.com/questions/6599329/can-one-ongesturelistener-object-deal-with-two-gesturedetector-objects public void gestureDetector(View v, final addGestureDetectorCB cb) { final GestureDetectorReturn g = new GestureDetectorReturn(); final GestureDetector gestureDetector = new GestureDetector(a.get(), new GestureDetector.OnGestureListener() { @Override//from w w w. j av a 2s .c om public boolean onSingleTapUp(MotionEvent e) { g.type = "up"; cb.event(g); return false; } @Override public void onShowPress(MotionEvent e) { g.type = "showpress"; cb.event(g); } @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { g.type = "scroll"; g.data = new JSONObject(); try { g.data.put("distanceX", distanceX); g.data.put("distanceY", distanceY); } catch (JSONException e) { e.printStackTrace(); } cb.event(g); return true; } @Override public void onLongPress(MotionEvent e) { g.type = "longpress"; cb.event(g); } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { g.type = "fling"; g.data = new JSONObject(); try { g.data.put("velocityX", velocityX); g.data.put("velocityY", velocityY); } catch (JSONException e) { e.printStackTrace(); } cb.event(g); return true; } @Override public boolean onDown(MotionEvent e) { g.type = "down"; cb.event(g); return true; } }); final ScaleGestureDetector scaleGestureDetector = new ScaleGestureDetector(a.get(), new OnScaleGestureListener() { @Override public boolean onScale(ScaleGestureDetector scaleGestureDetector) { g.type = "scale"; cb.event(g); return false; } @Override public boolean onScaleBegin(ScaleGestureDetector scaleGestureDetector) { g.type = "scaleBegin"; cb.event(g); return false; } @Override public void onScaleEnd(ScaleGestureDetector scaleGestureDetector) { g.type = "scaleEnd"; cb.event(g); } }); v.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { scaleGestureDetector.onTouchEvent(event); if (scaleGestureDetector.isInProgress()) return true; gestureDetector.onTouchEvent(event); return true; } }); }
From source file:com.owen.view.views.PieChart.java
/** * Initialize the control. This code is in a separate method so that it can be * called from both constructors./*from w ww . j a va 2 s .c o m*/ */ private void init() { // Force the background to software rendering because otherwise the Blur // filter won't work. setLayerToSW(this); // Set up the paint for the label text mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mTextPaint.setColor(mTextColor); if (mTextHeight == 0) { mTextHeight = mTextPaint.getTextSize(); } else { mTextPaint.setTextSize(mTextHeight); } // Set up the paint for the pie slices mPiePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPiePaint.setStyle(Paint.Style.FILL); mPiePaint.setTextSize(mTextHeight); // Set up the paint for the shadow mShadowPaint = new Paint(0); mShadowPaint.setColor(0xff101010); mShadowPaint.setMaskFilter(new BlurMaskFilter(8, BlurMaskFilter.Blur.NORMAL)); // Add a child view to draw the pie. Putting this in a child view // makes it possible to draw it on a separate hardware layer that rotates // independently mPieView = new PieView(getContext()); addView(mPieView); mPieView.rotateTo(mPieRotation); // The pointer doesn't need hardware acceleration, but in order to show up // in front of the pie it also needs to be on a separate view. mPointerView = new PointerView(getContext()); addView(mPointerView); // Set up an animator to animate the PieRotation property. This is used to // correct the pie's orientation after the user lets go of it. if (Build.VERSION.SDK_INT >= 11) { mAutoCenterAnimator = ObjectAnimator.ofInt(PieChart.this, "PieRotation", 0); // Add a listener to hook the onAnimationEnd event so that we can do // some cleanup when the pie stops moving. mAutoCenterAnimator.addListener(new Animator.AnimatorListener() { public void onAnimationStart(Animator animator) { } public void onAnimationEnd(Animator animator) { mPieView.decelerate(); } public void onAnimationCancel(Animator animator) { } public void onAnimationRepeat(Animator animator) { } }); } // Create a Scroller to handle the fling gesture. if (Build.VERSION.SDK_INT < 11) { mScroller = new Scroller(getContext()); } else { mScroller = new Scroller(getContext(), null, true); } // The scroller doesn't have any built-in animation functions--it just supplies // values when we ask it to. So we have to have a way to call it every frame // until the fling ends. This code (ab)uses a ValueAnimator object to generate // a callback on every animation frame. We don't use the animated value at all. if (Build.VERSION.SDK_INT >= 11) { mScrollAnimator = ValueAnimator.ofFloat(0, 1); mScrollAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator valueAnimator) { tickScrollAnimation(); } }); } // Create a gesture detector to handle onTouch messages mDetector = new GestureDetector(PieChart.this.getContext(), new GestureListener()); // Turn off long press--this control doesn't use it, and if long press is enabled, // you can't scroll for a bit, pause, then scroll some more (the pause is interpreted // as a long press, apparently) mDetector.setIsLongpressEnabled(false); // In edit mode it's nice to have some demo data, so add that here. if (this.isInEditMode()) { Resources res = getResources(); addItem("Annabelle", 3, ContextCompat.getColor(getContext(), R.color.bluegrass)); addItem("Brunhilde", 4, ContextCompat.getColor(getContext(), R.color.chartreuse)); addItem("Carolina", 2, ContextCompat.getColor(getContext(), R.color.emerald)); addItem("Dahlia", 3, ContextCompat.getColor(getContext(), R.color.seafoam)); addItem("Ekaterina", 1, ContextCompat.getColor(getContext(), R.color.slate)); } }
From source file:me.ccrama.redditslide.Views.SubsamplingScaleImageView.java
private void setGestureDetector(final Context context) { this.detector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() { @Override/*from w w w . j a v a2s. c o m*/ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if (panEnabled && readySent && vTranslate != null && e1 != null && e2 != null && (Math.abs(e1.getX() - e2.getX()) > 50 || Math.abs(e1.getY() - e2.getY()) > 50) && (Math.abs(velocityX) > 500 || Math.abs(velocityY) > 500) && !isZooming) { PointF vTranslateEnd = new PointF(vTranslate.x + (velocityX * 0.25f), vTranslate.y + (velocityY * 0.25f)); float sCenterXEnd = ((getWidth() / 2) - vTranslateEnd.x) / scale; float sCenterYEnd = ((getHeight() / 2) - vTranslateEnd.y) / scale; new AnimationBuilder(new PointF(sCenterXEnd, sCenterYEnd)).withEasing(EASE_OUT_QUAD) .withPanLimited(false).start(); return true; } return super.onFling(e1, e2, velocityX, velocityY); } @Override public boolean onSingleTapConfirmed(MotionEvent e) { performClick(); return true; } @Override public boolean onDoubleTap(MotionEvent e) { if (zoomEnabled && readySent && vTranslate != null) { // Hacky solution for #15 - after a double tap the GestureDetector gets in a state // where the next fling is ignored, so here we replace it with a new one. setGestureDetector(context); if (quickScaleEnabled) { // Store quick scale params. This will become either a double tap zoom or a // quick scale depending on whether the user swipes. vCenterStart = new PointF(e.getX(), e.getY()); vTranslateStart = new PointF(vTranslate.x, vTranslate.y); scaleStart = scale; isQuickScaling = true; isZooming = true; quickScaleCenter = viewToSourceCoord(vCenterStart); quickScaleLastDistance = -1F; quickScaleLastPoint = new PointF(quickScaleCenter.x, quickScaleCenter.y); quickScaleMoved = false; // We need to get events in onTouchEvent after this. return false; } else { // Start double tap zoom animation. doubleTapZoom(viewToSourceCoord(new PointF(e.getX(), e.getY())), new PointF(e.getX(), e.getY())); return true; } } return super.onDoubleTapEvent(e); } }); }
From source file:com.gmail.walles.johan.batterylogger.BatteryPlotFragment.java
private GestureDetector getOneFingerGestureDetector(final XYPlot plot) { GestureDetector.SimpleOnGestureListener gestureListener = new GestureDetector.SimpleOnGestureListener() { @Override/*from ww w . j a va 2 s .c o m*/ public boolean onDown(MotionEvent motionEvent) { // Return true since the framework is weird: // http://stackoverflow.com/questions/4107565/on-android-do-gesture-events-work-on-the-emulator return true; } @Override public boolean onDoubleTap(MotionEvent e) { double targetMinX; double targetMaxX; if (minX == originalMinX && maxX == originalMaxX) { // Reset zoom to two most recent days targetMaxX = originalMaxX; targetMinX = targetMaxX - History.deltaMsToDouble(86400 * 1000 * 2); } else { // Reset zoom to max out targetMinX = originalMinX; targetMaxX = originalMaxX; } animateXrange(plot, targetMinX, targetMaxX); return true; } @Override public boolean onScroll(MotionEvent motionEvent, MotionEvent motionEvent2, float dx, float dy) { scrollSideways(plot, dx); plot.setDomainBoundaries(minX, maxX, BoundaryMode.FIXED); redrawPlot(plot); return true; } }; final GestureDetector gestureDetector = new GestureDetector(getActivity(), gestureListener); gestureDetector.setIsLongpressEnabled(false); gestureDetector.setOnDoubleTapListener(gestureListener); return gestureDetector; }
From source file:pl.edu.agh.mindmapex.gui.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); progressDialog = ProgressDialog.show(this, "Drawing", "Please wait...", true, false); if (WelcomeScreen.workbook != null) { workbook = WelcomeScreen.workbook; }/* w ww .jav a 2s .co m*/ res = getResources(); if (handler == null) { handler = WorkbookHandler.createNewWorkbook(); } if (workbook == null) { workbook = handler.getWorkbook(); styleSheet = workbook.getStyleSheet(); style1 = styleSheet.createStyle(IStyle.TOPIC); styleSheet.addStyle(style1, IStyleSheet.NORMAL_STYLES); } styleSheet = workbook.getStyleSheet(); sheet1 = workbook.getPrimarySheet(); res = getResources(); if (style == null) { Intent intent = getIntent(); style = intent.getStringExtra(WelcomeScreen.STYLE); } if (root == null) { // Display display = getWindowManager().getDefaultDisplay(); setContentView(R.layout.main_content_view); lay = (DrawView) findViewById(R.id.main_draw_view); lay.post(new Runnable() { @Override public void run() { rootTopic = sheet1.getRootTopic(); root = new Box(); // Point size = new Point(lay.getWidth(), lay.getHeight()); // width = size.x / 2; // height = size.y / 2; root.setPoint(new pl.edu.agh.mindmapex.common.Point( lay.getWidth() / 2 - getResources().getDimensionPixelSize(R.dimen.init_box_size), lay.getHeight() / 2 - getResources().getDimensionPixelSize(R.dimen.init_box_size_height))); lay.setZOrderOnTop(true); if (style.equals("ReadyMap")) { if (sheet1.getTheme() == null) { root.setPoint(new pl.edu.agh.mindmapex.common.Point(width, height)); final HashMap<String, Box> boxes = new HashMap<>(); root.topic = rootTopic; if (root.topic.getStyleId() != null) { checkStyle(root); } else { root.setDrawableShape(res.getDrawable(R.drawable.round_rect)); } root.topic.setFolded(false); boxes.put(root.topic.getId(), root); for (ITopic t : root.topic.getAllChildren()) { Box b = new Box(); b.topic = t; boxes.put(root.topic.getId(), root); b.point = new pl.edu.agh.mindmapex.common.Point(); if (b.topic.getStyleId() != null) { checkStyle(b); } else { b.setDrawableShape(res.getDrawable(R.drawable.round_rect)); } b.parent = root; root.addChild(b); rootTopic.add(b.topic, 0, ITopic.ATTACHED); Utils.fireAddSubtopic(b, boxes); boxes.put(t.getId(), b); } Utils.findRelationships(boxes); } else { if (sheet1.getTheme().getName().equals("%classic") || sheet1.getTheme().getName().equals("%comic")) { root.setPoint(new pl.edu.agh.mindmapex.common.Point(width, height)); root.topic = rootTopic; final HashMap<String, Box> boxes = new HashMap<>(); if (root.topic.getStyleId() != null) { checkStyle(root); } else { root.setDrawableShape(res.getDrawable(R.drawable.elipse)); } root.topic.setFolded(false); boxes.put(root.topic.getId(), root); for (ITopic t : root.topic.getAllChildren()) { Box b = new Box(); b.topic = t; b.point = new pl.edu.agh.mindmapex.common.Point(); boxes.put(root.topic.getId(), root); if (b.topic.getStyleId() != null) { checkStyle(b); } else { b.setDrawableShape(res.getDrawable(R.drawable.round_rect)); } b.parent = root; root.addChild(b); Utils.fireAddSubtopic(b, boxes); rootTopic.add(b.topic, 0, ITopic.ATTACHED); boxes.put(t.getId(), b); } Utils.findRelationships(boxes); } else if (sheet1.getTheme().getName().equals("%simple")) { root.setPoint(new pl.edu.agh.mindmapex.common.Point(width, height)); final HashMap<String, Box> boxes = new HashMap<>(); root.topic = rootTopic; if (root.topic.getStyleId() != null) { checkStyle(root); } else { root.setDrawableShape(res.getDrawable(R.drawable.elipse)); } root.topic.setFolded(false); boxes.put(root.topic.getId(), root); for (ITopic t : root.topic.getAllChildren()) { Box b = new Box(); b.topic = t; b.point = new pl.edu.agh.mindmapex.common.Point(); boxes.put(root.topic.getId(), root); if (b.topic.getStyleId() != null) { checkStyle(b); } else { b.setDrawableShape(res.getDrawable(R.drawable.no_border)); } b.parent = root; root.addChild(b); rootTopic.add(b.topic, 0, ITopic.ATTACHED); Utils.fireAddSubtopic(b, boxes); boxes.put(t.getId(), b); } Utils.findRelationships(boxes); } else if (sheet1.getTheme().getName().equals("%bussiness")) { root.setPoint(new pl.edu.agh.mindmapex.common.Point(width, height)); final HashMap<String, Box> boxes = new HashMap<>(); root.topic = rootTopic; if (root.topic.getStyleId() != null) { checkStyle(root); } else { root.setDrawableShape(res.getDrawable(R.drawable.round_rect)); } root.topic.setFolded(false); boxes.put(root.topic.getId(), root); for (ITopic t : root.topic.getAllChildren()) { Box b = new Box(); b.topic = t; b.point = new pl.edu.agh.mindmapex.common.Point(); boxes.put(root.topic.getId(), root); if (b.topic.getStyleId() != null) { checkStyle(b); } else { b.setDrawableShape(res.getDrawable(R.drawable.rect)); } b.parent = root; root.addChild(b); rootTopic.add(b.topic, 0, ITopic.ATTACHED); Utils.fireAddSubtopic(b, boxes); boxes.put(t.getId(), b); } Utils.findRelationships(boxes); } else if (sheet1.getTheme().getName().equals("%academese")) { root.setPoint(new pl.edu.agh.mindmapex.common.Point(width, height)); final HashMap<String, Box> boxes = new HashMap<>(); root.topic = rootTopic; if (root.topic.getStyleId() != null) { checkStyle(root); } else { root.setDrawableShape(res.getDrawable(R.drawable.rect)); } root.topic.setFolded(false); Style s = (Style) workbook.getStyleSheet().createStyle(IStyle.MAP); s.setProperty(Styles.FillColor, Integer.toString(res.getColor(R.color.dark_gray), 16)); styleSheet.addStyle(s, IStyleSheet.NORMAL_STYLES); sheet1.setStyleId(s.getId()); lay.setBackgroundColor(res.getColor(R.color.dark_gray)); boxes.put(root.topic.getId(), root); for (ITopic t : root.topic.getAllChildren()) { Box b = new Box(); b.topic = t; b.point = new pl.edu.agh.mindmapex.common.Point(); boxes.put(root.topic.getId(), root); if (b.topic.getStyleId() != null) { checkStyle(b); } else { b.setDrawableShape(res.getDrawable(R.drawable.elipse)); } b.parent = root; root.addChild(b); Utils.fireAddSubtopic(b, boxes); rootTopic.add(b.topic, 0, ITopic.ATTACHED); boxes.put(t.getId(), b); } Utils.findRelationships(boxes); } } } else if (style.equals("Default")) { rootTopic.setTitleText("Central Topic"); root.topic = rootTopic; root.topic.setFolded(false); root.setDrawableShape(res.getDrawable(R.drawable.round_rect)); IStyle style3 = styleSheet.createStyle(IStyle.TOPIC); style3.setProperty(Styles.FillColor, "#CCE5FF"); style3.setProperty(Styles.ShapeClass, Styles.TOPIC_SHAPE_ROUNDEDRECT); style3.setProperty(Styles.LineClass, Styles.BRANCH_CONN_STRAIGHT); styleSheet.addStyle(style3, IStyleSheet.NORMAL_STYLES); rootTopic.setStyleId(style3.getId()); } else if (style.equals("Classic")) { rootTopic.setTitleText("Central Topic"); root.topic = rootTopic; root.topic.setFolded(false); root.setDrawableShape(res.getDrawable(R.drawable.elipse)); IStyle style2 = styleSheet.createStyle(IStyle.THEME); style2.setName("%classic"); style2.setProperty(Styles.FillColor, String.valueOf(res.getColor(R.color.light_yellow))); styleSheet.addStyle(style2, IStyleSheet.NORMAL_STYLES); sheet1.setThemeId(style2.getId()); IStyle style3 = styleSheet.createStyle(IStyle.TOPIC); style3.setProperty(Styles.FillColor, "#9ACD32"); style3.setProperty(Styles.ShapeClass, Styles.TOPIC_SHAPE_ELLIPSE); style3.setProperty(Styles.LineClass, Styles.BRANCH_CONN_CURVE); styleSheet.addStyle(style3, IStyleSheet.NORMAL_STYLES); style2.setProperty(Style.TOPIC, style3.getId()); rootTopic.setStyleId(style3.getId()); } else if (style.equals("Simple")) { rootTopic.setTitleText("Central Topic"); root.topic = rootTopic; root.topic.setFolded(false); root.setDrawableShape(res.getDrawable(R.drawable.elipse)); IStyle style2 = styleSheet.createStyle(IStyle.THEME); style2.setName("%simple"); style2.setProperty(Styles.FillColor, String.valueOf(res.getColor(R.color.white))); styleSheet.addStyle(style2, IStyleSheet.NORMAL_STYLES); sheet1.setThemeId(style2.getId()); IStyle style3 = styleSheet.createStyle(IStyle.TOPIC); style3.setProperty(Styles.FillColor, "#FFFFFF"); style3.setProperty(Styles.ShapeClass, Styles.TOPIC_SHAPE_ELLIPSE); style3.setProperty(Styles.LineClass, Styles.BRANCH_CONN_CURVE); styleSheet.addStyle(style3, IStyleSheet.NORMAL_STYLES); style2.setProperty(Style.TOPIC, style3.getId()); rootTopic.setStyleId(style3.getId()); } else if (style.equals("Business")) { rootTopic.setTitleText("Central Topic"); root.topic = rootTopic; root.topic.setFolded(false); root.setDrawableShape(res.getDrawable(R.drawable.round_rect)); IStyle style2 = styleSheet.createStyle(IStyle.THEME); style2.setName("%business"); style2.setProperty(Styles.FillColor, String.valueOf(res.getColor(R.color.white))); styleSheet.addStyle(style2, IStyleSheet.NORMAL_STYLES); sheet1.setThemeId(style2.getId()); IStyle style3 = styleSheet.createStyle(IStyle.TOPIC); style3.setProperty(Styles.FillColor, "#B87333"); style3.setProperty(Styles.ShapeClass, Styles.TOPIC_SHAPE_ROUNDEDRECT); style3.setProperty(Styles.LineClass, Styles.BRANCH_CONN_CURVE); styleSheet.addStyle(style3, IStyleSheet.NORMAL_STYLES); style2.setProperty(Style.TOPIC, style3.getId()); rootTopic.setStyleId(style3.getId()); } else if (style.equals("Academese")) { rootTopic.setTitleText("Central Topic"); root.topic = rootTopic; root.topic.setFolded(false); root.setDrawableShape(res.getDrawable(R.drawable.rect)); IStyle style2 = styleSheet.createStyle(IStyle.THEME); style2.setProperty(Styles.FillColor, "#404040"); styleSheet.addStyle(style2, IStyleSheet.NORMAL_STYLES); sheet1.setStyleId(style2.getId()); lay.setBackgroundColor(res.getColor(R.color.dark_gray)); IStyle style3 = styleSheet.createStyle(IStyle.TOPIC); style3.setProperty(Styles.FillColor, "#404040"); style3.setProperty(Styles.ShapeClass, Styles.TOPIC_SHAPE_RECT); style3.setProperty(Styles.LineClass, Styles.BRANCH_CONN_STRAIGHT); style3.setProperty(Styles.LineColor, "#FFFFFF"); styleSheet.addStyle(style3, IStyleSheet.NORMAL_STYLES); style2.setProperty(Style.TOPIC, style3.getId()); rootTopic.setStyleId(style3.getId()); } } }); } else { setContentView(R.layout.main_content_view); lay = (DrawView) findViewById(R.id.main_draw_view); lay.setZOrderOnTop(true); } gestureDetector = new GestureDetector(this, gestList); Utils.lay = lay; if (lay != null) { lay.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { detector.onTouchEvent(event); switch (event.getActionMasked()) { case (MotionEvent.ACTION_OUTSIDE): return true; case (MotionEvent.ACTION_UP): break; case MotionEvent.ACTION_POINTER_UP: if (!detector.isInProgress()) { int count = event.getPointerCount(); // Number of 'fingers' in this time Utils.getCoordsInView(lay, event, 1); boxEdited = Utils.whichBox(lay, event); float[] tab1 = Utils.getCoordsInView(lay, event, 0); float[] tab = Utils.getCoordsInView(lay, event, 1); if (count == 2 && boxEdited != null) { if (tab.length == 2) { if (mTourGuide != null) mTourGuide.cleanUp(); Box box1 = new Box(); box1.setPoint(new pl.edu.agh.mindmapex.common.Point( (int) tab[0] - (box1.getWidth() / 2), (int) tab[1] - (box1.getHeight() / 2))); AddBox addBox = new AddBox(); Properties properties = new Properties(); properties.put("box", MainActivity.boxEdited); properties.put("new_box", box1); properties.put("root", root); properties.put("res", res); properties.put("style", style); addBox.execute(properties); MainActivity.addCommendUndo(addBox); editContent(box1, addBox); lay.updateBoxWithText(box1); } } break; } default: break; } boolean response = gestureDetector.onTouchEvent(event); lay.requestFocus(); InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); in.hideSoftInputFromWindow(lay.getApplicationWindowToken(), 0); return response; } }); lay.setLayerType(View.LAYER_TYPE_SOFTWARE, null); } Utils.context = this; this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayOptions( ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.show(); detector = new ScaleGestureDetector(this, new SimpleOnScaleGestureListener() { @Override public boolean onScaleBegin(ScaleGestureDetector detector) { mScaling = true; return true; } @Override public boolean onScale(ScaleGestureDetector detector) { // float focusX = detector.getFocusX(); // float focusY = detector.getFocusY(); //// lay.setPivotX(mid.x); //// lay.setPivotY(mid.y); //// lay.pivotx = (int) (lastFocusX + detector.getFocusX())/2; //// lay.pivoty = (int) (lastFocusY+ detector.getFocusY())/2; // // lay.pivotx = (int) mid.x; // // lay.pivoty = (int) mid.y; // // lay.canvas.translate(-focusX,-focusY); lay.pivotx = detector.getFocusX(); lay.pivoty = detector.getFocusY(); // lay.transx = (lay.pivotx); // lay.transy = (lay.pivoty); // lay.pivotx = (int) mid.x; // lay.pivoty = (int) mid.y; // lay.setPivotX(lastFocusX); // lay.setPivotY(lastFocusY); float SF = detector.getScaleFactor(); lay.zoomx *= SF; lay.zoomy *= SF; // lay.canvas.scale(SF, SF, mid.x, mid.y); // float focusShiftX = focusX - lastFocusX; // float focusShiftY = focusY - lastFocusY; //lay.canvas.translate(focusX + focusShiftX, focusY + focusShiftY); // lastFocusX = focusX; // lastFocusY = focusY; // lay.transy = detector.getFocusY(); // lay.zoomx = Math.max(0.1f, Math.min(lay.zoomx, 5.0f)); // lay.zoomy = Math.max(0.1f, Math.min(lay.zoomy, 5.0f)); return true; } }); progressDialog.dismiss(); lay.setId(View.generateViewId()); lay.setSaveEnabled(true); if (savedInstanceState != null) { lay.transx = savedInstanceState.getFloat(TRANSX_KEY); lay.transy = savedInstanceState.getFloat(TRANSY_KEY); lay.zoomx = savedInstanceState.getFloat(ZOOMX_KEY); lay.zoomy = savedInstanceState.getFloat(ZOOMY_KEY); lay.pivotx = savedInstanceState.getFloat(PIVOTX_KEY); lay.pivoty = savedInstanceState.getFloat(PIVOTY_KEY); } }
From source file:com.mobicage.rogerthat.plugins.friends.ServiceActionMenuActivity.java
private void populateScreen(final ServiceMenu menu) { menuBrandingHash = menu.branding;//from w w w . j av a 2 s . c o m final FriendsPlugin friendsPlugin = mService.getPlugin(FriendsPlugin.class); final MessagingPlugin messagingPlugin = mService.getPlugin(MessagingPlugin.class); final FriendStore store = friendsPlugin.getStore(); List<Cell> usedCells = new ArrayList<Cell>(); if (page == 0) { addAboutHandler(usedCells, menu.aboutLabel); addHistoryHandler(usedCells, store, menu.messagesLabel); addCallHandler(menu, usedCells, menu.callLabel); if (CloudConstants.isYSAAA()) { addScanHandler(menu, usedCells, null); } else { addShareHandler(menu, usedCells, menu.shareLabel); } } boolean[] rows = new boolean[] { false, false, false }; if (page == 0) rows[0] = true; for (final ServiceMenuItem item : menu.itemList) { rows[(int) item.coords[1]] = true; final Cell cell = cells[(int) item.coords[0]][(int) item.coords[1]]; View.OnClickListener onClickListener = new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { pressMenuItem(menu, messagingPlugin, store, item); } }; ((View) cell.icon.getParent()).setOnClickListener(onClickListener); cell.icon.setImageBitmap(BitmapFactory.decodeByteArray(item.icon, 0, item.icon.length)); cell.icon.setVisibility(View.VISIBLE); cell.label.setText(item.label); cell.label.setVisibility(View.VISIBLE); usedCells.add(cell); } for (int i = 2; i >= 0; i--) { if (rows[i]) break; tableRows[i].setVisibility(View.GONE); } boolean showBranded = false; boolean useDarkScheme = false; Integer menuItemColor = null; if (menu.branding != null) { try { BrandingMgr brandingMgr = messagingPlugin.getBrandingMgr(); Friend friend = store.getExistingFriend(email); if (brandingMgr.isBrandingAvailable(menu.branding)) { BrandingResult br = brandingMgr.prepareBranding(menu.branding, friend, false); WebSettings settings = branding.getSettings(); settings.setJavaScriptEnabled(false); settings.setBlockNetworkImage(false); branding.setVisibility(View.VISIBLE); branding.setVerticalScrollBarEnabled(false); final int displayWidth = UIUtils.getDisplayWidth(this); final int calculatedHeight = BrandingMgr.calculateHeight(br, displayWidth); final long start = System.currentTimeMillis(); branding.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() { @Override public boolean onPreDraw() { int height = branding.getMeasuredHeight(); if (height > calculatedHeight * 90 / 100 || System.currentTimeMillis() - start > 3000) { if (calculatedHeight > 0) { setBrandingHeight(height); } else { mService.postDelayedOnUIHandler(new SafeRunnable() { @Override protected void safeRun() throws Exception { setBrandingHeight(branding.getMeasuredHeight()); } }, 100); } branding.getViewTreeObserver().removeOnPreDrawListener(this); } return false; } }); branding.loadUrl("file://" + br.file.getAbsolutePath()); if (br.color != null) { branding.setBackgroundColor(br.color); activity.setBackgroundColor(br.color); } if (br.scheme == ColorScheme.dark) { for (Cell cell : usedCells) { cell.label.setTextColor(darkSchemeTextColor); cell.label.setShadowLayer(2, 1, 1, Color.BLACK); } useDarkScheme = true; } menuItemColor = br.menuItemColor; final ImageView watermarkView = (ImageView) findViewById(R.id.watermark); if (br.watermark != null) { BitmapDrawable watermark = new BitmapDrawable(getResources(), BitmapFactory.decodeFile(br.watermark.getAbsolutePath())); watermark.setGravity(Gravity.BOTTOM | Gravity.RIGHT); watermarkView.setImageDrawable(watermark); final LayoutParams layoutParams = watermarkView.getLayoutParams(); layoutParams.width = layoutParams.height = displayWidth; } else { watermarkView.setImageDrawable(null); } showBranded = true; } else { friend.actionMenu = menu; friend.actionMenu.items = menu.itemList.toArray(new ServiceMenuItemTO[] {}); brandingMgr.queue(friend); } } catch (BrandingFailureException e) { L.bug("Could not display service action menu with branding.", e); } } if (!showBranded) { setNavigationBarVisible(AppConstants.SHOW_NAV_HEADER); setNavigationBarTitle(menu.name); title.setVisibility(View.GONE); title.setText(menu.name); } for (final Cell cell : usedCells) { final View p = (View) cell.icon.getParent(); final Drawable d = getResources().getDrawable( useDarkScheme ? R.drawable.mc_smi_background_light : R.drawable.mc_smi_background_dark); p.setBackgroundDrawable(d); } if (menuItemColor == null) menuItemColor = Color.parseColor("#646464"); for (Cell cell : new Cell[] { cells[0][0], cells[1][0], cells[2][0], cells[3][0] }) cell.faIcon.setTextColor(menuItemColor); if (menu.maxPage > 0) { for (int i = 0; i <= menu.maxPage; i++) { ImageView bolleke = (ImageView) getLayoutInflater().inflate(R.layout.page, pages, false); if (page == i) { if (useDarkScheme) { bolleke.setImageResource(R.drawable.current_page_dark); } else { bolleke.setImageResource(R.drawable.current_page_light); } } else { if (useDarkScheme) { bolleke.setImageResource(R.drawable.other_page_dark); } else { bolleke.setImageResource(R.drawable.other_page_light); } } pages.addView(bolleke); } pages.setVisibility(View.VISIBLE); } final int leftPage = page - 1; final int rightPage = page + 1; final String service = email; Slider instance = new Slider(this, this, page == menu.maxPage ? null : new Slider.Swiper() { @Override public Intent onSwipe() { return new Intent(ServiceActionMenuActivity.this, ServiceActionMenuActivity.class) .putExtra(SERVICE_EMAIL, service).putExtra(MENU_PAGE, rightPage); } }, page == 0 ? null : new Slider.Swiper() { @Override public Intent onSwipe() { return new Intent(ServiceActionMenuActivity.this, ServiceActionMenuActivity.class) .putExtra(SERVICE_EMAIL, service).putExtra(MENU_PAGE, leftPage); } }); mGestureScanner = new GestureDetector(this, instance); }
From source file:illab.nabal.NabalSimpleDemoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_nabal_simple_demo); CookieSyncManager.createInstance(NabalSimpleDemoActivity.this); mBackground = (RelativeLayout) findViewById(R.id.relativeLayout1); mImgBtn1 = (ImageButton) findViewById(R.id.imageButton1); mImgBtn2 = (ImageButton) findViewById(R.id.imageButton2); mImgBtn3 = (ImageButton) findViewById(R.id.imageButton3); mImgBtn4 = (ImageButton) findViewById(R.id.imageButton4); mImgBtn5 = (ImageButton) findViewById(R.id.imageButton5); mImgBtn7 = (ImageButton) findViewById(R.id.imageButton7); mImgBtn8 = (ImageButton) findViewById(R.id.imageButton8); mEditText1 = (EditText) findViewById(R.id.editText1); mEditText2 = (EditText) findViewById(R.id.editText2); mEditText3 = (EditText) findViewById(R.id.editText3); mDialogHelper.toast("Please log in first."); mInputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); mInputMethodManager.hideSoftInputFromWindow(mEditText1.getWindowToken(), 0); mInputMethodManager.hideSoftInputFromWindow(mEditText2.getWindowToken(), 0); // set a listener to background for a fling mGestureDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() { @Override//from w ww . ja v a 2 s.com public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { try { if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) { return false; } // right to left swipe if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { if (mCurrentSnsId == SocialNetwork.FACEBOOK) { toggleSnsButtons(SocialNetwork.WEIBO); } else if (mCurrentSnsId == SocialNetwork.TWITTER) { toggleSnsButtons(SocialNetwork.FACEBOOK); } else if (mCurrentSnsId == SocialNetwork.WEIBO) { toggleSnsButtons(SocialNetwork.TWITTER); } } // left to right swipe else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { if (mCurrentSnsId == SocialNetwork.FACEBOOK) { toggleSnsButtons(SocialNetwork.TWITTER); } else if (mCurrentSnsId == SocialNetwork.TWITTER) { toggleSnsButtons(SocialNetwork.WEIBO); } else if (mCurrentSnsId == SocialNetwork.WEIBO) { toggleSnsButtons(SocialNetwork.FACEBOOK); } } } catch (Exception e) { // nothing } return false; } }); View.OnTouchListener gestureListener = new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { return mGestureDetector.onTouchEvent(event); } }; mBackground.setOnTouchListener(gestureListener); // set a listener to background for a long-click mBackground.setOnLongClickListener(new OnLongClickListener() { public boolean onLongClick(View v) { Log.i(TAG, "#### background area long-clicked"); if (mCurrentSnsId == SocialNetwork.FACEBOOK) { if (mFbBgBitmap != null) { new PhotoDialog(NabalSimpleDemoActivity.this, mFbBgBitmap).show(); } } else if (mCurrentSnsId == SocialNetwork.TWITTER) { if (mTwBgBitmap != null) { new PhotoDialog(NabalSimpleDemoActivity.this, mTwBgBitmap).show(); } } else if (mCurrentSnsId == SocialNetwork.WEIBO) { if (mWeBgBitmap != null) { new PhotoDialog(NabalSimpleDemoActivity.this, mWeBgBitmap).show(); } } return false; } }); // set a listener to Facebook button mImgBtn3.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { //Log.i(TAG, "#### Facebook button clicked"); toggleSnsButtons(SocialNetwork.FACEBOOK); } }); // set a listener to Twitter button mImgBtn4.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { //Log.i(TAG, "#### Twitter button clicked"); toggleSnsButtons(SocialNetwork.TWITTER); } }); // set a listener to Weibo button mImgBtn5.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { //Log.i(TAG, "#### Weibo button clicked"); toggleSnsButtons(SocialNetwork.WEIBO); } }); // set a listener to portrait button mImgBtn1.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { //Log.i(TAG, "#### portrait button clicked"); clearOutProfileUi(); clearProfileBufferData(mCurrentSnsId); mHasErrorOccurredWhileFetchingProfile = false; mImgBtn1.setVisibility(View.GONE); requestMyProfile(); requestMyLastStatus(); } }); mImgBtn1.setOnLongClickListener(new OnLongClickListener() { public boolean onLongClick(View paramView) { //Log.i(TAG, "#### portrait button long-clicked"); confirmJumpToSnsProfile(); return true; } }); // set a listener to photo attach button mImgBtn7.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { //Log.i(TAG, "#### photo attach button clicked"); // if not logged-in yet if (mOpAgent.isSessionValid(mCurrentSnsId) == false) { mEditText1.setText(""); mDialogHelper.toast("Please log in first."); } // if logged-in already else { final String message = mEditText1.getText().toString(); if (StringHelper.isEmpty(message) == true) { mDialogHelper.toast("Please enter the photo description correctly."); } else { Intent pickPhoto = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(pickPhoto, REQ_CODE_FETCH_BITMAP_FROM_GALLERY); } } } }); // set a listener to status update button mImgBtn2.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { //Log.i(TAG, "#### status update button clicked"); // if not logged-in yet if (mOpAgent.isSessionValid(mCurrentSnsId) == false) { mEditText1.setText(""); mDialogHelper.toast("Please log in first."); } // if logged-in already else { final String message = mEditText1.getText().toString(); if (StringHelper.isEmpty(message) == true) { mDialogHelper.toast("Please enter your status correctly."); } else { postStatus(message); } } } }); // set a listener to link button mImgBtn8.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { //Log.i(TAG, "#### photo attach button clicked"); // if not logged-in yet if (mOpAgent.isSessionValid(mCurrentSnsId) == false) { } // if logged-in already else { confirmJumpToLinkDialog(); } } }); }
From source file:com.haibison.android.anhuu.FragmentFiles.java
/** * This should be called after the owner activity has been created * successfully./* www.jav a 2s. c om*/ */ private void initGestureDetector() { mListviewFilesGestureDetector = new GestureDetector(getActivity(), new GestureDetector.SimpleOnGestureListener() { private Object getData(float x, float y) { int i = getSubViewId(x, y); if (i >= 0) return mViewFiles.getItemAtPosition(mViewFiles.getFirstVisiblePosition() + i); return null; }// getSubView() private int getSubViewId(float x, float y) { Rect r = new Rect(); for (int i = 0; i < mViewFiles.getChildCount(); i++) { mViewFiles.getChildAt(i).getHitRect(r); if (r.contains((int) x, (int) y)) return i; } return -1; }// getSubViewId() /** * Gets {@link Cursor} from {@code e}. * * @param e * {@link MotionEvent}. * @return the cursor, or {@code null} if not available. */ private Cursor getData(MotionEvent e) { Object o = getData(e.getX(), e.getY()); return o instanceof Cursor ? (Cursor) o : null; }// getDataModel() @Override public void onLongPress(MotionEvent e) { /* * Do nothing. */ }// onLongPress() @Override public boolean onSingleTapConfirmed(MotionEvent e) { /* * Do nothing. */ return false; }// onSingleTapConfirmed() @Override public boolean onDoubleTap(MotionEvent e) { if (mDoubleTapToChooseFiles) { if (mIsMultiSelection) return false; Cursor cursor = getData(e); if (cursor == null) return false; if (BaseFileProviderUtils.isDirectory(cursor) && BaseFile.FILTER_FILES_ONLY == mFilterMode) return false; /* * If mFilterMode == FILTER_DIRECTORIES_ONLY, files * won't be shown. */ if (mIsSaveDialog) { if (BaseFileProviderUtils.isFile(cursor)) { mTextSaveas.setText(BaseFileProviderUtils.getFileName(cursor)); /* * Always set tag after setting text, or tag * will be reset to null. */ mTextSaveas.setTag(BaseFileProviderUtils.getUri(cursor)); checkSaveasFilenameAndFinish(); } else return false; } else finish(BaseFileProviderUtils.getUri(cursor)); } // double tap to choose files else { /* * Do nothing. */ return false; } // single tap to choose files return true; }// onDoubleTap() @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { /* * Sometimes e1 or e2 can be null. This came from users' * experiences. */ if (e1 == null || e2 == null) return false; final int max_y_distance = 19;// 10 is too short :-D final int min_x_distance = 80; final int min_x_velocity = 200; if (Math.abs(e1.getY() - e2.getY()) < max_y_distance && Math.abs(e1.getX() - e2.getX()) > min_x_distance && Math.abs(velocityX) > min_x_velocity) { int pos = getSubViewId(e1.getX(), e1.getY()); if (pos >= 0) { /* * Don't let this event to be recognized as a * single tap. */ MotionEvent cancelEvent = MotionEvent.obtain(e1); cancelEvent.setAction(MotionEvent.ACTION_CANCEL); mViewFiles.onTouchEvent(cancelEvent); deleteFile(mViewFiles.getFirstVisiblePosition() + pos); } } /* * Always return false to let the default handler draw * the item properly. */ return false; }// onFling() });// mListviewFilesGestureDetector }
From source file:com.arlib.floatingsearchview.FloatingSearchView.java
private void setupSuggestionSection() { boolean showItemsFromBottom = true; LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, showItemsFromBottom);/*www . j a v a2s . c o m*/ mSuggestionsList.setLayoutManager(layoutManager); mSuggestionsList.setItemAnimator(null); final GestureDetector gestureDetector = new GestureDetector(getContext(), new GestureDetectorListenerAdapter() { @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { if (mHostActivity != null) Util.closeSoftKeyboard(mHostActivity); return false; } }); mSuggestionsList.addOnItemTouchListener(new OnItemTouchListenerAdapter() { @Override public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) { gestureDetector.onTouchEvent(e); return false; } }); mSuggestionsAdapter = new SearchSuggestionsAdapter(getContext(), mSuggestionsTextSizePx, new SearchSuggestionsAdapter.Listener() { @Override public void onItemSelected(SearchSuggestion item) { setSearchFocused(false); if (mSearchListener != null) mSearchListener.onSuggestionClicked(item); } @Override public void onMoveItemToSearchClicked(SearchSuggestion item) { mSearchInput.setText(item.getBody()); //move cursor to end of text mSearchInput.setSelection(mSearchInput.getText().length()); } }); mSuggestionsList.setAdapter(mSuggestionsAdapter); int cardViewBottomPadding = Util.dpToPx(5); //move up the suggestions section enough to cover the search bar //card's bottom left and right corners mSuggestionsSection.setTranslationY(-cardViewBottomPadding); }
From source file:org.appcelerator.titanium.view.TiUIView.java
protected void registerTouchEvents(final View touchable) { touchView = new WeakReference<View>(touchable); final ScaleGestureDetector scaleDetector = new ScaleGestureDetector(touchable.getContext(), new SimpleOnScaleGestureListener() { // protect from divide by zero errors long minTimeDelta = 1; float minStartSpan = 1.0f; float startSpan; @Override// ww w. j a v a 2s . c o m public boolean onScale(ScaleGestureDetector sgd) { if (proxy.hierarchyHasListener(TiC.EVENT_PINCH)) { float timeDelta = sgd.getTimeDelta() == 0 ? minTimeDelta : sgd.getTimeDelta(); // Suppress scale events (and allow for possible two-finger tap events) // until we've moved at least a few pixels. Without this check, two-finger // taps are very hard to register on some older devices. if (!didScale) { if (Math.abs(sgd.getCurrentSpan() - startSpan) > SCALE_THRESHOLD) { didScale = true; } } if (didScale) { KrollDict data = new KrollDict(); data.put(TiC.EVENT_PROPERTY_SCALE, sgd.getCurrentSpan() / startSpan); data.put(TiC.EVENT_PROPERTY_VELOCITY, (sgd.getScaleFactor() - 1.0f) / timeDelta * 1000); data.put(TiC.EVENT_PROPERTY_SOURCE, proxy); return proxy.fireEvent(TiC.EVENT_PINCH, data); } } return false; } @Override public boolean onScaleBegin(ScaleGestureDetector sgd) { startSpan = sgd.getCurrentSpan() == 0 ? minStartSpan : sgd.getCurrentSpan(); return true; } }); final GestureDetector detector = new GestureDetector(touchable.getContext(), new SimpleOnGestureListener() { @Override public boolean onDoubleTap(MotionEvent e) { if (proxy.hierarchyHasListener(TiC.EVENT_DOUBLE_TAP) || proxy.hierarchyHasListener(TiC.EVENT_DOUBLE_CLICK)) { boolean handledTap = proxy.fireEvent(TiC.EVENT_DOUBLE_TAP, dictFromEvent(e)); boolean handledClick = proxy.fireEvent(TiC.EVENT_DOUBLE_CLICK, dictFromEvent(e)); return handledTap || handledClick; } return false; } @Override public boolean onSingleTapConfirmed(MotionEvent e) { Log.d(TAG, "TAP, TAP, TAP on " + proxy, Log.DEBUG_MODE); if (proxy.hierarchyHasListener(TiC.EVENT_SINGLE_TAP)) { return proxy.fireEvent(TiC.EVENT_SINGLE_TAP, dictFromEvent(e)); // Moved click handling to the onTouch listener, because a single tap is not the // same as a click. A single tap is a quick tap only, whereas clicks can be held // before lifting. // boolean handledClick = proxy.fireEvent(TiC.EVENT_CLICK, dictFromEvent(event)); // Note: this return value is irrelevant in our case. We "want" to use it // in onTouch below, when we call detector.onTouchEvent(event); But, in fact, // onSingleTapConfirmed is *not* called in the course of onTouchEvent. It's // called via Handler in GestureDetector. <-- See its Java source. // return handledTap;// || handledClick; } return false; } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { Log.d(TAG, "SWIPE on " + proxy, Log.DEBUG_MODE); if (proxy.hierarchyHasListener(TiC.EVENT_SWIPE)) { KrollDict data = dictFromEvent(e2); if (Math.abs(velocityX) > Math.abs(velocityY)) { data.put(TiC.EVENT_PROPERTY_DIRECTION, velocityX > 0 ? "right" : "left"); } else { data.put(TiC.EVENT_PROPERTY_DIRECTION, velocityY > 0 ? "down" : "up"); } return proxy.fireEvent(TiC.EVENT_SWIPE, data); } return false; } @Override public void onLongPress(MotionEvent e) { Log.d(TAG, "LONGPRESS on " + proxy, Log.DEBUG_MODE); if (proxy.hierarchyHasListener(TiC.EVENT_LONGPRESS)) { proxy.fireEvent(TiC.EVENT_LONGPRESS, dictFromEvent(e)); } } }); touchable.setOnTouchListener(new OnTouchListener() { int pointersDown = 0; public boolean onTouch(View view, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { lastUpEvent.put(TiC.EVENT_PROPERTY_X, (double) event.getX()); lastUpEvent.put(TiC.EVENT_PROPERTY_Y, (double) event.getY()); } scaleDetector.onTouchEvent(event); if (scaleDetector.isInProgress()) { pointersDown = 0; return true; } boolean handled = detector.onTouchEvent(event); if (handled) { pointersDown = 0; return true; } if (event.getActionMasked() == MotionEvent.ACTION_POINTER_UP) { if (didScale) { didScale = false; pointersDown = 0; } else { pointersDown++; } } else if (event.getAction() == MotionEvent.ACTION_UP) { if (pointersDown == 1) { proxy.fireEvent(TiC.EVENT_TWOFINGERTAP, dictFromEvent(event)); pointersDown = 0; return true; } pointersDown = 0; } String motionEvent = motionEvents.get(event.getAction()); if (motionEvent != null) { if (proxy.hierarchyHasListener(motionEvent)) { proxy.fireEvent(motionEvent, dictFromEvent(event)); } } // Inside View.java, dispatchTouchEvent() does not call onTouchEvent() if this listener returns true. As // a result, click and other motion events do not occur on the native Android side. To prevent this, we // always return false and let Android generate click and other motion events. return false; } }); }