예제 #1
0
  // 动画开启
  private void startLogin() {
    Animation loAnimRotate = AnimationUtils.loadAnimation(this, R.anim.rotate);
    Animation loAnimScale = AnimationUtils.loadAnimation(this, R.anim.login_photo_scale_small);
    // 匀速动画
    LinearInterpolator linearInterpolator = new LinearInterpolator();
    // 加速动画
    // AccelerateInterpolator accelerateInterpolator = new
    // AccelerateInterpolator();
    // 弹跳动画
    // BounceInterpolator bounceInterpolator = new BounceInterpolator();

    loAnimRotate.setInterpolator(linearInterpolator);
    loAnimScale.setInterpolator(linearInterpolator);
    moImgProgress.setVisibility(View.VISIBLE);
    moImgProgress.startAnimation(loAnimRotate);
    moImgPhoto.startAnimation(loAnimScale);

    moImgSlider.setVisibility(View.GONE);
    moViewSlideLine.setVisibility(View.GONE);
    moEditUsername.setVisibility(View.GONE);
    moEditPassword.setVisibility(View.GONE);
    moBtnClearUsername.setVisibility(View.GONE);
    moBtnClearPassword.setVisibility(View.GONE);
    // moBtnRegister.setVisibility(View.GONE);
    moBtnTraveller.setVisibility(View.GONE);

    moLayoutWelcome.setVisibility(View.VISIBLE);
  }
 @Override
 public void run() {
   mReturningToStart = true;
   // Timeout fired since the user last moved their finger; animate the
   // trigger to 0 and put the target back at its original position
   if (mProgressBar != null || mProgressBarBottom != null) {
     mFromPercentage = mCurrPercentage;
     if (mDirection > 0 && ((mMode == Mode.PULL_FROM_START) || (mMode == Mode.BOTH))) {
       mShrinkTrigger.setDuration(mMediumAnimationDuration);
       mShrinkTrigger.setAnimationListener(mShrinkAnimationListener);
       mShrinkTrigger.reset();
       mShrinkTrigger.setInterpolator(mDecelerateInterpolator);
       startAnimation(mShrinkTrigger);
     } else if (mDirection < 0 && ((mMode == Mode.PULL_FROM_END) || (mMode == Mode.BOTH))) {
       mShrinkTriggerBottom.setDuration(mMediumAnimationDuration);
       mShrinkTriggerBottom.setAnimationListener(mShrinkAnimationListener);
       mShrinkTriggerBottom.reset();
       mShrinkTriggerBottom.setInterpolator(mDecelerateInterpolator);
       startAnimation(mShrinkTriggerBottom);
     }
   }
   mDirection = 0;
   animateOffsetToStartPosition(
       mCurrentTargetOffsetTop + getPaddingTop(), mReturnToStartPositionListener);
 }
