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;
}
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;
}
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);
}
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);
}
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);
}
Aggregations