Pilldroid/app/src/main/java/net/foucry/pilldroid/SlideAnimationUtil.java

63 lines
1.7 KiB
Java
Raw Normal View History

package net.foucry.pilldroid;
import android.content.Context;
import android.view.View;
import android.view.animation.AnimationUtils;
public class SlideAnimationUtil {
/**
* Animates a view so that it slides in from the left of it's container.
*
* @param context Context
* @param view View
*/
public static void slideInFromLeft(Context context, View view) {
runSimpleAnimation(context, view, R.anim.slide_from_left);
}
/**
* Animates a view so that it slides from its current position, out of view to the left.
*
* @param context Context
* @param view View
*/
public static void slideOutToLeft(Context context, View view) {
runSimpleAnimation(context, view, R.anim.slide_to_left);
}
/**
* Animates a view so that it slides in the from the right of it's container.
*
* @param context Context
* @param view View
*/
public static void slideInFromRight(Context context, View view) {
runSimpleAnimation(context, view, R.anim.slide_from_right);
}
/**
* Animates a view so that it slides from its current position, out of view to the right.
*
* @param context Context
* @param view View
*/
public static void slideOutToRight(Context context, View view) {
runSimpleAnimation(context, view, R.anim.slide_to_right);
}
/**
* Runs a simple animation on a View with no extra parameters.
*
* @param context Context
* @param view View
* @param animationId int
*/
private static void runSimpleAnimation(Context context, View view, int animationId) {
view.startAnimation(AnimationUtils.loadAnimation(
context, animationId
));
}
}