public void hideSearchBar(boolean shiftView) {
    if (shiftView) {
      mSearchViewContainer.animate().cancel();
      mSearchViewContainer.setAlpha(1);
      mSearchViewContainer.setTranslationY(0);
      mSearchViewContainer
          .animate()
          .withLayer()
          .alpha(0)
          .translationY(-mSearchView.getHeight())
          .setDuration(200)
          .setListener(mHideListener);

      mFragmentsFrame
          .animate()
          .withLayer()
          .translationY(-mSearchViewContainer.getHeight())
          .setDuration(200)
          .setListener(
              new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                  mBottomPaddingView.setVisibility(View.VISIBLE);
                  mFragmentsFrame.setTranslationY(0);
                  mActionBar.setVisibility(View.INVISIBLE);
                }
              });
    } else {
      mSearchViewContainer.setTranslationY(-mSearchView.getHeight());
      mActionBar.setVisibility(View.INVISIBLE);
    }
  }
Esempio n. 2
0
 public static void a(View paramView, dz paramdz) {
   if (paramdz != null) {
     paramView.animate().setListener(new dw(paramdz, paramView));
     return;
   }
   paramView.animate().setListener(null);
 }
  @TargetApi(12)
  public void crossfade() {

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB_MR1) {

      // Set the content view to 0% opacity but visible, so that it is visible
      // (but fully transparent) during the animation.
      contentView.setAlpha(0f);
      contentView.setVisibility(View.VISIBLE);

      // Animate the content view to 100% opacity, and clear any animation
      // listener set on the view.
      contentView.animate().alpha(1f).setDuration(animationDuration).setListener(null);

      // Animate the loading view to 0% opacity. After the animation ends,
      // set its visibility to GONE as an optimization step (it won't
      // participate in layout passes, etc.)
      progressView
          .animate()
          .alpha(0f)
          .setDuration(animationDuration)
          .setListener(
              new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(final Animator animation) {
                  progressView.setVisibility(View.GONE);
                }
              });
    } else {
      progressView.setVisibility(View.GONE);
      contentView.setVisibility(View.VISIBLE);
    }
  }
  public void showSearchBar() {
    mSearchViewContainer.animate().cancel();
    mSearchViewContainer.setAlpha(0);
    mSearchViewContainer.setTranslationY(-mSearchViewContainer.getHeight());
    mSearchViewContainer
        .animate()
        .withLayer()
        .alpha(1)
        .translationY(0)
        .setDuration(200)
        .setListener(
            new AnimatorListenerAdapter() {
              @Override
              public void onAnimationStart(Animator animation) {
                mSearchViewContainer.setVisibility(View.VISIBLE);
                mActionBar.setVisibility(View.VISIBLE);
              }
            });

    mFragmentsFrame.setTranslationY(-mSearchViewContainer.getHeight());
    mFragmentsFrame
        .animate()
        .withLayer()
        .translationY(0)
        .setDuration(200)
        .setListener(
            new AnimatorListenerAdapter() {
              @Override
              public void onAnimationStart(Animator animation) {
                mBottomPaddingView.setVisibility(View.GONE);
              }
            });
  }
  /** Shows a view, and synchronizes the animation with Keyguard exit animations, if applicable. */
  private void animateShow(View v, boolean animate) {
    v.animate().cancel();
    v.setVisibility(View.VISIBLE);
    if (!animate) {
      v.setAlpha(1f);
      return;
    }
    v.animate()
        .alpha(1f)
        .setDuration(320)
        .setInterpolator(PhoneStatusBar.ALPHA_IN)
        .setStartDelay(50)

        // We need to clean up any pending end action from animateHide if we call
        // both hide and show in the same frame before the animation actually gets started.
        // cancel() doesn't really remove the end action.
        .withEndAction(null);

    // Synchronize the motion with the Keyguard fading if necessary.
    if (mPhoneStatusBar.isKeyguardFadingAway()) {
      v.animate()
          .setDuration(mPhoneStatusBar.getKeyguardFadingAwayDuration())
          .setInterpolator(mLinearOutSlowIn)
          .setStartDelay(mPhoneStatusBar.getKeyguardFadingAwayDelay())
          .start();
    }
  }
  public void toggleHistoryPanel() {
    final View view = findViewById(R.id.mainPanel);
    final View viewList = findViewById(R.id.historyPanel);

    if (mShowingImageStatePanel) {
      findViewById(R.id.imageStatePanel).setVisibility(View.INVISIBLE);
      mShowingImageStatePanel = false;
    }

    int translate = translateMainPanel(viewList);
    if (!mShowingHistoryPanel) {
      mShowingHistoryPanel = true;
      view.animate()
          .setDuration(200)
          .x(translate)
          .withLayer()
          .withEndAction(
              new Runnable() {
                @Override
                public void run() {
                  viewList.setAlpha(0);
                  viewList.setVisibility(View.VISIBLE);
                  viewList.animate().setDuration(100).alpha(1.0f).start();
                }
              })
          .start();
    } else {
      mShowingHistoryPanel = false;
      viewList.setVisibility(View.INVISIBLE);
      view.animate().setDuration(200).x(0).withLayer().start();
    }
    invalidateOptionsMenu();
  }
  /** Shows the progress UI and hides the login form */
  private void showProgress(final boolean show) {
    int shortAnimTime = getResources().getInteger(android.R.integer.config_mediumAnimTime);

    mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
    mLoginFormView
        .animate()
        .setDuration(shortAnimTime)
        .alpha(show ? 0 : 1)
        .setListener(
            new AnimatorListenerAdapter() {
              @Override
              public void onAnimationEnd(Animator animation) {
                mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
              }
            });

    mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
    mProgressView
        .animate()
        .setDuration(shortAnimTime)
        .alpha(show ? 1 : 0)
        .setListener(
            new AnimatorListenerAdapter() {
              @Override
              public void onAnimationEnd(Animator animation) {
                mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
              }
            });
  }
