SlideKitkatpublic class SlideKitkat extends android.transition.Visibility Slide distance toward/from a edge.
This is a limited Slide implementation for KitKat without propagation support. |
Fields Summary |
---|
private static final String | TAG | private static final android.animation.TimeInterpolator | sDecelerate | private static final android.animation.TimeInterpolator | sAccelerate | private int | mSlideEdge | private CalculateSlide | mSlideCalculator | private static final CalculateSlide | sCalculateLeft | private static final CalculateSlide | sCalculateTop | private static final CalculateSlide | sCalculateRight | private static final CalculateSlide | sCalculateBottom | private static final CalculateSlide | sCalculateStart | private static final CalculateSlide | sCalculateEnd |
Constructors Summary |
---|
public SlideKitkat()
setSlideEdge(Gravity.BOTTOM);
| public SlideKitkat(android.content.Context context, android.util.AttributeSet attrs)
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.lbSlide);
int edge = a.getInt(R.styleable.lbSlide_lb_slideEdge, Gravity.BOTTOM);
setSlideEdge(edge);
long duration = a.getInt(R.styleable.lbSlide_android_duration, -1);
if (duration >= 0) {
setDuration(duration);
}
long startDelay = a.getInt(R.styleable.lbSlide_android_startDelay, -1);
if (startDelay > 0) {
setStartDelay(startDelay);
}
final int resID = a.getResourceId(R.styleable.lbSlide_android_interpolator, 0);
if (resID > 0) {
setInterpolator(AnimationUtils.loadInterpolator(context, resID));
}
a.recycle();
|
Methods Summary |
---|
private android.animation.Animator | createAnimation(android.view.View view, android.util.Property property, float start, float end, float terminalValue, android.animation.TimeInterpolator interpolator, int finalVisibility)
float[] startPosition = (float[]) view.getTag(R.id.lb_slide_transition_value);
if (startPosition != null) {
start = View.TRANSLATION_Y == property ? startPosition[1] : startPosition[0];
view.setTag(R.id.lb_slide_transition_value, null);
}
final ObjectAnimator anim = ObjectAnimator.ofFloat(view, property, start, end);
SlideAnimatorListener listener = new SlideAnimatorListener(view, property, terminalValue, end,
finalVisibility);
anim.addListener(listener);
anim.addPauseListener(listener);
anim.setInterpolator(interpolator);
return anim;
| public int | getSlideEdge()Returns the edge that Views appear and disappear from.
return mSlideEdge;
| public android.animation.Animator | onAppear(android.view.ViewGroup sceneRoot, android.transition.TransitionValues startValues, int startVisibility, android.transition.TransitionValues endValues, int endVisibility)
View view = (endValues != null) ? endValues.view : null;
if (view == null) {
return null;
}
float end = mSlideCalculator.getHere(view);
float start = mSlideCalculator.getGone(view);
return createAnimation(view, mSlideCalculator.getProperty(), start, end, end, sDecelerate,
View.VISIBLE);
| public android.animation.Animator | onDisappear(android.view.ViewGroup sceneRoot, android.transition.TransitionValues startValues, int startVisibility, android.transition.TransitionValues endValues, int endVisibility)
View view = (startValues != null) ? startValues.view : null;
if (view == null) {
return null;
}
float start = mSlideCalculator.getHere(view);
float end = mSlideCalculator.getGone(view);
return createAnimation(view, mSlideCalculator.getProperty(), start, end, start,
sAccelerate, View.INVISIBLE);
| public void | setSlideEdge(int slideEdge)Change the edge that Views appear and disappear from.
switch (slideEdge) {
case Gravity.LEFT:
mSlideCalculator = sCalculateLeft;
break;
case Gravity.TOP:
mSlideCalculator = sCalculateTop;
break;
case Gravity.RIGHT:
mSlideCalculator = sCalculateRight;
break;
case Gravity.BOTTOM:
mSlideCalculator = sCalculateBottom;
break;
case Gravity.START:
mSlideCalculator = sCalculateStart;
break;
case Gravity.END:
mSlideCalculator = sCalculateEnd;
break;
default:
throw new IllegalArgumentException("Invalid slide direction");
}
mSlideEdge = slideEdge;
|
|