@Override
 public void animate(View view) {
   f = pickScale();
   f2 = pickScale();
   f3 = pickTranslation(view.getWidth(), f);
   f4 = pickTranslation(view.getHeight(), f);
   f5 = pickTranslation(view.getWidth(), f2);
   f6 = pickTranslation(view.getHeight(), f2);
   start(view, Image_Animation_Duration, f, f2, f3, f4, f5, f6);
 }
示例#2
0
  private void performDismiss(final View dismissView, final int dismissPosition) {
    // Animate the dismissed list item to zero-height and fire the dismiss callback when
    // all dismissed list item animations have completed. This triggers layout on each animation
    // frame; in the future we may want to do something smarter and more performant.

    final ViewGroup.LayoutParams lp = dismissView.getLayoutParams();
    final int originalHeight = dismissView.getHeight();

    ((ViewGroup) dismissView)
        .getChildAt(1)
        .animate()
        .translationX(0)
        .alpha(1f)
        .setListener(
            new AnimatorListenerAdapter() {

              @Override
              public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                ((ViewGroup) dismissView).removeViewAt(0);
                Log.d(
                    "Selected view",
                    dismissView.getClass()
                        + "..."
                        + dismissView.getId()
                        + mDismissAnimationRefCount);
                ValueAnimator animator =
                    ValueAnimator.ofInt(originalHeight, 0).setDuration(mAnimationTime);
                animator.addListener(
                    new AnimatorListenerAdapter() {
                      @Override
                      public void onAnimationEnd(Animator animation) {
                        --mDismissAnimationRefCount;
                        if (mDismissAnimationRefCount == 0) {
                          // No active animations, process all pending dismisses.
                          // Sort by descending position
                          Collections.sort(mPendingDismisses);

                          int[] dismissPositions = new int[mPendingDismisses.size()];
                          for (int i = mPendingDismisses.size() - 1; i >= 0; i--) {
                            dismissPositions[i] = mPendingDismisses.get(i).position;
                            Log.d("Dismiss positions....", dismissPositions[i] + "");
                          }
                          tcallbacks.onDismiss(mListView, dismissPositions);
                          //                            ViewGroup.LayoutParams lp;
                          //                          for (PendingDismissData pendingDismiss :
                          // mPendingDismisses) {
                          //                              // Reset view presentation
                          //                              lp =
                          // pendingDismiss.view.getLayoutParams();
                          //                              lp.height = originalHeight;
                          //                              pendingDismiss.view.setLayoutParams(lp);
                          //                          }
                          mPendingDismisses.clear();
                        }
                      }
                    });

                animator.addUpdateListener(
                    new ValueAnimator.AnimatorUpdateListener() {
                      @Override
                      public void onAnimationUpdate(ValueAnimator valueAnimator) {
                        lp.height = (Integer) valueAnimator.getAnimatedValue();
                        dismissView.setLayoutParams(lp);
                      }
                    });

                mPendingDismisses.add(new PendingDismissData(dismissPosition, dismissView));
                animator.start();
              }
            });
  }