Esempio n. 8
0
 /** Dispose of the photo gracefully, in case we can see some of it. */
 public void fadeAway(final View photo, final boolean replace) {
   // fade out of view
   mOnTable.remove(photo);
   exitStageLeft(photo);
   photo.setOnTouchListener(null);
   photo.animate().cancel();
   photo
       .animate()
       .withLayer()
       .alpha(0f)
       .setDuration(mPickUpDuration)
       .withEndAction(
           new Runnable() {
             @Override
             public void run() {
               if (photo == getFocus()) {
                 clearFocus();
               }
               mStageLeft.removeView(photo);
               recycle(photo);
               if (replace) {
                 scheduleNext(mNowDropDelay);
               }
             }
           });
 }
Esempio n. 9
0
 private void prepareAndAnimateView(
     final View v, float initTransX, final boolean notifyAnimationFinished) {
   v.setLayerType(View.LAYER_TYPE_HARDWARE, null);
   v.buildLayer();
   v.setAlpha(0);
   v.setTranslationX(initTransX);
   v.animate()
       .alpha(1f)
       .translationX(0)
       .setDuration(ANIMATE_IN_DURATION)
       .setStartDelay(SECONDARY_ANIMATE_DELAY);
   v.animate().setInterpolator(new DecelerateInterpolator(1.0f));
   v.animate()
       .setListener(
           new AnimatorListenerAdapter() {
             @Override
             public void onAnimationEnd(Animator animation) {
               v.setLayerType(View.LAYER_TYPE_NONE, null);
               if (notifyAnimationFinished) {
                 onIntroAnimationFinished();
               }
             }
           });
   v.animate().start();
 }
  /** Shows the progress UI and hides the search form. */
  @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
  private void showProgress(final boolean show) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
      int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);

      mSearchStatusView.setVisibility(View.VISIBLE);
      mSearchStatusView
          .animate()
          .setDuration(shortAnimTime)
          .alpha(show ? 1 : 0)
          .setListener(
              new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                  mSearchStatusView.setVisibility(show ? View.VISIBLE : View.GONE);
                }
              });

      mSearchFormView.setVisibility(View.VISIBLE);
      mSearchFormView
          .animate()
          .setDuration(shortAnimTime)
          .alpha(show ? 0 : 1)
          .setListener(
              new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                  mSearchFormView.setVisibility(show ? View.GONE : View.VISIBLE);
                }
              });
    } else {
      mSearchStatusView.setVisibility(show ? View.VISIBLE : View.GONE);
      mSearchFormView.setVisibility(show ? View.GONE : View.VISIBLE);
    }
  }
  private void up(MotionEvent motionEvent) {
    if (mPaused || mVelocityTracker == null || mSwipeView == null) {
      return;
    }
    mSwipeView.setPressed(false);
    float deltaX = motionEvent.getRawX() - mDownX;
    mVelocityTracker.addMovement(motionEvent);
    mVelocityTracker.computeCurrentVelocity(1000);
    float velocityX = mVelocityTracker.getXVelocity();
    float absVelocityX = Math.abs(velocityX);
    float absVelocityY = Math.abs(mVelocityTracker.getYVelocity());
    boolean dismiss = false;
    boolean dismissRight = false;
    if (Math.abs(deltaX) > mViewWidth / 2 && mSwiping) {
      dismiss = true;
      dismissRight = deltaX > 0;
    } else if (mMinFlingVelocity <= absVelocityX
        && absVelocityX <= mMaxFlingVelocity
        && absVelocityY < absVelocityX
        && absVelocityY < absVelocityX
        && mSwiping) {
      // dismiss only if flinging in the same direction as dragging
      dismiss = (velocityX < 0) == (deltaX < 0);
      dismissRight = mVelocityTracker.getXVelocity() > 0;
    }
    if (dismiss) {
      // dismiss
      final int pos = mRecyclerView.getChildAdapterPosition(mSwipeView);
      final View swipeViewCopy = mSwipeView;
      final SwipeDirection swipeDirection =
          dismissRight ? SwipeDirection.RIGHT : SwipeDirection.LEFT;
      ++mDismissCount;
      mSwipeView
          .animate()
          .translationX(dismissRight ? mViewWidth : -mViewWidth)
          .alpha(0)
          .setDuration(mAnimationTime);

      // this is instead of unreliable onAnimationEnd callback
      swipeViewCopy.postDelayed(
          () -> {
            performDismiss(swipeViewCopy, pos, swipeDirection);
            swipeViewCopy.setTranslationX(0);
            // swipeViewCopy.setAlpha(1);

          },
          mAnimationTime + 100);

    } else if (mSwiping) {
      // cancel
      mSwipeView.animate().translationX(0).alpha(1).setDuration(mAnimationTime).setListener(null);
    }

    resetMotion();
  }
