Tabnine Logo
FlingAnimation.setStartVelocity
Code IndexAdd Tabnine to your IDE (free)

How to use
setStartVelocity
method
in
android.support.animation.FlingAnimation

Best Java code snippets using android.support.animation.FlingAnimation.setStartVelocity (Showing top 7 results out of 315)

origin: recruit-lifestyle/FloatingView

/**
 * Start fling animation(X coordinate)
 *
 * @param velocityX velocity X coordinate
 */
private void startFlingAnimationX(float velocityX) {
  final FlingAnimation flingAnimationX = new FlingAnimation(new FloatValueHolder());
  flingAnimationX.setStartVelocity(velocityX);
  flingAnimationX.setMaxValue(mPositionLimitRect.right);
  flingAnimationX.setMinValue(mPositionLimitRect.left);
  flingAnimationX.setStartValue(mParams.x);
  flingAnimationX.setFriction(ANIMATION_FLING_X_FRICTION);
  flingAnimationX.setMinimumVisibleChange(DynamicAnimation.MIN_VISIBLE_CHANGE_PIXELS);
  flingAnimationX.addUpdateListener(new DynamicAnimation.OnAnimationUpdateListener() {
    @Override
    public void onAnimationUpdate(DynamicAnimation animation, float value, float velocity) {
      final int x = Math.round(value);
      // Not moving, or the touch operation is continuing
      if (mParams.x == x || mVelocityTracker != null) {
        return;
      }
      // update y coordinate
      mParams.x = x;
      updateViewLayout();
    }
  });
  flingAnimationX.start();
}
origin: recruit-lifestyle/FloatingView

/**
 * Start fling animation(Y coordinate)
 *
 * @param velocityY velocity Y coordinate
 */
private void startFlingAnimationY(float velocityY) {
  final FlingAnimation flingAnimationY = new FlingAnimation(new FloatValueHolder());
  flingAnimationY.setStartVelocity(velocityY);
  flingAnimationY.setMaxValue(mPositionLimitRect.bottom);
  flingAnimationY.setMinValue(mPositionLimitRect.top);
  flingAnimationY.setStartValue(mParams.y);
  flingAnimationY.setFriction(ANIMATION_FLING_Y_FRICTION);
  flingAnimationY.setMinimumVisibleChange(DynamicAnimation.MIN_VISIBLE_CHANGE_PIXELS);
  flingAnimationY.addUpdateListener(new DynamicAnimation.OnAnimationUpdateListener() {
    @Override
    public void onAnimationUpdate(DynamicAnimation animation, float value, float velocity) {
      final int y = Math.round(value);
      // Not moving, or the touch operation is continuing
      if (mParams.y == y || mVelocityTracker != null) {
        return;
      }
      // update y coordinate
      mParams.y = y;
      updateViewLayout();
    }
  });
  flingAnimationY.start();
}
origin: Rkhcy/PhysicsBasedAnimation

  @Override
  public void onClick(View view) {
    final FlingAnimation flingAnimation = new FlingAnimation(img, DynamicAnimation.X);
    flingAnimation.setStartVelocity(500f);
    flingAnimation.setFriction(0.5f);
    flingAnimation.start();
  }
});
origin: richakhanna/physicsbasedanimation

  @Override
  public boolean onFling(MotionEvent downEvent, MotionEvent moveEvent, float velocityX, float velocityY) {
    //downEvent : when user puts his finger down on the view
    //moveEvent : when user lifts his finger at the end of the movement
    float distanceInX = Math.abs(moveEvent.getRawX() - downEvent.getRawX());
    float distanceInY = Math.abs(moveEvent.getRawY() - downEvent.getRawY());
    mTvFlingDistance.setText("distanceInX : " + distanceInX + "\n" + "distanceInY : " + distanceInY);
    if (distanceInX > MIN_DISTANCE_MOVED) {
      //Fling Right/Left
      FlingAnimation flingX = new FlingAnimation(mViewTobeFlung, DynamicAnimation.TRANSLATION_X);
      flingX.setStartVelocity(velocityX)
          .setMinValue(MIN_TRANSLATION) // minimum translationX property
          .setMaxValue(maxTranslationX)  // maximum translationX property
          .setFriction(FRICTION)
          .start();
    } else if (distanceInY > MIN_DISTANCE_MOVED) {
      //Fling Down/Up
      FlingAnimation flingY = new FlingAnimation(mViewTobeFlung, DynamicAnimation.TRANSLATION_Y);
      flingY.setStartVelocity(velocityY)
          .setMinValue(MIN_TRANSLATION)  // minimum translationY property
          .setMaxValue(maxTranslationY) // maximum translationY property
          .setFriction(FRICTION)
          .start();
    }
    return true;
  }
};
origin: google-developer-training/android-advanced

  @Override
  public boolean onTouchEvent(MotionEvent event) {
    switch (event.getActionMasked()) {
      case MotionEvent.ACTION_DOWN:
        // Create an animation that rotates around the views X value.
        FlingAnimation fling = new FlingAnimation(
            this, DynamicAnimation.ROTATION_X);
        // Set parameters and constraints for the animation.
        // This does almost a full rotation, but not quite.
        // Play with these values!
        fling.setStartVelocity(150) // In pixels per second.
            .setFriction(0.11f) // Friction slows animation.
            .start();
        break;
      default:
        // Do nothing.
    }
    return super.onTouchEvent(event);
  }
}
origin: TakuSemba/CropMe

@Override
public void fling(float velocity) {
  isFlinging = true;
  cancel();
  fling.addUpdateListener(updateListener);
  fling.addEndListener(endListener);
  fling.setStartVelocity(velocity).start();
}
origin: TakuSemba/CropMe

@Override
public void fling(float velocity) {
  cancel();
  isFlinging = true;
  fling.addUpdateListener(updateListener);
  fling.addEndListener(endListener);
  fling.setStartVelocity(velocity).start();
}
android.support.animationFlingAnimationsetStartVelocity

Popular methods of FlingAnimation

  • <init>
  • setFriction
  • start
  • addUpdateListener
  • setMaxValue
  • setMinValue
  • addEndListener
  • cancel
  • removeEndListener
  • removeUpdateListener
  • setMinimumVisibleChange
  • setStartValue
  • setMinimumVisibleChange,
  • setStartValue

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getResourceAsStream (ClassLoader)
  • getSharedPreferences (Context)
  • getSupportFragmentManager (FragmentActivity)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • Socket (java.net)
    Provides a client-side TCP socket.
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • ImageIO (javax.imageio)
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now