Ejemplo n.º 1
0
 /** This function must be called from the UI thread. */
 public void abortAnimation() {
   checkMainThread();
   // this happens when gecko changes the viewport on us or if the device is rotated.
   // if that's the case, abort any animation in progress and re-zoom so that the page
   // snaps to edges. for other cases (where the user's finger(s) are down) don't do
   // anything special.
   switch (mState) {
     case FLING:
       mX.stopFling();
       mY.stopFling();
       // fall through
     case BOUNCE:
     case ANIMATED_ZOOM:
       // the zoom that's in progress likely makes no sense any more (such as if
       // the screen orientation changed) so abort it
       setState(PanZoomState.NOTHING);
       // fall through
     case NOTHING:
       // Don't do animations here; they're distracting and can cause flashes on page
       // transitions.
       synchronized (mTarget.getLock()) {
         mTarget.setViewportMetrics(getValidViewportMetrics());
       }
       break;
   }
 }
Ejemplo n.º 2
0
  private void finishAnimation() {
    checkMainThread();

    stopAnimationTimer();

    // Force a viewport synchronisation
    mTarget.setForceRedraw();
  }
Ejemplo n.º 3
0
 /** This function must be called on the UI thread. */
 public void preventedTouchFinished() {
   checkMainThread();
   if (mState == PanZoomState.WAITING_LISTENERS) {
     // if we enter here, we just finished a block of events whose default actions
     // were prevented by touch listeners. Now there are no touch points left, so
     // we need to reset our state and re-bounce because we might be in overscroll
     bounce();
   }
 }
Ejemplo n.º 4
0
 /** This function must be called on the UI thread. */
 public void startingNewEventBlock(MotionEvent event, boolean waitingForTouchListeners) {
   checkMainThread();
   mSubscroller.cancel();
   if (waitingForTouchListeners
       && (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
     // this is the first touch point going down, so we enter the pending state
     // seting the state will kill any animations in progress, possibly leaving
     // the page in overscroll
     setState(PanZoomState.WAITING_LISTENERS);
   }
 }
Ejemplo n.º 5
0
  public PanZoomController(PanZoomTarget target, EventDispatcher eventDispatcher) {
    mTarget = target;
    mSubscroller = new SubdocumentScrollHelper(this, eventDispatcher);
    mX = new AxisX(mSubscroller);
    mY = new AxisY(mSubscroller);

    mMainThread = GeckoApp.mAppContext.getMainLooper().getThread();
    checkMainThread();

    setState(PanZoomState.NOTHING);

    mEventDispatcher = eventDispatcher;
    registerEventListener(MESSAGE_ZOOM_RECT);
    registerEventListener(MESSAGE_ZOOM_PAGE);

    Axis.initPrefs();
  }
Ejemplo n.º 6
0
 /** This function must be called from the UI thread. */
 public void abortPanning() {
   checkMainThread();
   bounce();
 }