Esempio n. 12
0
  /** Shows the progress UI and hides the login form. */
  @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
  private void showProgress(final boolean show) {
    // On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
    // for very easy animations. If available, use these APIs to fade-in
    // the progress spinner.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
      int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);

      recipeList.setVisibility(show ? View.GONE : View.VISIBLE);
      recipeList
          .animate()
          .setDuration(shortAnimTime)
          .alpha(show ? 0 : 1)
          .setListener(
              new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                  recipeList.setVisibility(show ? View.GONE : View.VISIBLE);
                }
              });

      textView.setVisibility(show ? View.GONE : View.VISIBLE);
      textView
          .animate()
          .setDuration(shortAnimTime)
          .alpha(show ? 0 : 1)
          .setListener(
              new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                  textView.setVisibility(show ? View.GONE : View.VISIBLE);
                }
              });

      progressView.setVisibility(show ? View.VISIBLE : View.GONE);
      progressView
          .animate()
          .setDuration(shortAnimTime)
          .alpha(show ? 1 : 0)
          .setListener(
              new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                  progressView.setVisibility(show ? View.VISIBLE : View.GONE);
                }
              });
    } else {
      // The ViewPropertyAnimator APIs are not available, so simply show
      // and hide the relevant UI components.
      progressView.setVisibility(show ? View.VISIBLE : View.GONE);
      recipeList.setVisibility(show ? View.GONE : View.VISIBLE);
      textView.setVisibility(show ? View.GONE : View.VISIBLE);
    }
  }
Esempio n. 13
0
  private void showControls() {
    if (mControlsVisible) return;
    mControlsVisible = true;
    int duration = getResources().getInteger(R.integer.animation_controls_showHide);
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
      // Landscape: tab containers slide from left / right
      mConTabsA
          .animate()
          .alpha(1)
          .translationX(0)
          .setInterpolator(new DecelerateInterpolator())
          .setDuration(duration);
      mConTabsB
          .animate()
          .alpha(1)
          .translationX(0)
          .setInterpolator(new DecelerateInterpolator())
          .setDuration(duration);
    } else {
      // Portrait: tab containers slide from top / bottom
      mConTabsA
          .animate()
          .alpha(1)
          .translationY(0)
          .setInterpolator(new DecelerateInterpolator())
          .setDuration(duration);
      mConTabsB
          .animate()
          .alpha(1)
          .translationY(0)
          .setInterpolator(new DecelerateInterpolator())
          .setDuration(duration);
    }

    // 'Compress' the main fragment, to make space for the tab containers
    PointF shrinkPercents = getShrinkPercents();
    mConFragments
        .animate()
        .scaleX(shrinkPercents.x)
        .scaleY(shrinkPercents.y)
        .setInterpolator(new DecelerateInterpolator())
        .setDuration(duration);

    // Record button
    mChkRecord
        .animate()
        .alpha(1)
        .translationY(0)
        .setInterpolator(new DecelerateInterpolator())
        .setDuration(duration);

    mTxtTitle.animate().alpha(0).setDuration(duration).setStartDelay(0);
  }
