Exemple #1
0
 /** De-emphasize the other photos on the table. */
 public void fadeOutBackground(final View photo) {
   resolveBackgroundQueue();
   if (mBackgroudOptimization) {
     mBackground.animate().withLayer().setDuration(mPickUpDuration).alpha(0f);
   } else {
     mScrim.setAlpha(0f);
     mScrim.setVisibility(View.VISIBLE);
     bringChildToFront(mScrim);
     bringChildToFront(photo);
     mScrim.animate().withLayer().setDuration(mPickUpDuration).alpha(1f);
   }
 }
Exemple #2
0
  /** Animate to a random place and orientation, down on the table (visually small). */
  public void dropOnTable(final View photo, final Interpolator interpolator) {
    float angle = randfrange(-mImageRotationLimit, mImageRotationLimit);
    PointF p =
        randMultiDrop(
            sRNG.nextInt(),
            (float) sRNG.nextGaussian(),
            (float) sRNG.nextGaussian(),
            mWidth,
            mHeight);
    float x = p.x;
    float y = p.y;

    log("drop it at %f, %f", x, y);

    float x0 = photo.getX();
    float y0 = photo.getY();

    x -= mLongSide / 2f;
    y -= mShortSide / 2f;
    log("fixed offset is %f, %f ", x, y);

    float dx = x - x0;
    float dy = y - y0;

    float dist = (float) Math.hypot(dx, dy);
    int duration = (int) (1000f * dist / mThrowSpeed);
    duration = Math.max(duration, 1000);

    log("animate it");
    // toss onto table
    resolveBackgroundQueue();
    photo
        .animate()
        .withLayer()
        .scaleX(mTableRatio / mImageRatio)
        .scaleY(mTableRatio / mImageRatio)
        .rotation(angle)
        .x(x)
        .y(y)
        .setDuration(duration)
        .setInterpolator(interpolator)
        .withEndAction(
            new Runnable() {
              @Override
              public void run() {
                mWaitingToJoinBackground.add(photo);
              }
            });
  }