예제 #3
0
  private void init(Context context, View target, int tabIndex) {

    this.context = context;
    this.target = target;
    this.targetTabIndex = tabIndex;

    // apply defaults
    badgePosition = DEFAULT_POSITION;
    badgeMarginH = dipToPixels(DEFAULT_MARGIN_DIP);
    badgeMarginV = badgeMarginH;
    badgeColor = DEFAULT_BADGE_COLOR;

    setTypeface(Typeface.DEFAULT_BOLD);
    int paddingPixels = dipToPixels(DEFAULT_LR_PADDING_DIP);
    setPadding(paddingPixels, 0, paddingPixels, 0);
    setTextColor(DEFAULT_TEXT_COLOR);

    fadeIn = new AlphaAnimation(0, 1);
    fadeIn.setInterpolator(new DecelerateInterpolator());
    fadeIn.setDuration(200);

    fadeOut = new AlphaAnimation(1, 0);
    fadeOut.setInterpolator(new AccelerateInterpolator());
    fadeOut.setDuration(200);

    isShown = false;

    if (this.target != null) {
      applyTo(this.target);
    } else {
      show();
    }
  }
  private void moveLeft(cgCacheView holder, cgCache cache, boolean force) {
    if (cache == null) {
      return;
    }

    holder.checkbox.setChecked(cache.isStatusChecked());

    // slide cache info
    final Animation hideCheckbox =
        new TranslateAnimation((int) (SWIPE_DISTANCE * pixelDensity), 0, 0, 0);
    hideCheckbox.setRepeatCount(0);
    hideCheckbox.setDuration(force ? 0 : 400);
    hideCheckbox.setFillEnabled(true);
    hideCheckbox.setFillAfter(true);
    hideCheckbox.setInterpolator(new AccelerateDecelerateInterpolator());

    // brighten cache info
    final Animation brightenInfo = new AlphaAnimation(SWIPE_OPACITY, 1.0f);
    brightenInfo.setRepeatCount(0);
    brightenInfo.setDuration(force ? 0 : 400);
    brightenInfo.setFillEnabled(true);
    brightenInfo.setFillAfter(true);
    brightenInfo.setInterpolator(new AccelerateDecelerateInterpolator());

    // animation set (container)
    final AnimationSet selectAnimation = new AnimationSet(true);
    selectAnimation.setFillEnabled(true);
    selectAnimation.setFillAfter(true);

    selectAnimation.addAnimation(hideCheckbox);
    selectAnimation.addAnimation(brightenInfo);

    holder.oneInfo.startAnimation(selectAnimation);
    cache.setStatusCheckedView(false);
  }
 private void initAnimation() {
   mAnimationHide = new AlphaAnimation(1.0f, 0.0f);
   mAnimationHide.setInterpolator(new DecelerateInterpolator());
   mAnimationHide.setDuration(200);
   mAnimationShow = new AlphaAnimation(0.0f, 1.0f);
   mAnimationShow.setInterpolator(new AccelerateInterpolator());
   mAnimationShow.setDuration(600);
 }
예제 #6
0
  private Animation createScaleUpAnimationLocked(
      int transit, boolean enter, int appWidth, int appHeight) {
    Animation a = null;
    if (enter) {
      // Entering app zooms out from the center of the initial rect.
      float scaleW = mNextAppTransitionStartWidth / (float) appWidth;
      float scaleH = mNextAppTransitionStartHeight / (float) appHeight;
      Animation scale =
          new ScaleAnimation(
              scaleW,
              1,
              scaleH,
              1,
              computePivot(mNextAppTransitionStartX, scaleW),
              computePivot(mNextAppTransitionStartY, scaleH));
      scale.setInterpolator(mDecelerateInterpolator);

      Animation alpha = new AlphaAnimation(0, 1);
      alpha.setInterpolator(mThumbnailFadeOutInterpolator);

      AnimationSet set = new AnimationSet(false);
      set.addAnimation(scale);
      set.addAnimation(alpha);
      set.setDetachWallpaper(true);
      a = set;
    } else if (transit == TRANSIT_WALLPAPER_INTRA_OPEN
        || transit == TRANSIT_WALLPAPER_INTRA_CLOSE) {
      // If we are on top of the wallpaper, we need an animation that
      // correctly handles the wallpaper staying static behind all of
      // the animated elements.  To do this, will just have the existing
      // element fade out.
      a = new AlphaAnimation(1, 0);
      a.setDetachWallpaper(true);
    } else {
      // For normal animations, the exiting element just holds in place.
      a = new AlphaAnimation(1, 1);
    }

    // Pick the desired duration.  If this is an inter-activity transition,
    // it  is the standard duration for that.  Otherwise we use the longer
    // task transition duration.
    final long duration;
    switch (transit) {
      case TRANSIT_ACTIVITY_OPEN:
      case TRANSIT_ACTIVITY_CLOSE:
        duration = mConfigShortAnimTime;
        break;
      default:
        duration = DEFAULT_APP_TRANSITION_DURATION;
        break;
    }
    a.setDuration(duration);
    a.setFillAfter(true);
    a.setInterpolator(mDecelerateInterpolator);
    a.initialize(appWidth, appHeight, appWidth, appHeight);
    return a;
  }