Esempio n. 14
0
  private void hideControls() {
    mControlsVisible = false;
    int duration = getResources().getInteger(R.integer.animation_controls_showHide);
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
      // Landscape: tab containers slide to left / right
      mConTabsA
          .animate()
          .alpha(0)
          .translationX(-mConTabsA.getWidth())
          .setInterpolator(new AccelerateInterpolator())
          .setDuration(duration);
      mConTabsB
          .animate()
          .alpha(0)
          .translationX(mConTabsB.getWidth())
          .setInterpolator(new AccelerateInterpolator())
          .setDuration(duration);
    } else {
      // Portrait: tab containers slide to top / bottom
      mConTabsA
          .animate()
          .alpha(0)
          .translationY(-mConTabsA.getHeight())
          .setInterpolator(new AccelerateInterpolator())
          .setDuration(duration);
      mConTabsB
          .animate()
          .alpha(0)
          .translationY(mConTabsB.getHeight())
          .setInterpolator(new AccelerateInterpolator())
          .setDuration(duration);
    }

    // 'Uncompress' the main fragment
    mConFragments
        .animate()
        .scaleX(1f)
        .scaleY(1f)
        .setInterpolator(new AccelerateInterpolator())
        .setDuration(duration);

    // Record button
    mChkRecord
        .animate()
        .alpha(0)
        .translationY(-mChkRecord.getHeight())
        .setInterpolator(new AccelerateInterpolator())
        .setDuration(duration);

    // Show the title
    mTxtTitle.animate().alpha(1f).setDuration(duration).setStartDelay(duration);
  }
Esempio n. 15
0
  /** Shows the progress UI and hides the login form. */
  @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
  public void showProgress(final boolean show) {
    // On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
    // for very easy animations. If available, use these APIs to fade-in
    // the progress spinner.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
      int shortAnimTime = getResources().getInteger(android.R.integer.config_longAnimTime);

      mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
      mLoginFormView
          .animate()
          .setDuration(shortAnimTime)
          .alpha(show ? 0 : 1)
          .setListener(
              new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                  mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
                }
              });

      // Create a progressdialog
      mProgressDialog = new ProgressDialog(LoginActivity.this);
      // Set progressdialog title
      mProgressDialog.setTitle("Obteniendo datos");
      // Set progressdialog message
      mProgressDialog.setMessage("Cargando...");
      mProgressDialog.setIndeterminate(false);
      // Show progressdialog
      mProgressDialog.show();
      mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
      mProgressView
          .animate()
          .setDuration(shortAnimTime)
          .alpha(show ? 1 : 0)
          .setListener(
              new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                  mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
                }
              });
    } else {
      // The ViewPropertyAnimator APIs are not available, so simply show
      // and hide the relevant UI components.
      mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
      mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
    }
  }
