Search in sources :

Example 96 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project mobile-android by photo.

the class BottombarViewFlipper method createInAnimation.

/**
 * Creates the in animation.
 *
 * @param deltaType
 *           the delta type
 * @param height
 *           the height
 * @param durationMillis
 *           the duration millis
 * @param startOffset
 *           the start offset
 * @return the animation
 */
private Animation createInAnimation(int deltaType, int height, int durationMillis, int startOffset) {
    if (mAnimationIn == null) {
        mAnimationIn = new TranslateAnimation(deltaType, 0, deltaType, 0, deltaType, height, deltaType, 0);
        mAnimationIn.setDuration(durationMillis);
        mAnimationIn.setStartOffset(startOffset);
        mAnimationIn.setInterpolator(new AccelerateInterpolator(0.5f));
    }
    return mAnimationIn;
// return animation;
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator) TranslateAnimation(android.view.animation.TranslateAnimation)

Example 97 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project Etar-Calendar by Etar-Group.

the class DayView method switchViews.

private View switchViews(boolean forward, float xOffSet, float width, float velocity) {
    mAnimationDistance = width - xOffSet;
    if (DEBUG) {
        Log.d(TAG, "switchViews(" + forward + ") O:" + xOffSet + " Dist:" + mAnimationDistance);
    }
    float progress = Math.abs(xOffSet) / width;
    if (progress > 1.0f) {
        progress = 1.0f;
    }
    float inFromXValue, inToXValue;
    float outFromXValue, outToXValue;
    if (forward) {
        inFromXValue = 1.0f - progress;
        inToXValue = 0.0f;
        outFromXValue = -progress;
        outToXValue = -1.0f;
    } else {
        inFromXValue = progress - 1.0f;
        inToXValue = 0.0f;
        outFromXValue = progress;
        outToXValue = 1.0f;
    }
    final Time start = new Time(mBaseDate.timezone);
    start.set(mController.getTime());
    if (forward) {
        start.monthDay += mNumDays;
    } else {
        start.monthDay -= mNumDays;
    }
    mController.setTime(start.normalize(true));
    Time newSelected = start;
    if (mNumDays == 7) {
        newSelected = new Time(start);
        adjustToBeginningOfWeek(start);
    }
    final Time end = new Time(start);
    end.monthDay += mNumDays - 1;
    // We have to allocate these animation objects each time we switch views
    // because that is the only way to set the animation parameters.
    TranslateAnimation inAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, inFromXValue, Animation.RELATIVE_TO_SELF, inToXValue, Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, 0.0f);
    TranslateAnimation outAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, outFromXValue, Animation.RELATIVE_TO_SELF, outToXValue, Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, 0.0f);
    long duration = calculateDuration(width - Math.abs(xOffSet), width, velocity);
    inAnimation.setDuration(duration);
    inAnimation.setInterpolator(mHScrollInterpolator);
    outAnimation.setInterpolator(mHScrollInterpolator);
    outAnimation.setDuration(duration);
    outAnimation.setAnimationListener(new GotoBroadcaster(start, end));
    mViewSwitcher.setInAnimation(inAnimation);
    mViewSwitcher.setOutAnimation(outAnimation);
    DayView view = (DayView) mViewSwitcher.getCurrentView();
    view.cleanup();
    mViewSwitcher.showNext();
    view = (DayView) mViewSwitcher.getCurrentView();
    view.setSelected(newSelected, true, false);
    view.requestFocus();
    view.reloadEvents();
    view.updateTitle();
    view.restartCurrentTimeUpdates();
    return view;
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation) Time(android.text.format.Time)

Example 98 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project cw-advandroid by commonsguy.

the class SlidingPanel method toggle.

public void toggle() {
    TranslateAnimation anim = null;
    AnimationSet set = new AnimationSet(true);
    isOpen = !isOpen;
    if (isOpen) {
        setVisibility(View.VISIBLE);
        anim = new TranslateAnimation(0.0f, 0.0f, getHeight(), 0.0f);
    } else {
        anim = new TranslateAnimation(0.0f, 0.0f, 0.0f, getHeight());
        anim.setAnimationListener(collapseListener);
        set.addAnimation(fadeOut);
    }
    set.addAnimation(anim);
    set.setDuration(speed);
    set.setInterpolator(new AccelerateInterpolator(1.0f));
    startAnimation(set);
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator) TranslateAnimation(android.view.animation.TranslateAnimation) AnimationSet(android.view.animation.AnimationSet)

Example 99 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project Android2048GameLesson by plter.

the class AnimLayer method createMoveAnim.

public void createMoveAnim(final Card from, final Card to, int fromX, int toX, int fromY, int toY) {
    final Card c = getCard(from.getNum());
    LayoutParams lp = new LayoutParams(Config.CARD_WIDTH, Config.CARD_WIDTH);
    lp.leftMargin = fromX * Config.CARD_WIDTH;
    lp.topMargin = fromY * Config.CARD_WIDTH;
    c.setLayoutParams(lp);
    if (to.getNum() <= 0) {
        to.getLabel().setVisibility(View.INVISIBLE);
    }
    TranslateAnimation ta = new TranslateAnimation(0, Config.CARD_WIDTH * (toX - fromX), 0, Config.CARD_WIDTH * (toY - fromY));
    ta.setDuration(100);
    ta.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            to.getLabel().setVisibility(View.VISIBLE);
            recycleCard(c);
        }
    });
    c.startAnimation(ta);
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation) ScaleAnimation(android.view.animation.ScaleAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation)

Example 100 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project Signal-Android by WhisperSystems.

the class CreateKbsPinFragment method shake.

private static void shake(@NonNull EditText view, @NonNull Runnable afterwards) {
    TranslateAnimation shake = new TranslateAnimation(0, 30, 0, 0);
    shake.setDuration(50);
    shake.setRepeatCount(7);
    shake.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            afterwards.run();
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    view.startAnimation(shake);
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation)

Aggregations

TranslateAnimation (android.view.animation.TranslateAnimation)229 Animation (android.view.animation.Animation)109 AlphaAnimation (android.view.animation.AlphaAnimation)90 AnimationSet (android.view.animation.AnimationSet)69 ScaleAnimation (android.view.animation.ScaleAnimation)44 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)30 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)27 View (android.view.View)22 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)22 TextView (android.widget.TextView)18 AnimationListener (android.view.animation.Animation.AnimationListener)17 LinearInterpolator (android.view.animation.LinearInterpolator)13 RotateAnimation (android.view.animation.RotateAnimation)13 ClipRectAnimation (android.view.animation.ClipRectAnimation)12 ListView (android.widget.ListView)12 CurvedTranslateAnimation (com.android.server.wm.animation.CurvedTranslateAnimation)12 ImageView (android.widget.ImageView)11 LayoutAnimationController (android.view.animation.LayoutAnimationController)8 WindowAnimation_activityCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation)8 WindowAnimation_activityCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation)8