예제 #7
0
  /**
   * Create a pair of {@link FlipAnimation} that can be used to flip 3D transition from {@code
   * fromView} to {@code toView}. A typical use case is with {@link ViewAnimator} as an out and in
   * transition.
   *
   * <p>NOTE: Avoid using this method. Instead, use {@link #flipTransition}.
   *
   * @param fromView the view transition away from
   * @param toView the view transition to
   * @param dir the flip direction
   * @param duration the transition duration in milliseconds
   * @param interpolator the interpolator to use (pass {@code null} to use the {@link
   *     AccelerateInterpolator} interpolator)
   * @return
   */
  public static Animation[] flipAnimation(
      final View fromView,
      final View toView,
      FlipDirection dir,
      long duration,
      Interpolator interpolator) {
    Animation[] result = new Animation[2];
    float centerX;
    float centerY;

    centerX = fromView.getWidth() / 2.0f;
    centerY = fromView.getHeight() / 2.0f;

    Animation outFlip =
        new FlipAnimation(
            dir.getStartDegreeForFirstView(),
            dir.getEndDegreeForFirstView(),
            centerX,
            centerY,
            FlipAnimation.SCALE_DEFAULT,
            FlipAnimation.ScaleUpDownEnum.SCALE_DOWN);
    outFlip.setDuration(duration);
    outFlip.setFillAfter(true);
    outFlip.setInterpolator(interpolator == null ? new AccelerateInterpolator() : interpolator);

    AnimationSet outAnimation = new AnimationSet(true);
    outAnimation.addAnimation(outFlip);
    result[0] = outAnimation;

    // Uncomment the following if toView has its layout established (not the case if using
    // ViewFlipper and on first show)
    // centerX = toView.getWidth() / 2.0f;
    // centerY = toView.getHeight() / 2.0f;

    Animation inFlip =
        new FlipAnimation(
            dir.getStartDegreeForSecondView(),
            dir.getEndDegreeForSecondView(),
            centerX,
            centerY,
            FlipAnimation.SCALE_DEFAULT,
            FlipAnimation.ScaleUpDownEnum.SCALE_UP);
    inFlip.setDuration(duration);
    inFlip.setFillAfter(true);
    inFlip.setInterpolator(interpolator == null ? new AccelerateInterpolator() : interpolator);
    inFlip.setStartOffset(duration);

    AnimationSet inAnimation = new AnimationSet(true);
    inAnimation.addAnimation(inFlip);
    result[1] = inAnimation;

    return result;
  }