Esempio n. 16
0
  private void hide(final View view) {
    ViewPropertyAnimator animator =
        view.animate()
            .translationY(view.getHeight())
            .setInterpolator(INTERPOLATOR)
            .setDuration(200);
    animator.setListener(
        new Animator.AnimatorListener() {
          @Override
          public void onAnimationStart(Animator animator) {}

          @Override
          public void onAnimationEnd(Animator animator) {
            view.setVisibility(View.GONE);
          }

          @Override
          public void onAnimationCancel(Animator animator) {
            show(view);
          }

          @Override
          public void onAnimationRepeat(Animator animator) {}
        });
    animator.start();
  }
  @Override
  public void onBackPressed() {

    for (int i = 0; i < rowContainer.getChildCount(); i++) {

      View rowView = rowContainer.getChildAt(i);
      ViewPropertyAnimator propertyAnimator =
          rowView.animate().setStartDelay(i * SCALE_DELAY).scaleX(0).scaleY(0);

      propertyAnimator.setListener(
          new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animator) {}

            @Override
            public void onAnimationEnd(Animator animator) {

              finishAfterTransition();
            }

            @Override
            public void onAnimationCancel(Animator animator) {}

            @Override
            public void onAnimationRepeat(Animator animator) {}
          });
    }
  }
 public static void a(View paramView, fq paramfq) {
   fn localfn = null;
   if (paramfq != null) {
     localfn = new fn(paramfq, paramView);
   }
   paramView.animate().setUpdateListener(localfn);
 }
  private void updateStep() {
    if (stepIndex >= steps.size()) {
      hideSoftInput();

      View finishedView = onCreateFinishedView(getLayoutInflater(), container);
      if (finishedView != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
          finishedView.setAlpha(0);
          finishedView.setVisibility(View.VISIBLE);
          container.addView(finishedView);
          finishedView
              .animate()
              .alpha(1)
              .setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime));
        } else {
          finishedView.setVisibility(View.VISIBLE);
          container.addView(finishedView);
        }
      }

      onFormFinished(setupData);
      return;
    }
    updateViews();
    containerScrollView.smoothScrollTo(0, 0);
  }
  @Subscribe
  public void onMessageSent(Messages.SendMessageResponse response) {
    if (!response.didSucceed()) {
      response.showErrorToast(this);
      messageEditText.setError(response.getPropertyError("message"));
      progressFrame
          .animate()
          .alpha(0)
          .setDuration(200)
          .withEndAction(
              new Runnable() {
                @Override
                public void run() {
                  progressFrame.setVisibility(View.GONE);
                }
              })
          .start();
      return;
    }
    response.message.setIsFromUs(true);
    Intent data = new Intent();
    data.putExtra(RESULT_MESSAGE, response.message);
    Log.d("myLogs", "response.message ID == " + response.message.getId());

    setResult(RESULT_OK, data);
    finish();
  }
  private void makeJump(final View view) {
    final int jumpHeight = getResources().getDimensionPixelOffset(R.dimen.jump_height);
    final int jumpDuration = 400;

    view.animate()
        .translationZ(jumpHeight)
        .setDuration(jumpDuration)
        .setInterpolator(new AccelerateDecelerateInterpolator())
        .setListener(
            new Animator.AnimatorListener() {

              @Override
              public void onAnimationEnd(Animator animator) {
                view.animate()
                    .translationZ(0)
                    .setDuration(jumpDuration)
                    .setInterpolator(new AccelerateDecelerateInterpolator());
              }

              @Override
              public void onAnimationStart(Animator animator) {}

              @Override
              public void onAnimationCancel(Animator animator) {}

              @Override
              public void onAnimationRepeat(Animator animator) {}
            });
  }
Esempio n. 22
0
  private void animateInIconOfFirstTask() {
    if (mItemToAnimateInWhenWindowAnimationIsFinished != null
        && !mRecentTasksLoader.isFirstScreenful()) {
      int timeSinceWindowAnimation = (int) (System.currentTimeMillis() - mWindowAnimationStartTime);
      final int minStartDelay = 150;
      final int startDelay =
          Math.max(0, Math.min(minStartDelay - timeSinceWindowAnimation, minStartDelay));
      final int duration = 250;
      final ViewHolder holder = mItemToAnimateInWhenWindowAnimationIsFinished;
      final TimeInterpolator cubic = new DecelerateInterpolator(1.5f);
      for (View v :
          new View[] {
            holder.iconView, /* holder.labelView */ /*
																			 * ,
																			 * holder
																			 * .
																			 * calloutLine
																			 */
          }) {
        if (v != null) {
          v.animate()
              .translationX(0)
              .translationY(0)
              .alpha(1f)
              .setStartDelay(startDelay)
              .setDuration(duration)
              .setInterpolator(cubic);
        }
      }
      mItemToAnimateInWhenWindowAnimationIsFinished = null;
      mAnimateIconOfFirstTask = false;
    }
  }
