List of usage examples for android.view MotionEvent getActionMasked
public final int getActionMasked()
From source file:com.android.inputmethod.latin.suggestions.SuggestionStripView.java
@Override public boolean onTouchEvent(final MotionEvent me) { if (!mMoreSuggestionsView.isShowingInParent()) { // Ignore any touch event while more suggestions panel hasn't been shown. // Detecting sliding up is done at {@link #onInterceptTouchEvent}. return true; }//from w w w . j av a 2s.c o m // In the sliding input mode. {@link MotionEvent} should be forwarded to // {@link MoreSuggestionsView}. final int index = me.getActionIndex(); final int x = mMoreSuggestionsView.translateX((int) me.getX(index)); final int y = mMoreSuggestionsView.translateY((int) me.getY(index)); me.setLocation(x, y); if (!mNeedsToTransformTouchEventToHoverEvent) { mMoreSuggestionsView.onTouchEvent(me); return true; } // In sliding suggestion mode with accessibility mode on, a touch event should be // transformed to a hover event. final int width = mMoreSuggestionsView.getWidth(); final int height = mMoreSuggestionsView.getHeight(); final boolean onMoreSuggestions = (x >= 0 && x < width && y >= 0 && y < height); if (!onMoreSuggestions && !mIsDispatchingHoverEventToMoreSuggestions) { // Just drop this touch event because dispatching hover event isn't started yet and // the touch event isn't on {@link MoreSuggestionsView}. return true; } final int hoverAction; if (onMoreSuggestions && !mIsDispatchingHoverEventToMoreSuggestions) { // Transform this touch event to a hover enter event and start dispatching a hover // event to {@link MoreSuggestionsView}. mIsDispatchingHoverEventToMoreSuggestions = true; hoverAction = MotionEvent.ACTION_HOVER_ENTER; } else if (me.getActionMasked() == MotionEvent.ACTION_UP) { // Transform this touch event to a hover exit event and stop dispatching a hover event // after this. mIsDispatchingHoverEventToMoreSuggestions = false; mNeedsToTransformTouchEventToHoverEvent = false; hoverAction = MotionEvent.ACTION_HOVER_EXIT; } else { // Transform this touch event to a hover move event. hoverAction = MotionEvent.ACTION_HOVER_MOVE; } me.setAction(hoverAction); mMoreSuggestionsView.onHoverEvent(me); return true; }
From source file:com.onyx.deskclock.deskclock.alarms.AlarmActivity.java
@Override public boolean onTouch(View view, MotionEvent motionEvent) { if (mAlarmHandled) { LogUtils.v(LOGTAG, "onTouch ignored: %s", motionEvent); return false; }/*from w w w. jav a2 s. c om*/ final int[] contentLocation = { 0, 0 }; mContentView.getLocationOnScreen(contentLocation); final float x = motionEvent.getRawX() - contentLocation[0]; final float y = motionEvent.getRawY() - contentLocation[1]; final int alarmLeft = mAlarmButton.getLeft() + mAlarmButton.getPaddingLeft(); final int alarmRight = mAlarmButton.getRight() - mAlarmButton.getPaddingRight(); final float snoozeFraction, dismissFraction; if (ViewCompat.getLayoutDirection(view) == ViewCompat.LAYOUT_DIRECTION_RTL) { snoozeFraction = getFraction(alarmRight, mSnoozeButton.getLeft(), x); dismissFraction = getFraction(alarmLeft, mDismissButton.getRight(), x); } else { snoozeFraction = getFraction(alarmLeft, mSnoozeButton.getRight(), x); dismissFraction = getFraction(alarmRight, mDismissButton.getLeft(), x); } // API >= 17 /*if (mContentView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { snoozeFraction = getFraction(alarmRight, mSnoozeButton.getLeft(), x); dismissFraction = getFraction(alarmLeft, mDismissButton.getRight(), x); } else { snoozeFraction = getFraction(alarmLeft, mSnoozeButton.getRight(), x); dismissFraction = getFraction(alarmRight, mDismissButton.getLeft(), x); }*/ setAnimatedFractions(snoozeFraction, dismissFraction); switch (motionEvent.getActionMasked()) { case MotionEvent.ACTION_DOWN: LogUtils.v(LOGTAG, "onTouch started: %s", motionEvent); // Stop the pulse, allowing the last pulse to finish. mPulseAnimator.setRepeatCount(0); break; case MotionEvent.ACTION_UP: LogUtils.v(LOGTAG, "onTouch ended: %s", motionEvent); if (snoozeFraction == 1.0f) { snooze(); } else if (dismissFraction == 1.0f) { dismiss(); } else { if (snoozeFraction > 0.0f || dismissFraction > 0.0f) { // Animate back to the initial state. AnimatorUtils.reverse(mAlarmAnimator, mSnoozeAnimator, mDismissAnimator); } else if (mAlarmButton.getTop() <= y && y <= mAlarmButton.getBottom()) { // User touched the alarm button, hint the dismiss action hintDismiss(); } // Restart the pulse. mPulseAnimator.setRepeatCount(ValueAnimator.INFINITE); if (!mPulseAnimator.isStarted()) { mPulseAnimator.start(); } } break; case MotionEvent.ACTION_CANCEL: resetAnimations(); break; default: break; } return true; }
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// w ww.j av a 2 s . com 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; } }); }
From source file:org.telegram.ui.Components.ChatAttachAlert.java
private boolean processTouchEvent(MotionEvent event) { if (!pressed && event.getActionMasked() == MotionEvent.ACTION_DOWN || event.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN) { if (!takingPhoto) { pressed = true;//from w w w . j a v a 2 s.c o m maybeStartDraging = true; lastY = event.getY(); } } else if (pressed) { if (event.getActionMasked() == MotionEvent.ACTION_MOVE) { float newY = event.getY(); float dy = (newY - lastY); if (maybeStartDraging) { if (Math.abs(dy) > AndroidUtilities.getPixelsInCM(0.4f, false)) { maybeStartDraging = false; } } else { cameraView.setTranslationY(cameraView.getTranslationY() + dy); lastY = newY; if (cameraPanel.getTag() == null) { cameraPanel.setTag(1); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(ObjectAnimator.ofFloat(cameraPanel, "alpha", 0.0f), ObjectAnimator.ofFloat(flashModeButton[0], "alpha", 0.0f), ObjectAnimator.ofFloat(flashModeButton[1], "alpha", 0.0f)); animatorSet.setDuration(200); animatorSet.start(); } } } else if (event.getActionMasked() == MotionEvent.ACTION_CANCEL || event.getActionMasked() == MotionEvent.ACTION_UP || event.getActionMasked() == MotionEvent.ACTION_POINTER_UP) { pressed = false; if (Math.abs(cameraView.getTranslationY()) > cameraView.getMeasuredHeight() / 6.0f) { closeCamera(true); } else { AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(ObjectAnimator.ofFloat(cameraView, "translationY", 0.0f), ObjectAnimator.ofFloat(cameraPanel, "alpha", 1.0f), ObjectAnimator.ofFloat(flashModeButton[0], "alpha", 1.0f), ObjectAnimator.ofFloat(flashModeButton[1], "alpha", 1.0f)); animatorSet.setDuration(250); animatorSet.setInterpolator(interpolator); animatorSet.start(); cameraPanel.setTag(null); } } } return true; }
From source file:com.example.aaron.test.MyGLSurfaceView.java
@Override public boolean onTouchEvent(MotionEvent e) { float x = e.getX(); float y = e.getY(); int cc = 0;/*from w ww.ja v a2 s .c om*/ /* float xGL=(width1/2-x)/(float)(height1/1.85); float yGL=( height1/2+30-y)/(float)(height1/1.85); */ float xGL = (width1 / 2 - x) / (float) (height1 / 2); float yGL = (height1 / 2 - y) / (float) (height1 / 2); workspace = -(width1 - 115) / (height1 * 2) + .15f - mRenderer.slider; mRenderer.tempFun(xGL, yGL); switch (e.getActionMasked()) { case MotionEvent.ACTION_DOWN: mRenderer.tToggle = 1; for (int i = 0; i < maxBots; i++) { if (tList[i].getOn() == 1) { cc = cc + 1; if (Math.abs(tList[i].getX() * getScale() + mRenderer.dragX * mRenderer.scale - xGL) < .1f && Math.abs( tList[i].getY() * getScale() + mRenderer.dragY * mRenderer.scale - yGL) < .1f) { if (state[i] == 0) { state[i] = 1; } else { state[i] = 0; } v.vibrate(50); } } } if (antispam > 1) { if (xGL < .85 && xGL > .65 && yGL > -.95 && yGL < -.75) { mRenderer.scale = mRenderer.scale + .5f; mRenderer.textList.get(1).setText("Scale: " + truncateDecimal(mRenderer.scale, 1) + "x"); mRenderer.textList.get(2).setText(truncateDecimal(2 / mRenderer.scale, 2) + " ft"); v.vibrate(75); break; } if (xGL < 1.2f && xGL > .95f && yGL > -.85f && yGL < -.75 && mRenderer.scale > .5f) { mRenderer.scale = mRenderer.scale - .5f; mRenderer.textList.get(1).setText("Scale: " + truncateDecimal(mRenderer.scale, 1) + "x"); mRenderer.textList.get(2).setText(truncateDecimal(2 / mRenderer.scale, 2) + " ft"); v.vibrate(75); break; } if (mRenderer.commit.blocked == false && xGL < mRenderer.commit.left - mRenderer.slider && xGL > mRenderer.commit.right - mRenderer.slider && yGL > mRenderer.commit.down && yGL < mRenderer.commit.up) if (mRenderer.commit.active == true) { mRenderer.commit.active = false; newAction = true; v.vibrate(50); } else { mRenderer.commit.active = true; if (mRenderer.customFormation.active) { mRenderer.justifyRelativePositions(); mRenderer.resetScaleAndRotation(); mRenderer.formation.send = true; } newAction = true; v.vibrate(50); } //Turn on voronoi toggle if (buttonPush(xGL, yGL, mRenderer.vorToggle)) if (mRenderer.getvToggle() == 1) { mRenderer.setvToggle(0); v.vibrate(500); } else { mRenderer.setvToggle(1); v.vibrate(500); } vFlag = mRenderer.getvToggle(); //Turn on Free Draw Toggle if (buttonPush(xGL, yGL, mRenderer.freeDrawToggle)) if (mRenderer.getfToggle() == 1) { mRenderer.setfToggle(0); fFlag = mRenderer.getfToggle(); } else { mRenderer.setfToggle(1); mRenderer.eraseFreeLine(); freeDrawCount = 0; previousy = 0; previousx = 0; connectable = 0; firstPointFreeDraw[0] = -1000; firstPointFreeDraw[1] = -1000; fFlag = mRenderer.getfToggle(); } //Toggable swarm for Path Follower /*if (mRenderer.getfToggle()==1 && xGL<mRenderer.swarmToggle.left- mRenderer.slider&& xGL>mRenderer.swarmToggle.right-mRenderer.slider&& yGL > mRenderer.swarmToggle.down && yGL < mRenderer.swarmToggle.up) if (mRenderer.swarmToggle.active == true) { mRenderer.swarmToggle.active = false; v.vibrate(50); } else { mRenderer.swarmToggle.active = true; v.vibrate(50); } */ //THIS FEATURE CAN BE ADDED LATER IF WE WANT //Turn on Way Point Toggle if (buttonPush(xGL, yGL, mRenderer.wayPointToggle)) if (mRenderer.getpToggle() == 1) { mRenderer.setpToggle(0); pFlag2 = 0; mRenderer.setpToggle2(pFlag2); mRenderer.tToggle = 1; pX = 0; pY = 0; } else { mRenderer.tToggle = 0; mRenderer.setpToggle(1); mRenderer.voronoiDeploymentToggle.active = false; pX = 0; pY = 0; } pFlag = mRenderer.getpToggle(); //Turn on AndroneToggle if (buttonPush(xGL, yGL, mRenderer.ardronePrefToggle)) if (mRenderer.getAPToggle() == 1) { mRenderer.setAPToggle(0); mRenderer.SINFO_FLAG = true; } else { mRenderer.setAPToggle(1); mRenderer.SINFO_FLAG = false; } if (buttonPush(xGL, yGL, mRenderer.gaussianTrackToggle)) { if (mRenderer.gaussianTrackToggle.active == true) { mRenderer.gaussianTrackToggle.active = false; } else { mRenderer.gaussianTrackToggle.active = true; } v.vibrate(50); } if (buttonPush(xGL, yGL, mRenderer.formation)) { if (mRenderer.formation.active == true) { mRenderer.formation.active = false; mRenderer.formation.send = false; } else { mRenderer.formation.active = true; mRenderer.formation.send = true; mRenderer.refreshFormationtext(); } } if (buttonPush(xGL, yGL, mRenderer.formationToggleTransform)) { if (mRenderer.formationToggleTransform.active == true) { mRenderer.formationToggleTransform.active = false; } else { mRenderer.formationToggleTransform.active = true; mRenderer.customFormation.active = false; mRenderer.commit.blocked = true; mRenderer.refreshFormationtext(); } } if (buttonPush(xGL, yGL, mRenderer.customFormation)) { if (mRenderer.customFormation.active == true) { mRenderer.customFormation.active = false; mRenderer.commit.blocked = true; } else { mRenderer.customFormation.active = true; mRenderer.resetFormation(); mRenderer.refreshCenter(); mRenderer.formationToggleTransform.active = false; mRenderer.commit.blocked = false; mRenderer.commit.active = false; mRenderer.refreshFormationtext(); } } if (buttonPush(xGL, yGL, mRenderer.ardroneAddToggle)) { dummyFlag = 1; } if (buttonPush(xGL, yGL, mRenderer.addToggle)) { mRenderer.formation.val1 = mRenderer.formation.val1 + 1; mRenderer.refreshFormationtext(); mRenderer.formation.send = true; } if (buttonPush(xGL, yGL, mRenderer.subtractToggle)) { mRenderer.formation.val1 = mRenderer.formation.val1 - 1; mRenderer.refreshFormationtext(); mRenderer.formation.send = true; } if (buttonPush(xGL, yGL, mRenderer.freeBoundarytoggle)) { if (mRenderer.freeBoundarytoggle.active == true) { mRenderer.freeBoundarytoggle.active = false; freeBoundaryFlag = true; closedBoundaryFlag = false; } else { mRenderer.freeBoundarytoggle.active = true; closedBoundaryFlag = true; freeBoundaryFlag = false; } } if (buttonPush(xGL, yGL, mRenderer.obstacleLineToggle)) { System.out.println("obstacle Line Pushed"); addObstacleFlag = true; mRenderer.makeObstacle(); mRenderer.fToggle = 0; fFlag = mRenderer.fToggle; } //IF GAUSS TOGGLE SELECTED if (buttonPush(xGL, yGL, mRenderer.gaussToggle)) if (mRenderer.getgToggle() == 1) { mRenderer.setgToggle(0); gFlag2 = 0; mRenderer.setgToggle2(gFlag2); } else { mRenderer.setgToggle(1); } gFlag = mRenderer.getgToggle(); //IF GAUSSPATH TOGGLE SELECTED /*if (xGL<mRenderer.temptoggle.left- mRenderer.slider&& xGL>mRenderer.temptoggle.right-mRenderer.slider&& yGL > mRenderer.temptoggle.down && yGL < mRenderer.temptoggle.up) if (mRenderer.getgpToggle() == 1) { mRenderer.setgpToggle(0); mRenderer.eraseGaussLine(); v.vibrate(50); } else { mRenderer.setgpToggle(1); mRenderer.makeGaussPoints(); v.vibrate(50); }*/ gpFlag = mRenderer.getgpToggle(); //Toggle for voronoi deployment if (buttonPush(xGL, yGL, mRenderer.voronoiDeploymentToggle)) if (mRenderer.voronoiDeploymentToggle.active == true) { mRenderer.voronoiDeploymentToggle.active = false; newAction = true; } else { newAction = true; mRenderer.voronoiDeploymentToggle.active = true; mRenderer.setpToggle(0); mRenderer.setpToggle2(0); } if (buttonPush(xGL, yGL, mRenderer.dragToggle)) { addedTurtleNumber = 0; addedTurtleX = .1f; addedTurtleY = .1f; for (int j = 41; j < 44; j++) { if (tList[j].getOn() != 1) { addedTurtleNumber = j; } } if (addedTurtleNumber == 0) { addTurtleFlag = false; } else { addTurtleFlag = true; } } if (buttonPush(xGL, yGL, mRenderer.addTurtle)) { addedTurtleNumber = 0; addedTurtleX = .1f; addedTurtleY = .1f; for (int j = 1; j < 11; j++) { if (tList[j].getOn() != 1) { addedTurtleNumber = j; } } if (addedTurtleNumber == 0) { addTurtleFlag = false; } else { addTurtleFlag = true; } } if (buttonPush(xGL, yGL, mRenderer.dragRobotToggle)) { if (mRenderer.dragRobotToggle.active == false) { mRenderer.dragRobotToggle.active = true; } else { mRenderer.dragRobotToggle.active = false; } } if (buttonPush(xGL, yGL, mRenderer.gaussianPathToggle)) { if (mRenderer.gaussianPathToggle.active == true) { mRenderer.gaussianPathToggle.active = false; mRenderer.gaussPathPlay.active = false; } else { mRenderer.gaussianPathToggle.active = true; if (mRenderer.getfToggle() == 1) {// mRenderer.gaussPathPlay.active = true; mRenderer.updateGauss( mRenderer.pathArray.pose[0].x * mRenderer.scale + mRenderer.dragX * mRenderer.scale, mRenderer.pathArray.pose[0].y * mRenderer.scale + mRenderer.dragY * mRenderer.scale, 0); gaussianPathArrayIteration = 1; deltaX = (mRenderer.pathArray.pose[gaussianPathArrayIteration].x - mRenderer.pathArray.pose[gaussianPathArrayIteration - 1].x) / (float) Math.sqrt(Math .pow(mRenderer.pathArray.pose[gaussianPathArrayIteration].x - mRenderer.pathArray.pose[gaussianPathArrayIteration - 1].x, 2) + Math.pow(mRenderer.pathArray.pose[gaussianPathArrayIteration].y - mRenderer.pathArray.pose[gaussianPathArrayIteration - 1].y, 2)); deltaY = (mRenderer.pathArray.pose[gaussianPathArrayIteration].y - mRenderer.pathArray.pose[gaussianPathArrayIteration - 1].y) / (float) Math.sqrt(Math .pow(mRenderer.pathArray.pose[gaussianPathArrayIteration].x - mRenderer.pathArray.pose[gaussianPathArrayIteration - 1].x, 2) + Math.pow(mRenderer.pathArray.pose[gaussianPathArrayIteration].y - mRenderer.pathArray.pose[gaussianPathArrayIteration - 1].y, 2)); } } } if (xGL < mRenderer.clearAll.left - mRenderer.slider && xGL > mRenderer.clearAll.right - mRenderer.slider && yGL > mRenderer.clearAll.down && yGL < mRenderer.clearAll.up) { if (mRenderer.clearAll.active == true) { mRenderer.clearAll.active = false; v.vibrate(50); } else { mRenderer.clearAll.active = true; v.vibrate(50); } } if (xGL < mRenderer.resetToggle.left - mRenderer.slider && xGL > mRenderer.resetToggle.right - mRenderer.slider && yGL > mRenderer.resetToggle.down && yGL < mRenderer.resetToggle.up) { if (mRenderer.resetToggle.active == true) { mRenderer.resetToggle.active = false; v.vibrate(50); } else { mRenderer.resetToggle.active = true; v.vibrate(50); } } /* if (xGL<-(width1-90)/height1+.05f && xGL>-(width1-90)/height1 && yGL >-(height1-10)/(height1)-mRenderer.slider && yGL < -(height1-10)/(height1)+05f-mRenderer.slider ){ }*/ //Clear button if (xGL < mRenderer.clear.left - mRenderer.slider && xGL > mRenderer.clear.right - mRenderer.slider && yGL > mRenderer.clear.down && yGL < mRenderer.clear.up) { if (mRenderer.getgToggle() == 1) { gInd = 0; mRenderer.clearGauss(); } if (mRenderer.dragToggle.active == true) { obsticle.on = 0; } deleteTurtleNumber = -1; for (int i = 0; i < maxBots; i++) { if (tList[i].getState() == 1) { deleteTurtleNumber = i; } } if (deleteTurtleNumber != -1) { deleteTurtleFlag = true; } else { deleteTurtleFlag = false; } v.vibrate(75); mRenderer.clear.active = true; } } if (pFlag == 1 && xGL > workspace && xGL < mapLeft && yGL < mapTop && yGL > mapBottom) { pX = xGL - mRenderer.dragX * mRenderer.scale; pY = yGL - mRenderer.dragY * mRenderer.scale; pFlag2 = 1; mRenderer.setpToggle2(pFlag2); mRenderer.setWayPointValues(pX, pY); } if (gFlag == 1 && xGL > workspace && xGL < mapLeft && yGL < mapTop && yGL > mapBottom) { //pX=xGL; //pY=yGL; gFlag2 = 1; mRenderer.setgToggle2(gFlag2); //System.out.println("GAUSSIAN INDEX: " +gInd); //mRenderer.setWayPointValues(xGL, yGL); //mRenderer.setGaussValues(xGL, yGL, gInd); //mRenderer.setGaussScale(1f); if (gInd < 99) { //mRenderer.addGaussStuff(xGL, yGL, 1f,gInd); //TEMP FIX mRenderer.addGaussStuff(xGL, yGL, 1f, 0); } gInd++; } if (mRenderer.gToggle == 0 && mRenderer.fToggle == 0 && mRenderer.directionalDrag.active == true && (mRenderer.directionalDrag.active == true && xGL < mRenderer.directionalDrag.left - mRenderer.slider && xGL > mRenderer.directionalDrag.right - mRenderer.slider && yGL > mRenderer.directionalDrag.down && yGL < mRenderer.directionalDrag.up)) { v.vibrate(50); if (xGL > mRenderer.directionalDrag.left + (mRenderer.directionalDrag.right - mRenderer.directionalDrag.left) / 3 - mRenderer.slider) { mRenderer.dragX = mRenderer.dragX - .01f; } if (xGL < mRenderer.directionalDrag.left + 2 * (mRenderer.directionalDrag.right - mRenderer.directionalDrag.left) / 3 - mRenderer.slider) { mRenderer.dragX = mRenderer.dragX + .01f; } if (yGL > mRenderer.directionalDrag.up + (mRenderer.directionalDrag.down - mRenderer.directionalDrag.up) / 3) { mRenderer.dragY = mRenderer.dragY - .01f; } if (yGL < mRenderer.directionalDrag.up + 2 * (mRenderer.directionalDrag.down - mRenderer.directionalDrag.up) / 3) { mRenderer.dragY = mRenderer.dragY + .01f; } } case MotionEvent.ACTION_POINTER_DOWN: //System.out.println("GAUSS 0"); if (e.getActionIndex() == 1) { if (gFlag == 1) { float gaussX = e.getX(1); float gaussY = e.getY(1); float gauss_xGL = (width1 / 2 - gaussX) / (float) (height1 / 1.85); float gauss_yGL = (height1 / 2 + 30 - gaussY) / (float) (height1 / 1.85); float gauss_dx = gauss_xGL - xGL; float gauss_dy = gauss_yGL - yGL; float dgauss = (float) Math.sqrt(Math.pow(gauss_dx, 2) + Math.pow(gauss_dy, 2)); gaussScale = dgauss / .2f; //System.out.println("SCALE"); //mRenderer.addGaussStuff(xGL, yGL, gaussScale,gInd-1); //mRenderer.setGaussScale(gInd-1, gaussScale); //TEMP FIX mRenderer.setGaussScale(0, gaussScale); } } case MotionEvent.ACTION_MOVE: mRenderer.tToggle = 1; float dx = x - mPreviousX; float dy = y - mPreviousY; if (mRenderer.dragRobotToggle.active) { for (int i = 0; i < maxBots; i++) { if (tList[i].getOn() == 1) { if (Math.abs(tList[i].getX() * getScale() + mRenderer.dragX * mRenderer.scale - xGL) < .1f && Math.abs(tList[i].getY() * getScale() + mRenderer.dragY * mRenderer.scale - yGL) < .1f) { addedTurtleNumber = i; addedTurtleX = xGL / getScale() - mRenderer.dragX; addedTurtleY = yGL / getScale() - mRenderer.dragY; addTurtleFlag = true; v.vibrate(50); } } } } //pX+(float)Math.cos(formation.val4)*.3f+dragX*scale, pY+(float)Math.sin(formation.val4)*.3f+dragY*scale, 0); if (mRenderer.formation.active && mRenderer.formationToggleTransform.active) { if (Math.abs(mRenderer.formation.x * mRenderer.scale + (float) Math.cos(mRenderer.formation.val4) * .3f * mRenderer.scale + mRenderer.dragX * mRenderer.scale - xGL) < .15f && Math.abs(mRenderer.formation.y * mRenderer.scale + (float) Math.sin(mRenderer.formation.val4) * .3f * mRenderer.scale + mRenderer.dragY * mRenderer.scale - yGL) < .15f) { mRenderer.formation.val4 = (float) Math.atan2( yGL - (mRenderer.formation.y * mRenderer.scale + mRenderer.dragY * mRenderer.scale), xGL - (mRenderer.formation.x * mRenderer.scale + mRenderer.dragX * mRenderer.scale)); mRenderer.refreshFormationtext(); mRenderer.justifyFormationLocations(); mRenderer.rotation_block.active = true; mRenderer.formation.send = true; } else { mRenderer.rotation_block.active = false; } } if (mRenderer.formation.active && mRenderer.formationToggleTransform.active) { if (Math.abs( mRenderer.formation.x * mRenderer.scale + mRenderer.dragX * mRenderer.scale - xGL) < .15f && Math.abs(mRenderer.formation.y * mRenderer.scale + mRenderer.dragY * mRenderer.scale - yGL) < .15f) { pX = xGL - mRenderer.scale * mRenderer.dragX; pY = yGL - mRenderer.scale * mRenderer.dragY; mRenderer.setWayPointValues(pX, pY); mRenderer.refreshFormationtext(); mRenderer.justifyFormationLocations(); mRenderer.center_block.active = true; mRenderer.formation.send = true; } else { mRenderer.center_block.active = false; } } if (mRenderer.formation.active && mRenderer.formationToggleTransform.active) { if (Math.abs(mRenderer.formation.x * mRenderer.scale + mRenderer.dragX * mRenderer.scale + mRenderer.formation.val3 * .2f * mRenderer.scale - xGL) < .15f && Math.abs(mRenderer.formation.y * mRenderer.scale + mRenderer.dragY * mRenderer.scale - yGL) < .15f) { mRenderer.formation.val3 = (xGL - (mRenderer.formation.x * mRenderer.scale + mRenderer.dragX * mRenderer.scale)) / .2f / mRenderer.scale; mRenderer.refreshFormationtext(); mRenderer.justifyFormationLocations(); mRenderer.scale_block.active = true; mRenderer.formation.send = true; } else { mRenderer.scale_block.active = false; } } if (mRenderer.formation.active && mRenderer.customFormation.active) { for (int i = 0; i < mRenderer.formation.val1; i++) { if (target(convertToScreenPosition(mRenderer.formation_locations.x[i], true), xGL, convertToScreenPosition(mRenderer.formation_locations.y[i], false), yGL, .15f)) { //mRenderer.formation.x=mRenderer.formation.x*mRenderer.formation.val1-mRenderer.formation_locations.x[i]; //mRenderer.formation.y=mRenderer.formation.y*mRenderer.formation.val1-mRenderer.formation_locations.y[i]; mRenderer.formation_locations.x[i] = convertToGlobalPosition(xGL, true); mRenderer.formation_locations.y[i] = convertToGlobalPosition(yGL, false); //mRenderer.formation.x=mRenderer.formation.x+mRenderer.formation_locations.x[i]; //mRenderer.formation.x=mRenderer.formation.x/mRenderer.formation.val1; //mRenderer.formation.y=mRenderer.formation.y+mRenderer.formation_locations.y[i]; //mRenderer.formation.y=mRenderer.formation.y/mRenderer.formation.val1; mRenderer.refreshCenter(); break; } } } if (mRenderer.dragToggle.active == true && xGL > workspace && xGL < mapLeft && yGL < mapTop && yGL > mapBottom) { obsticle.x = xGL / getScale() - mRenderer.dragX; obsticle.y = yGL / getScale() - mRenderer.dragY; obsticle.Aw = 1; obsticle.on = 1; newObstacle = true; } if (mRenderer.gToggle == 0 && mRenderer.fToggle == 0 && mRenderer.directionalDrag.active == true && (mRenderer.directionalDrag.active == true && xGL < mRenderer.directionalDrag.left - mRenderer.slider && xGL > mRenderer.directionalDrag.right - mRenderer.slider && yGL > mRenderer.directionalDrag.down && yGL < mRenderer.directionalDrag.up)) { v.vibrate(50); if (xGL > mRenderer.directionalDrag.left + (mRenderer.directionalDrag.right - mRenderer.directionalDrag.left) / 3 - mRenderer.slider) { mRenderer.dragX = mRenderer.dragX - .01f; System.out.println("LEFT"); } if (xGL < mRenderer.directionalDrag.left + 2 * (mRenderer.directionalDrag.right - mRenderer.directionalDrag.left) / 3 - mRenderer.slider) { mRenderer.dragX = mRenderer.dragX + .01f; System.out.println("RIGHT"); } if (yGL > mRenderer.directionalDrag.up + (mRenderer.directionalDrag.down - mRenderer.directionalDrag.up) / 3) { mRenderer.dragY = mRenderer.dragY - .01f; System.out.println("UP"); } if (yGL < mRenderer.directionalDrag.up + 2 * (mRenderer.directionalDrag.down - mRenderer.directionalDrag.up) / 3) { mRenderer.dragY = mRenderer.dragY + .01f; System.out.println("DOWN"); } } if (fFlag == 1 && (Math.abs(xGL - previousx) > .03f || Math.abs(yGL - previousy) > .03f) && xGL > workspace && xGL < mapLeft && yGL < mapTop && yGL > mapBottom) { if (previousx != 0 && previousy != 0) { if (firstPointFreeDraw[0] == -1000) { firstPointFreeDraw[0] = previousx; firstPointFreeDraw[1] = previousy; } else if (xGL > firstPointFreeDraw[0] + .1f || xGL < firstPointFreeDraw[0] - .1f || yGL > firstPointFreeDraw[1] + .1f || yGL < firstPointFreeDraw[1] - .1f) { connectable = 1; } else if (connectable == 1) { fFlag = 0; setFreeDrawCoordinates(firstPointFreeDraw[0], firstPointFreeDraw[1], previousx, previousy, true); v.vibrate(50); } if (fFlag == 1) { setFreeDrawCoordinates(xGL - mRenderer.dragX * mRenderer.scale, yGL - mRenderer.dragY * mRenderer.scale, previousx - mRenderer.dragX * mRenderer.scale, previousy - mRenderer.dragY * mRenderer.scale, false); } } previousx = xGL; previousy = yGL; } // reverse direction of rotation above the mid-line if (y > getHeight() / 2) { dx = dx * -1; } // reverse direction of rotation to left of the mid-line if (x < getWidth() / 2) { dy = dy * -1; } if (yGL > -.15f && yGL < .15f && xGL > -(width1 - 115) / (height1 * 2) - mRenderer.slider && xGL < -(width1 - 115) / (height1 * 2) - mRenderer.slider + .15f) { mRenderer.slider = -(width1 - 115) / (height1 * 2) - xGL; if (mRenderer.slider < .1f) { mRenderer.slider = 0; } else if (mRenderer.slider > -.1f + (width1 - 115) / (height1 * 2)) { mRenderer.slider = (width1 - 115) / (height1 * 2); } } mRenderer.setAngle(mRenderer.getAngle() + ((dx + dy) * TOUCH_SCALE_FACTOR)); // = 180.0f / 320 requestRender(); if (pFlag == 1 && xGL > workspace && xGL < mapLeft && yGL < mapTop && yGL > mapBottom) { pX = xGL - mRenderer.scale * mRenderer.dragX; pY = yGL - mRenderer.scale * mRenderer.dragY; pFlag2 = 1; mRenderer.setpToggle2(pFlag2); mRenderer.setWayPointValues(pX, pY); } //moving gauss if (gFlag == 1 && xGL > workspace && xGL < mapLeft && yGL < mapTop && yGL > mapBottom) { pX = xGL; pY = yGL; gFlag2 = 1; mRenderer.setpToggle2(gFlag2); //TEMP FIX mRenderer.updateGauss(xGL, yGL, 0); //mRenderer.updateGauss(xGL, yGL, gInd-1); } if (mRenderer.gToggle == 1 && xGL < mRenderer.bar.left + .04f - mRenderer.slider && xGL > mRenderer.bar.right - .04f - mRenderer.slider && yGL > mRenderer.dial.down && yGL < mRenderer.dial.up) { mRenderer.dial1 = -(xGL - mRenderer.bar.left - mRenderer.slider) / .6f; if (mRenderer.dial1 < 0.05) { mRenderer.dial1 = 0; } else if (mRenderer.dial1 > 1) { mRenderer.dial1 = 1; } else if (mRenderer.dial1 < .15) { mRenderer.dial1 = .1f; } else if (mRenderer.dial1 < .25) { mRenderer.dial1 = .2f; } else if (mRenderer.dial1 < .35) { mRenderer.dial1 = .3f; } else if (mRenderer.dial1 < .45) { mRenderer.dial1 = .4f; } else if (mRenderer.dial1 < .55) { mRenderer.dial1 = .5f; } else if (mRenderer.dial1 < .65) { mRenderer.dial1 = .6f; } else if (mRenderer.dial1 < .75) { mRenderer.dial1 = .7f; } else if (mRenderer.dial1 < .85) { mRenderer.dial1 = .8f; } else if (mRenderer.dial1 < .95) { mRenderer.dial1 = .9f; } else { mRenderer.dial1 = 1; } mRenderer.textListGaussian.get(1).setText(" " + truncateDecimal(mRenderer.dial1, 1)); mRenderer.dial.active = true; v.vibrate(50); } if (mRenderer.gToggle == 1 && xGL < mRenderer.bar_2.left + .04f - mRenderer.slider && xGL > mRenderer.bar_2.right - .04f - mRenderer.slider && yGL > mRenderer.dial_2.down && yGL < mRenderer.dial_2.up) { mRenderer.dial2 = -(xGL - mRenderer.bar_2.left - mRenderer.slider) / .6f; if (mRenderer.dial2 < 0.05) { mRenderer.dial2 = 0; } else if (mRenderer.dial2 > 1) { mRenderer.dial2 = 1; } else if (mRenderer.dial2 < .15) { mRenderer.dial2 = .1f; } else if (mRenderer.dial2 < .25) { mRenderer.dial2 = .2f; } else if (mRenderer.dial2 < .35) { mRenderer.dial2 = .3f; } else if (mRenderer.dial2 < .45) { mRenderer.dial2 = .4f; } else if (mRenderer.dial2 < .55) { mRenderer.dial2 = .5f; } else if (mRenderer.dial2 < .65) { mRenderer.dial2 = .6f; } else if (mRenderer.dial2 < .75) { mRenderer.dial2 = .7f; } else if (mRenderer.dial2 < .85) { mRenderer.dial2 = .8f; } else if (mRenderer.dial2 < .95) { mRenderer.dial2 = .9f; } else { mRenderer.dial2 = 1; } mRenderer.textListGaussian.get(3).setText(" " + truncateDecimal(mRenderer.dial2, 1)); mRenderer.dial_2.active = true; v.vibrate(50); } if (mRenderer.gToggle == 1 && xGL < mRenderer.bar_3.left + .04f - mRenderer.slider && xGL > mRenderer.bar_3.right - .04f - mRenderer.slider && yGL > mRenderer.dial_3.down && yGL < mRenderer.dial_3.up) { mRenderer.dial3 = -(xGL - mRenderer.bar_3.left - mRenderer.slider) / .6f; if (mRenderer.dial3 < 0.05) { mRenderer.dial3 = 0; } else if (mRenderer.dial3 > 1) { mRenderer.dial3 = 1; } else if (mRenderer.dial3 < .15) { mRenderer.dial3 = .1f; } else if (mRenderer.dial3 < .25) { mRenderer.dial3 = .2f; } else if (mRenderer.dial3 < .35) { mRenderer.dial3 = .3f; } else if (mRenderer.dial3 < .45) { mRenderer.dial3 = .4f; } else if (mRenderer.dial3 < .55) { mRenderer.dial3 = .5f; } else if (mRenderer.dial3 < .65) { mRenderer.dial3 = .6f; } else if (mRenderer.dial3 < .75) { mRenderer.dial3 = .7f; } else if (mRenderer.dial3 < .85) { mRenderer.dial3 = .8f; } else if (mRenderer.dial3 < .95) { mRenderer.dial3 = .9f; } else { mRenderer.dial3 = 1; } mRenderer.textListGaussian.get(5).setText(" " + truncateDecimal(mRenderer.dial3, 1)); mRenderer.dial_3.active = true; v.vibrate(50); } case MotionEvent.ACTION_UP: mRenderer.tToggle = 1; //mRenderer.clear.active = false; } mPreviousX = x; mPreviousY = y; antispam = 0; return true; }
From source file:com.ruesga.timelinechart.TimelineChartView.java
/** {@inheritDoc} */ @Override/* w w w.j a va 2 s . c o m*/ public boolean onTouchEvent(final MotionEvent event) { // Ignore events while performing scrolling animation if (mState == STATE_ZOOMING) { return true; } final int action = event.getActionMasked(); final int index = event.getActionIndex(); final int pointerId = event.getPointerId(index); final long now = System.currentTimeMillis(); mLastX = event.getX(); mLastY = event.getY(); switch (action) { case MotionEvent.ACTION_DOWN: // Initialize velocity tracker if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain(); } else { mVelocityTracker.clear(); } mVelocityTracker.addMovement(event); mScroller.forceFinished(true); releaseEdgeEffects(); mState = STATE_INITIALIZE; mLongPressDetector.mLongPressTriggered = false; mUiHandler.postDelayed(mLongPressDetector, mLongPressTimeout); mInitialTouchOffset = mCurrentOffset; mInitialTouchX = event.getX(); mInitialTouchY = event.getY(); mLastPressTimestamp = now; return true; case MotionEvent.ACTION_MOVE: // If a long press was detected then we end with the movement if (mLongPressDetector.mLongPressTriggered) { return true; } mVelocityTracker.addMovement(event); float diffX = event.getX() - mInitialTouchX; float diffY = event.getY() - mInitialTouchY; if (Math.abs(diffX) > mTouchSlop || mState >= STATE_MOVING) { mUiHandler.removeCallbacks(mLongPressDetector); mCurrentOffset = mInitialTouchOffset + diffX; if (mCurrentOffset < 0) { onOverScroll(); mCurrentOffset = 0; } else if (mCurrentOffset > mMaxOffset) { onOverScroll(); mCurrentOffset = mMaxOffset; } mVelocityTracker.computeCurrentVelocity(1000, mMaxFlingVelocity); mState = STATE_MOVING; ViewCompat.postInvalidateOnAnimation(this); } else if (Math.abs(diffY) > mTouchSlop && mState < STATE_MOVING) { mUiHandler.removeCallbacks(mLongPressDetector); return false; } return true; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mUiHandler.removeCallbacks(mLongPressDetector); // If a long press was detected then we end with the movement if (mLongPressDetector.mLongPressTriggered) { return true; } if (mState >= STATE_MOVING) { final int velocity = (int) VelocityTrackerCompat.getXVelocity(mVelocityTracker, pointerId); mScroller.forceFinished(true); mState = STATE_FLINGING; releaseEdgeEffects(); mScroller.fling((int) mCurrentOffset, 0, velocity, 0, 0, (int) mMaxOffset, 0, 0); ViewCompat.postInvalidateOnAnimation(this); } else { // Reset scrolling state mState = STATE_IDLE; if (action == MotionEvent.ACTION_UP) { // we are in a tap or long press action final long timeDiff = (now - mLastPressTimestamp); // If diff < 0, that means that time have change. ignore this event if (timeDiff >= 0) { if (timeDiff > TAP_TIMEOUT && timeDiff < mLongPressTimeout) { // A tap event happens. Long click are detected outside Message.obtain(mUiHandler, MSG_ON_CLICK_ITEM, computeItemEvent()).sendToTarget(); } } } } mLastPressTimestamp = -1; return true; } return false; }
From source file:com.tct.mail.ui.ConversationViewFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { LogUtils.d(LOG_TAG, "IN CVF.onActivityCreated, this=%s visible=%s", this, isUserVisible()); super.onActivityCreated(savedInstanceState); if (mActivity == null || mActivity.isFinishing()) { // Activity is finishing, just bail. return;//from w ww .j ava 2s. co m } Context context = getContext(); mTemplates = new HtmlConversationTemplates(context); final FormattedDateBuilder dateBuilder = new FormattedDateBuilder(context); mNavigationController = mActivity.getKeyboardNavigationController(); mAdapter = new ConversationViewAdapter(mActivity, this, getLoaderManager(), this, this, getContactInfoSource(), this, this, getListController(), this, mAddressCache, dateBuilder, mBidiFormatter, this); mConversationContainer.setOverlayAdapter(mAdapter); // set up snap header (the adapter usually does this with the other ones) mConversationContainer.getSnapHeader().initialize(this, mAddressCache, this, getContactInfoSource(), mActivity.getAccountController().getVeiledAddressMatcher()); final Resources resources = getResources(); mMaxAutoLoadMessages = resources.getInteger(R.integer.max_auto_load_messages); mSideMarginPx = resources.getDimensionPixelOffset(R.dimen.conversation_message_content_margin_side); mUrlToMessageIdMap = new ArrayMap<String, String>(); final InlineAttachmentViewIntentBuilderCreator creator = InlineAttachmentViewIntentBuilderCreatorHolder .getInlineAttachmentViewIntentCreator(); final WebViewContextMenu contextMenu = new WebViewContextMenu(getActivity(), creator .createInlineAttachmentViewIntentBuilder(mAccount, mConversation != null ? mConversation.id : -1)); contextMenu.setCallbacks(this); mWebView.setOnCreateContextMenuListener(contextMenu); // TS: zhaotianyong 2015-03-13 EMAIL BUGFIX-932165 ADD_S mWebView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub final int action = event.getActionMasked(); if (action == MotionEvent.ACTION_UP && webViewScaleHasChanged) { mWebView.loadUrl(String.format("javascript:setConversationHeaderSpacerHeight(%s);", mCovHeaderHeight * mWebView.getInitialScale() / mWebView.getScale())); if (mAdapter.getMessageHeaderItem() != null) { mWebView.loadUrl(String.format("javascript:setMessageHeaderSpacerHeight('%s', %s);", mTemplates.getMessageDomId(mAdapter.getMessageHeaderItem().getMessage()), mMsgHeaderHeight * mWebView.getInitialScale() / mWebView.getScale())); } mWebView.loadUrl(String.format("javascript:setConversationFooterSpacerHeight(%s);", mCovFooterHegiht * mWebView.getInitialScale() / mWebView.getScale())); webViewScaleHasChanged = false; } return mWebView.onTouchEvent(event); } }); // TS: zhaotianyong 2015-03-13 EMAIL BUGFIX-932165 ADD_E //TS: tao.gan 2015-09-10 EMAIL FEATURE-559891 ADD_S mFabButton.setAccountController(this); //Because we can't get the webview's contentHeight when onPageFinished(),so set the PictureListener //to get the contentHeight and judge if it's initialized bottom,and then do the animation. mWebView.setPictureListener(new PictureListener() { int previousHeight; @Deprecated public void onNewPicture(WebView w, Picture picture) { // TODO Auto-generated method stub int height = w.getContentHeight(); if (previousHeight == height) return; previousHeight = height; if (mWebView.isInitializedBottom()) { mWebView.animateBottom(true); } else { mWebView.animateHideFooter(); } } }); //TS: tao.gan 2015-09-10 EMAIL FEATURE-559891 ADD_E // set this up here instead of onCreateView to ensure the latest Account is loaded setupOverviewMode(); // Defer the call to initLoader with a Handler. // We want to wait until we know which fragments are present and their final visibility // states before going off and doing work. This prevents extraneous loading from occurring // as the ViewPager shifts about before the initial position is set. // // e.g. click on item #10 // ViewPager.setAdapter() actually first loads #0 and #1 under the assumption that #0 is // the initial primary item // Then CPC immediately sets the primary item to #10, which tears down #0/#1 and sets up // #9/#10/#11. getHandler().post(new FragmentRunnable("showConversation", this) { @Override public void go() { showConversation(); } }); if (mConversation != null && mConversation.conversationBaseUri != null && !Utils.isEmpty(mAccount.accountCookieQueryUri)) { // Set the cookie for this base url new SetCookieTask(getContext(), mConversation.conversationBaseUri.toString(), mAccount.accountCookieQueryUri).execute(); } // Find the height of the screen for manually scrolling the webview via keyboard. final Rect screen = new Rect(); mActivity.getWindow().getDecorView().getWindowVisibleDisplayFrame(screen); mMaxScreenHeight = screen.bottom; mTopOfVisibleScreen = screen.top + mActivity.getSupportActionBar().getHeight(); //[BUGFIX]-Add-BEGIN?by?TSCD.zheng.zou,01/14/2015,887972 //[Email]It?still?display?download?remaining?when?rotate?the?screen?during?loading //note:use initLoader to reconnect with the previous loader. if (savedInstanceState != null) { mIsDownloadingRemaining = savedInstanceState.getBoolean(IS_DOWNLOADING_REMAINING); mIsPopDownloadRemain = savedInstanceState.getBoolean(IS_POP_DOWNLOAD_REMAIN); } LoaderManager lm = getLoaderManager(); if (lm.getLoader(LOADER_DOWNLOAD_REMAINING) != null) { lm.initLoader(LOADER_DOWNLOAD_REMAINING, null, mDownloadRemainCallback); } //[BUGFIX]-Add-END?by?TSCD.zheng.zou }
From source file:com.android.systemui.statusbar.phone.NotificationPanelView.java
private void initDownStates(MotionEvent event) { if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { mOnlyAffordanceInThisMotion = false; mQsTouchAboveFalsingThreshold = mQsFullyExpanded; mDozingOnDown = isDozing();//from ww w . j a va2 s. c o m mCollapsedOnDown = isFullyCollapsed(); mListenForHeadsUp = mCollapsedOnDown && mHeadsUpManager.hasPinnedHeadsUp(); } }
From source file:com.android.systemui.statusbar.phone.NotificationPanelView.java
private void handleQsDown(MotionEvent event) { if (event.getActionMasked() == MotionEvent.ACTION_DOWN && shouldQuickSettingsIntercept(event.getX(), event.getY(), -1)) { mQsTracking = true;/*from w w w.j a va2 s .c om*/ onQsExpansionStarted(); mInitialHeightOnTouch = mQsExpansionHeight; mInitialTouchY = event.getX(); mInitialTouchX = event.getY(); // If we interrupt an expansion gesture here, make sure to update the state correctly. notifyExpandingFinished(); } }
From source file:com.android.systemui.statusbar.phone.NotificationPanelView.java
private boolean handleQsTouch(MotionEvent event) { final int action = event.getActionMasked(); // screen statusBar animator by yangfan if (mStatusBarState == StatusBarState.KEYGUARD) { if (event.getY() < getResources().getDimensionPixelOffset(R.dimen.status_bar_height)) //modify by mare 2017/3/2 //=====================> //?true??action???? return false; //<===================== //modify by mare 2017/3/2 }// ww w . j av a2 s . c o m // screen statusBar animator by yangfan if (action == MotionEvent.ACTION_DOWN && getExpandedFraction() == 1f && mStatusBar.getBarState() != StatusBarState.KEYGUARD && !mQsExpanded && mQsExpansionEnabled) { // Down in the empty area while fully expanded - go to QS. mQsTracking = true; mConflictingQsExpansionGesture = true; onQsExpansionStarted(); mInitialHeightOnTouch = mQsExpansionHeight; mInitialTouchY = event.getX(); mInitialTouchX = event.getY(); } if (!isFullyCollapsed()) { handleQsDown(event); } if (!mQsExpandImmediate && mQsTracking) { onQsTouch(event); if (!mConflictingQsExpansionGesture) { return true; } } if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) { mConflictingQsExpansionGesture = false; } if (action == MotionEvent.ACTION_DOWN && isFullyCollapsed() && mQsExpansionEnabled) { mTwoFingerQsExpandPossible = true; } if (mTwoFingerQsExpandPossible && isOpenQsEvent(event) && event.getY(event.getActionIndex()) < mStatusBarMinHeight) { MetricsLogger.count(mContext, COUNTER_PANEL_OPEN_QS, 1); mQsExpandImmediate = true; requestPanelHeightUpdate(); // Normally, we start listening when the panel is expanded, but here we need to start // earlier so the state is already up to date when dragging down. setListening(true); } return false; }