예제 #8
0
  public IndicatorLayout(Context context, PullToRefreshBase.Mode mode) {
    super(context);
    mArrowImageView = new ImageView(context);

    Drawable arrowD = getResources().getDrawable(R.drawable.indicator_arrow);
    mArrowImageView.setImageDrawable(arrowD);

    final int padding = getResources().getDimensionPixelSize(R.dimen.indicator_internal_padding);
    mArrowImageView.setPadding(padding, padding, padding, padding);
    addView(mArrowImageView);

    int inAnimResId, outAnimResId;
    switch (mode) {
      case PULL_FROM_END:
        inAnimResId = R.anim.slide_in_from_bottom;
        outAnimResId = R.anim.slide_out_to_bottom;
        setBackgroundResource(R.drawable.indicator_bg_bottom);

        // Rotate Arrow so it's pointing the correct way
        mArrowImageView.setScaleType(ScaleType.MATRIX);
        Matrix matrix = new Matrix();
        matrix.setRotate(180f, arrowD.getIntrinsicWidth() / 2f, arrowD.getIntrinsicHeight() / 2f);
        mArrowImageView.setImageMatrix(matrix);
        break;
      default:
      case PULL_FROM_START:
        inAnimResId = R.anim.slide_in_from_top;
        outAnimResId = R.anim.slide_out_to_top;
        setBackgroundResource(R.drawable.indicator_bg_top);
        break;
    }

    mInAnim = AnimationUtils.loadAnimation(context, inAnimResId);
    mInAnim.setAnimationListener(this);

    mOutAnim = AnimationUtils.loadAnimation(context, outAnimResId);
    mOutAnim.setAnimationListener(this);

    final Interpolator interpolator = new LinearInterpolator();
    mRotateAnimation =
        new RotateAnimation(
            0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    mRotateAnimation.setInterpolator(interpolator);
    mRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
    mRotateAnimation.setFillAfter(true);

    mResetRotateAnimation =
        new RotateAnimation(
            -180, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    mResetRotateAnimation.setInterpolator(interpolator);
    mResetRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
    mResetRotateAnimation.setFillAfter(true);
  }
  /**
   * The function responsible for fade-in fade-out effect
   *
   * @imageView <-- The View which displays the images
   * @images[] <-- Holds R references to the images to display
   * @imageIndex <-- index of the first image to show in images[]
   * @forever <-- If equals true then after the last image it starts all over again with the first
   *     image resulting in an infinite loop. You have been warned.
   */
  private void animate(
      final ImageView imageView, final int images[], final int imageIndex, final boolean forever) {

    int fadeInDuration = 800; // Configure time values here
    int timeBetween = 200;
    int fadeOutDuration = 400;

    // imageView.setVisibility(View.INVISIBLE);    //Visible or invisible by default - this will
    // apply when the animation ends
    imageView.setImageResource(images[imageIndex]);

    Animation fadeIn = new AlphaAnimation((float) 0.1, (float) 1.0);
    fadeIn.setInterpolator(new DecelerateInterpolator()); // add this
    fadeIn.setDuration(fadeInDuration);
    Animation fadeOut = new AlphaAnimation((float) 1.0, (float) 1.0);
    fadeOut.setInterpolator(new AccelerateInterpolator()); // and this
    fadeOut.setStartOffset(fadeInDuration + timeBetween);
    fadeOut.setDuration(fadeOutDuration);

    AnimationSet animation = new AnimationSet(false); // change to false
    animation.addAnimation(fadeIn);
    animation.addAnimation(fadeOut);
    animation.setRepeatCount(1);
    imageView.setAnimation(animation);

    animation.setAnimationListener(
        new Animation.AnimationListener() {
          public void onAnimationEnd(Animation animation) {
            if (images.length - 1 > imageIndex) {
              animate(
                  imageView,
                  images,
                  imageIndex + 1,
                  forever); // Calls itself until it gets to the end of the array
            } else {
              if (forever == true) {
                animate(
                    imageView, images, 0,
                    forever); // Calls itself to start the animation all over again in a loop if
                // forever = true
              }
            }
          }

          public void onAnimationRepeat(Animation animation) {
            // TODO Auto-generated method stub
          }

          public void onAnimationStart(Animation animation) {
            // TODO Auto-generated method stub
          }
        });
  }
  private void setupText1Marquee() {
    final int duration = (int) (mText1Difference * MS_PER_PX);

    mMoveText1TextOut = new TranslateAnimation(0, -mText1Difference, 0, 0);
    mMoveText1TextOut.setDuration(duration);
    mMoveText1TextOut.setInterpolator(new LinearInterpolator());
    mMoveText1TextOut.setFillAfter(true);

    mMoveText1TextIn = new TranslateAnimation(-mText1Difference, 0, 0, 0);
    mMoveText1TextIn.setDuration(duration);
    mMoveText1TextIn.setStartOffset(PAUSE_BETWEEN_ANIMATIONS);
    mMoveText1TextIn.setInterpolator(new LinearInterpolator());
    mMoveText1TextIn.setFillAfter(true);

    mMoveText1TextOut.setAnimationListener(
        new Animation.AnimationListener() {
          public void onAnimationStart(Animation animation) {
            //                mMoveText1TextOutPlaying = true;
            expandTextView(mTextField1);
          }

          public void onAnimationEnd(Animation animation) {
            //                mMoveText1TextOutPlaying = false;

            if (mCancelled) {
              return;
            }

            mTextField1.startAnimation(mMoveText1TextIn);
          }

          public void onAnimationRepeat(Animation animation) {}
        });

    mMoveText1TextIn.setAnimationListener(
        new Animation.AnimationListener() {
          public void onAnimationStart(Animation animation) {}

          public void onAnimationEnd(Animation animation) {

            cutTextView(mTextField1);

            if (mCancelled) {
              return;
            }
            startTextField1Animation();
          }

          public void onAnimationRepeat(Animation animation) {}
        });
  }
예제 #11
0
  private void initAnim() {

    long duration = 300;
    long durationS = 160;
    float alpha = 0.3f;
    AccelerateInterpolator accInterpolator = new AccelerateInterpolator();

    tab_left = new TranslateAnimation(tabW, 0, 0, 0);
    tab_right = new TranslateAnimation(0, tabW, 0, 0);
    tab_alpha_1 = new AlphaAnimation(1.0f, alpha);
    tab_alpha_2 = new AlphaAnimation(alpha, 1.0f);
    pop_in =
        new ScaleAnimation(
            0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0);
    pop_out =
        new ScaleAnimation(
            1, 0, 1, 0, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0);

    pop_in.setDuration(durationS);
    pop_in.setInterpolator(accInterpolator);
    pop_in.setAnimationListener(new PopListener(popView, PopListener.TYPE_IN));

    pop_out.setDuration(durationS);
    pop_out.setInterpolator(accInterpolator);
    pop_out.setAnimationListener(new PopListener(popView, PopListener.TYPE_OUT));

    tab_left.setFillAfter(true);
    tab_left.setFillEnabled(true);
    tab_left.setDuration(duration);
    tab_left.setInterpolator(accInterpolator);

    tab_right.setFillAfter(true);
    tab_right.setFillEnabled(true);
    tab_right.setDuration(duration);
    tab_right.setInterpolator(accInterpolator);

    tab_alpha_1.setFillAfter(true);
    tab_alpha_1.setFillEnabled(true);
    tab_alpha_1.setDuration(duration);
    tab_alpha_1.setInterpolator(accInterpolator);

    tab_alpha_2.setFillAfter(true);
    tab_alpha_2.setFillEnabled(true);
    tab_alpha_2.setDuration(duration);
    tab_alpha_2.setInterpolator(accInterpolator);

    AlphaAnimation alphaInit = new AlphaAnimation(alpha, alpha);
    alphaInit.setFillAfter(true);
    alphaInit.setFillEnabled(true);
    tv_tab_box.startAnimation(alphaInit);
  }
  /**
   * Code from http://stackoverflow.com/a/10471479/3399351
   *
   * <p>Cycles through an array of images in one ImageView, sequentially fading them out and fading
   * the new photo in.
   *
   * @param imageView ImageView : The View which displays the images
   * @param images int[] : Holds R references to the images to display
   * @param imageIndex int : index of the first image to show in images[]
   * @param forever boolean : If equals true than it loops back to the first image
   */
  public static void animate(
      final ImageView imageView, final int images[], final int imageIndex, final boolean forever) {
    // TODO: Smooth fade between images instead of fade through white
    int fadeInDuration = 500; // Configure time values here
    int timeBetween = 5000;
    int fadeOutDuration = 1000;

    imageView.setVisibility(View.VISIBLE);
    // Visible or invisible by default - this will apply when the animation ends
    imageView.setImageResource(images[imageIndex]);

    // Initialize the fade in animation
    Animation fadeIn = new AlphaAnimation(0, 1);
    fadeIn.setInterpolator(new DecelerateInterpolator());
    fadeIn.setDuration(fadeInDuration);

    // Initialize the fade out animation
    Animation fadeOut = new AlphaAnimation(1, 0);
    fadeOut.setInterpolator(new AccelerateInterpolator());
    fadeOut.setStartOffset(fadeInDuration + timeBetween);
    fadeOut.setDuration(fadeOutDuration);

    // Apply the animation set
    AnimationSet animation = new AnimationSet(false);
    animation.addAnimation(fadeIn);
    animation.addAnimation(fadeOut);
    animation.setRepeatCount(1);
    imageView.setAnimation(animation);

    // Overriding this function causes the animations to loop
    animation.setAnimationListener(
        new Animation.AnimationListener() {
          public void onAnimationEnd(Animation animation) {
            if (images.length - 1 > imageIndex) {
              animate(imageView, images, imageIndex + 1, forever);
              // Calls itself until it gets to the end of the array
              if (forever) {
                animate(imageView, images, 0, forever);
                // Calls itself to start the animation
                // all over again in a loop, if forever = true
              }
            }
          }

          public void onAnimationRepeat(Animation animation) {}

          public void onAnimationStart(Animation animation) {}
        });
  }
  /**
   * Constructor
   *
   * @param anchor {@link View} on where the popup should be displayed
   */
  public QuickAction(View anchor) {
    super(anchor);

    actionList = new ArrayList<ActionItem>();
    context = anchor.getContext();
    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    root = (ViewGroup) inflater.inflate(R.layout.quickaction, null);

    mArrowDown = (ImageView) root.findViewById(R.id.arrow_down);
    mArrowUp = (ImageView) root.findViewById(R.id.arrow_up);

    setContentView(root);

    mTrackAnim = AnimationUtils.loadAnimation(anchor.getContext(), R.anim.rail);

    mTrackAnim.setInterpolator(
        new Interpolator() {
          public float getInterpolation(float t) {
            // Pushes past the target area, then snaps back into place.
            // Equation for graphing: 1.2-((x*1.6)-1.1)^2
            final float inner = (t * 1.55f) - 1.1f;

            return 1.2f - inner * inner;
          }
        });

    mTrack = (ViewGroup) root.findViewById(R.id.tracks);
    animStyle = ANIM_AUTO;
    animateTrack = true;
  }
예제 #14
0
 // Same animation that FloatingActionButton.Behavior uses to show the FAB when the AppBarLayout
 // enters
 private void animateIn(FloatingActionButton button) {
   button.setVisibility(View.VISIBLE);
   Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.abc_slide_in_bottom);
   anim.setDuration(600L);
   anim.setInterpolator(INTERPOLATOR);
   button.startAnimation(anim);
 }
예제 #15
0
 public void onClick(View v) {
   Animation anim = null;
   anim = new RotateAnimation(0.0f, +360.0f);
   anim.setInterpolator(new AccelerateDecelerateInterpolator());
   anim.setDuration(3000);
   findViewById(R.id.TextView01).startAnimation(anim);
 }
예제 #16
0
  private void showZoomedView() {
    // no animation if the zoomed view is already visible
    if (getVisibility() != View.VISIBLE) {
      final Animation anim =
          new ScaleAnimation(
              0f,
              1f, // Start and end values for the X axis scaling
              0f,
              1f, // Start and end values for the Y axis scaling
              Animation.ABSOLUTE,
              animationStart.x, // Pivot point of X scaling
              Animation.ABSOLUTE,
              animationStart.y); // Pivot point of Y scaling
      anim.setFillAfter(true); // Needed to keep the result of the animation
      anim.setDuration(OPENING_ANIMATION_DURATION_MS);
      anim.setInterpolator(new OvershootInterpolator(OVERSHOOT_INTERPOLATOR_TENSION));
      anim.setAnimationListener(
          new AnimationListener() {
            public void onAnimationEnd(Animation animation) {
              setListeners();
            }

            public void onAnimationRepeat(Animation animation) {}

            public void onAnimationStart(Animation animation) {
              removeListeners();
            }
          });
      setAnimation(anim);
    }
    setVisibility(View.VISIBLE);
    shouldSetVisibleOnUpdate = false;
  }
예제 #17
0
  /**
   * 初始化
   *
   * @param context context
   */
  private void init(Context context) {
    mHeaderContainer = (RelativeLayout) findViewById(R.id.pull_to_refresh_header_content);
    mArrowImageView = (ImageView) findViewById(R.id.pull_to_refresh_header_arrow);
    mHintTextView = (TextView) findViewById(R.id.pull_to_refresh_header_hint_textview);
    mHeaderTimeView = (TextView) findViewById(R.id.pull_to_refresh_header_time);
    mHeaderTimeViewTitle = (TextView) findViewById(R.id.pull_to_refresh_last_update_time_text);

    mArrowImageView.setScaleType(ScaleType.CENTER);
    mArrowImageView.setImageResource(R.drawable.default_ptr_rotate);

    float pivotValue = 0.5f; // SUPPRESS CHECKSTYLE
    float toDegree = 720.0f; // SUPPRESS CHECKSTYLE
    mRotateAnimation =
        new RotateAnimation(
            0.0f,
            toDegree,
            Animation.RELATIVE_TO_SELF,
            pivotValue,
            Animation.RELATIVE_TO_SELF,
            pivotValue);
    mRotateAnimation.setFillAfter(true);
    mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
    mRotateAnimation.setDuration(ROTATION_ANIMATION_DURATION);
    mRotateAnimation.setRepeatCount(Animation.INFINITE);
    mRotateAnimation.setRepeatMode(Animation.RESTART);
  }
 @Override
 public Animation onCreateAnimation(int transit, final boolean enter, int nextAnim) {
   Animation animation;
   if (enter) {
     animation = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_up);
     animation.setInterpolator(new OvershootInterpolator(0.5f));
     animation.setDuration(350);
     presenter.onOpenAnimation(animation.getDuration());
   } else {
     animation = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_down);
     animation.setInterpolator(new LinearInterpolator());
     animation.setDuration(200);
     presenter.onExitAnimation(animation.getDuration());
   }
   return animation;
 }