Esempio n. 23
0
  /** Continue dynamically after a fling gesture, possibly off the screen. */
  public void fling(final View photo, float dx, float dy, int duration, boolean spin) {
    if (photo == getFocus()) {
      if (moveFocus(photo, 0f) == null) {
        moveFocus(photo, 180f);
      }
    }
    moveToForeground(photo);
    ViewPropertyAnimator animator =
        photo
            .animate()
            .withLayer()
            .xBy(dx)
            .yBy(dy)
            .setDuration(duration)
            .setInterpolator(new DecelerateInterpolator(2f));

    if (spin) {
      animator.rotation(mThrowRotation);
    }

    if (photoOffTable(photo, (int) dx, (int) dy)) {
      log("fling away");
      animator.withEndAction(
          new Runnable() {
            @Override
            public void run() {
              fadeAway(photo, true);
            }
          });
    }
  }
Esempio n. 24
0
 /** Move in response to touch. */
 public void move(final View photo, float x, float y, float a) {
   photo.animate().cancel();
   photo.setAlpha(1f);
   photo.setX((int) x);
   photo.setY((int) y);
   photo.setRotation((int) a);
 }
Esempio n. 25
0
  /** On deck is to the left or right of the selected photo. */
  private void placeOnDeck(final View photo, final int slot) {
    if (slot < mOnDeck.length) {
      if (mOnDeck[slot] != null && mOnDeck[slot] != photo) {
        fadeAway(mOnDeck[slot], false);
      }
      mOnDeck[slot] = photo;
      float photoWidth = photo.getWidth();
      float photoHeight = photo.getHeight();
      float scale = Math.min(getHeight() / photoHeight, getWidth() / photoWidth);

      float x = (getWidth() - photoWidth) / 2f;
      float y = (getHeight() - photoHeight) / 2f;

      float offset = (((float) mWidth + scale * (photoWidth - 2f * mInset)) / 2f);
      x += (slot == NEXT ? 1f : -1f) * offset;

      photo
          .animate()
          .withLayer()
          .rotation(0f)
          .rotationY(0f)
          .scaleX(scale)
          .scaleY(scale)
          .x(x)
          .y(y)
          .setDuration(mPickUpDuration)
          .setInterpolator(new DecelerateInterpolator(2f));
    }
  }