예제 #19
0
        @Override
        public void onClick(View v) {
          if (refreshing) return;
          Animation operatingAnim =
              AnimationUtils.loadAnimation(getActivity(), R.anim.refresh_route);
          LinearInterpolator lin = new LinearInterpolator();
          operatingAnim.setInterpolator(lin);
          if (operatingAnim != null) {
            v.startAnimation(operatingAnim);
          }

          swipeRefreshLayout.setRefreshing(true);

          mListView.post(
              new Runnable() {
                @Override
                public void run() {
                  mListView.smoothScrollToPosition(0);
                }
              });

          mListView.postDelayed(
              new Runnable() {
                @Override
                public void run() {
                  onRefresh();
                }
              },
              800);
        }
  private void initView(Context context) {
    // 初始情况,设置下拉刷新view高度为0
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 0);
    mContainer =
        (LinearLayout) LayoutInflater.from(context).inflate(R.layout.xlistview_header, null);
    addView(mContainer, lp);
    setGravity(Gravity.BOTTOM);

    mArrowImageView = (ImageView) findViewById(R.id.xlistview_header_arrow);
    mHintTextView = (TextView) findViewById(R.id.xlistview_header_hint_textview);
    mProgressBar = (ImageView) findViewById(R.id.xlistview_header_progressbar);
    mProgressBar.setVisibility(View.GONE);

    mRotateUpAnim =
        new RotateAnimation(
            0.0f, -180.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    mRotateUpAnim.setDuration(ROTATE_ANIM_DURATION);
    mRotateUpAnim.setFillAfter(true);
    mRotateDownAnim =
        new RotateAnimation(
            -180.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    mRotateDownAnim.setDuration(ROTATE_ANIM_DURATION);
    mRotateDownAnim.setFillAfter(true);

    mLoadingAni =
        new RotateAnimation(
            0f, 359f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    mLoadingAni.setDuration(1000);
    mLoadingAni.setRepeatCount(Animation.INFINITE);
    mLoadingAni.setRepeatMode(Animation.RESTART);
    mLoadingAni.setInterpolator(new LinearInterpolator());
  }
예제 #21
0
 // 刷新动画
 public static void refresh(Context context, View v, int id) {
   v.setBackgroundDrawable(context.getResources().getDrawable(id));
   Animation anim = AnimationUtils.loadAnimation(context, R.anim.title_progress);
   // 动画一直不断保持变化
   LinearInterpolator lir = new LinearInterpolator();
   anim.setInterpolator(lir);
   v.startAnimation(anim);
 }
예제 #22
0
  private void showSeekThumb() {
    Animation anim = AnimationUtils.loadAnimation(getContext(), R.anim.slider_thumb_in);
    anim.setDuration(300);
    anim.setInterpolator(getContext(), android.R.interpolator.decelerate_quint);

    scrubberThumb.startAnimation(anim);
    scrubberThumb.setVisibility(View.VISIBLE);
  }
 // 对子控件进行移动
 private void animateOffsetToStartPosition(int from, AnimationListener listener) {
   mFrom = from;
   mAnimateToStartPosition.reset();
   mAnimateToStartPosition.setDuration(mMediumAnimationDuration);
   mAnimateToStartPosition.setAnimationListener(listener);
   mAnimateToStartPosition.setInterpolator(mDecelerateInterpolator);
   mTarget.startAnimation(mAnimateToStartPosition);
 }
예제 #24
0
  /**
   * This animation runs for the thumbnail that gets cross faded with the enter/exit activity when a
   * thumbnail is specified with the activity options.
   */
  Animation createThumbnailScaleAnimationLocked(int appWidth, int appHeight, int transit) {
    Animation a;
    final int thumbWidthI = mNextAppTransitionThumbnail.getWidth();
    final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
    final int thumbHeightI = mNextAppTransitionThumbnail.getHeight();
    final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;

    if (mNextAppTransitionScaleUp) {
      // Animation for the thumbnail zooming from its initial size to the full screen
      float scaleW = appWidth / thumbWidth;
      float scaleH = appHeight / thumbHeight;
      Animation scale =
          new ScaleAnimation(
              1,
              scaleW,
              1,
              scaleH,
              computePivot(mNextAppTransitionStartX, 1 / scaleW),
              computePivot(mNextAppTransitionStartY, 1 / scaleH));
      scale.setInterpolator(mDecelerateInterpolator);

      Animation alpha = new AlphaAnimation(1, 0);
      alpha.setInterpolator(mThumbnailFadeOutInterpolator);

      // This AnimationSet uses the Interpolators assigned above.
      AnimationSet set = new AnimationSet(false);
      set.addAnimation(scale);
      set.addAnimation(alpha);
      a = set;
    } else {
      // Animation for the thumbnail zooming down from the full screen to its final size
      float scaleW = appWidth / thumbWidth;
      float scaleH = appHeight / thumbHeight;
      a =
          new ScaleAnimation(
              scaleW,
              1,
              scaleH,
              1,
              computePivot(mNextAppTransitionStartX, 1 / scaleW),
              computePivot(mNextAppTransitionStartY, 1 / scaleH));
    }

    return prepareThumbnailAnimation(a, appWidth, appHeight, transit);
  }
예제 #25
0
 /** Flash camera preview, then display a white overlay. */
 private void overlayPreview() {
   final Animation animation = new AlphaAnimation(1.0f, 0.8f);
   animation.setDuration(750);
   animation.setInterpolator(getActivity(), android.R.interpolator.decelerate_cubic);
   animation.setFillAfter(true);
   animation.setFillEnabled(true);
   mFlashView.setVisibility(View.VISIBLE);
   mFlashView.startAnimation(animation);
 }
예제 #26
0
  // para animar el imageButton
  public void startAnimation(ImageView ivDH) {

    Animation rotateAnim = new RotateAnimation(0, 360);
    rotateAnim.setDuration(5000);
    rotateAnim.setRepeatCount(1);
    rotateAnim.setInterpolator(new AccelerateInterpolator());
    rotateAnim.setRepeatMode(Animation.REVERSE);
    ivDH.startAnimation(rotateAnim);
  }
예제 #27
0
  /**
   * A fade animation that will fade the subject in by changing alpha from 0 to 1.
   *
   * @param duration the animation duration in milliseconds
   * @param delay how long to wait before starting the animation, in milliseconds
   * @return a fade animation
   * @see #fadeInAnimation(View, long)
   */
  public static Animation fadeInAnimation(long duration, long delay) {

    Animation fadeIn = new AlphaAnimation(0, 1);
    fadeIn.setInterpolator(new DecelerateInterpolator());
    fadeIn.setDuration(duration);
    fadeIn.setStartOffset(delay);

    return fadeIn;
  }
예제 #28
0
  /**
   * A fade animation that will fade the subject out by changing alpha from 1 to 0.
   *
   * @param duration the animation duration in milliseconds
   * @param delay how long to wait before starting the animation, in milliseconds
   * @return a fade animation
   * @see #fadeOutAnimation(View, long)
   */
  public static Animation fadeOutAnimation(long duration, long delay) {

    Animation fadeOut = new AlphaAnimation(1, 0);
    fadeOut.setInterpolator(new AccelerateInterpolator());
    fadeOut.setStartOffset(delay);
    fadeOut.setDuration(duration);

    return fadeOut;
  }
예제 #29
0
 // 加载中动画开始
 public void lodingAnimeStart() {
   ll_loading.setVisibility(View.VISIBLE);
   iv_loading.setVisibility(View.VISIBLE);
   tv_loading.setVisibility(View.VISIBLE);
   Animation operatingAnim = AnimationUtils.loadAnimation(context, R.anim.loading_dialog_round);
   LinearInterpolator lin = new LinearInterpolator();
   operatingAnim.setInterpolator(lin);
   iv_loading.startAnimation(operatingAnim);
 }
예제 #30
0
 protected Animation setAnimScale(float toX, float toY) {
   animationScale =
       new ScaleAnimation(
           1f, toX, 1f, toY, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.45f);
   animationScale.setInterpolator(
       PathButtonActivity.this, anim.accelerate_decelerate_interpolator);
   animationScale.setDuration(500);
   animationScale.setFillAfter(false);
   return animationScale;
 }