Esempio n. 26
0
 /** Return the other photos to foreground status. */
 public void fadeInBackground(final View photo) {
   if (mBackgroudOptimization) {
     mWaitingToJoinBackground.add(photo);
     mBackground
         .animate()
         .withLayer()
         .setDuration(mPickUpDuration)
         .alpha(1f)
         .withEndAction(
             new Runnable() {
               @Override
               public void run() {
                 resolveBackgroundQueue();
               }
             });
   } else {
     bringChildToFront(mScrim);
     bringChildToFront(photo);
     mScrim
         .animate()
         .withLayer()
         .setDuration(mPickUpDuration)
         .alpha(0f)
         .withEndAction(
             new Runnable() {
               @Override
               public void run() {
                 mScrim.setVisibility(View.GONE);
               }
             });
   }
 }
  /** Animates this task view as it exits recents */
  void startLaunchTaskAnimation(
      final Runnable postAnimRunnable,
      boolean isLaunchingTask,
      boolean occludesLaunchTarget,
      boolean lockToTask) {
    if (isLaunchingTask) {
      // Animate the thumbnail alpha back into full opacity for the window animation out
      mThumbnailView.startLaunchTaskAnimation(postAnimRunnable);

      // Animate the dim
      if (mDimAlpha > 0) {
        ObjectAnimator anim = ObjectAnimator.ofInt(this, "dim", 0);
        anim.setDuration(mConfig.taskViewExitToAppDuration);
        anim.setInterpolator(mConfig.fastOutLinearInInterpolator);
        anim.start();
      }

      // Animate the action button away
      if (!lockToTask) {
        float toScale = 0.9f;
        mActionButtonView.animate().scaleX(toScale).scaleY(toScale);
      }
      mActionButtonView
          .animate()
          .alpha(0f)
          .setStartDelay(0)
          .setDuration(mConfig.taskViewExitToAppDuration)
          .setInterpolator(mConfig.fastOutLinearInInterpolator)
          .withLayer()
          .start();
    } else {
      // Hide the dismiss button
      mHeaderView.startLaunchTaskDismissAnimation();
      // If this is another view in the task grouping and is in front of the launch task,
      // animate it away first
      if (occludesLaunchTarget) {
        animate()
            .alpha(0f)
            .translationY(getTranslationY() + mConfig.taskViewAffiliateGroupEnterOffsetPx)
            .setStartDelay(0)
            .setUpdateListener(null)
            .setInterpolator(mConfig.fastOutLinearInInterpolator)
            .setDuration(mConfig.taskViewExitToAppDuration)
            .start();
      }
    }
  }
  private void bindViews() {
    if (mRootView == null) {
      return;
    }

    TextView titleView = (TextView) mRootView.findViewById(R.id.article_title);
    TextView bylineView = (TextView) mRootView.findViewById(R.id.article_byline);
    bylineView.setMovementMethod(new LinkMovementMethod());
    TextView bodyView = (TextView) mRootView.findViewById(R.id.article_body);
    bodyView.setTypeface(
        Typeface.createFromAsset(getResources().getAssets(), "Rosario-Regular.ttf"));

    if (mCursor != null) {
      mRootView.setAlpha(0);
      mRootView.setVisibility(View.VISIBLE);
      mRootView.animate().alpha(1);
      titleView.setText(mCursor.getString(ArticleLoader.Query.TITLE));
      bylineView.setText(
          Html.fromHtml(
              DateUtils.getRelativeTimeSpanString(
                          mCursor.getLong(ArticleLoader.Query.PUBLISHED_DATE),
                          System.currentTimeMillis(),
                          DateUtils.HOUR_IN_MILLIS,
                          DateUtils.FORMAT_ABBREV_ALL)
                      .toString()
                  + " by <font color='#ffffff'>"
                  + mCursor.getString(ArticleLoader.Query.AUTHOR)
                  + "</font>"));
      bodyView.setText(Html.fromHtml(mCursor.getString(ArticleLoader.Query.BODY)));
      ImageLoaderHelper.getInstance(getActivity())
          .getImageLoader()
          .get(
              mCursor.getString(ArticleLoader.Query.PHOTO_URL),
              new ImageLoader.ImageListener() {
                @Override
                public void onResponse(ImageLoader.ImageContainer imageContainer, boolean b) {
                  Bitmap bitmap = imageContainer.getBitmap();
                  if (bitmap != null) {
                    Palette p = Palette.generate(bitmap, 12);
                    mMutedColor = p.getDarkMutedColor(0xFF333333);
                    mPhotoView.setImageBitmap(imageContainer.getBitmap());
                    mRootView.findViewById(R.id.meta_bar).setBackgroundColor(mMutedColor);
                    updateStatusBar();
                  }
                }

                @Override
                public void onErrorResponse(VolleyError volleyError) {}
              });
    } else {
      mRootView.setVisibility(View.GONE);
      titleView.setText("N/A");
      bylineView.setText("N/A");
      bodyView.setText("N/A");
    }

    //        if (collapsingToolbar != null)
    //            collapsingToolbar.setTitle("");
  }
  @Override
  public void dismiss() {
    Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_out_bottom);
    animation.setAnimationListener(mAnimListener);
    mContainer.startAnimation(animation);

    mOverlayView.animate().alpha(0f);
  }
  private void applyLightsOut(boolean lightsOut, boolean animate, boolean force) {
    if (!force && lightsOut == mLightsOut) return;

    mLightsOut = lightsOut;

    final View navButtons = mView.getCurrentView().findViewById(R.id.nav_buttons);
    final View lowLights = mView.getCurrentView().findViewById(R.id.lights_out);

    // ok, everyone, stop it right there
    navButtons.animate().cancel();
    lowLights.animate().cancel();

    final float navButtonsAlpha = lightsOut ? 0f : 1f;
    final float lowLightsAlpha = lightsOut ? 1f : 0f;

    if (!animate) {
      navButtons.setAlpha(navButtonsAlpha);
      lowLights.setAlpha(lowLightsAlpha);
      lowLights.setVisibility(lightsOut ? View.VISIBLE : View.GONE);
    } else {
      final int duration = lightsOut ? LIGHTS_OUT_DURATION : LIGHTS_IN_DURATION;
      navButtons.animate().alpha(navButtonsAlpha).setDuration(duration).start();

      lowLights.setOnTouchListener(mLightsOutListener);
      if (lowLights.getVisibility() == View.GONE) {
        lowLights.setAlpha(0f);
        lowLights.setVisibility(View.VISIBLE);
      }
      lowLights
          .animate()
          .alpha(lowLightsAlpha)
          .setDuration(duration)
          .setInterpolator(new AccelerateInterpolator(2.0f))
          .setListener(
              lightsOut
                  ? null
                  : new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator _a) {
                      lowLights.setVisibility(View.GONE);
                    }
                  })
          .start();
    }
  }