use of android.view.animation.Animation in project material by rey5137.
the class ListPopupWindow method show.
/**
* Show the popup list. If the list is already showing, this method
* will recalculate the popup's size and position.
*/
public void show() {
int height = buildDropDown();
int widthSpec = 0;
int heightSpec = 0;
boolean noInputMethod = isInputMethodNotNeeded();
if (mPopup.isShowing()) {
if (mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT) {
// The call to PopupWindow's update method below can accept -1 for any
// value you do not want to update.
widthSpec = -1;
} else if (mDropDownWidth == ViewGroup.LayoutParams.WRAP_CONTENT) {
widthSpec = getAnchorView().getWidth();
} else {
widthSpec = mDropDownWidth;
}
if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
// The call to PopupWindow's update method below can accept -1 for any
// value you do not want to update.
heightSpec = noInputMethod ? height : ViewGroup.LayoutParams.MATCH_PARENT;
if (noInputMethod) {
mPopup.setWindowLayoutMode(mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT ? ViewGroup.LayoutParams.MATCH_PARENT : 0, 0);
} else {
mPopup.setWindowLayoutMode(mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT ? ViewGroup.LayoutParams.MATCH_PARENT : 0, ViewGroup.LayoutParams.MATCH_PARENT);
}
} else if (mDropDownHeight == ViewGroup.LayoutParams.WRAP_CONTENT) {
heightSpec = height;
} else {
heightSpec = mDropDownHeight;
}
mPopup.setOutsideTouchable(!mForceIgnoreOutsideTouch && !mDropDownAlwaysVisible);
mPopup.update(getAnchorView(), mDropDownHorizontalOffset, mDropDownVerticalOffset, widthSpec, heightSpec);
} else {
if (mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT) {
widthSpec = ViewGroup.LayoutParams.MATCH_PARENT;
} else {
if (mDropDownWidth == ViewGroup.LayoutParams.WRAP_CONTENT) {
mPopup.setWidth(getAnchorView().getWidth());
} else {
mPopup.setWidth(mDropDownWidth);
}
}
if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
heightSpec = ViewGroup.LayoutParams.MATCH_PARENT;
} else {
if (mDropDownHeight == ViewGroup.LayoutParams.WRAP_CONTENT) {
mPopup.setHeight(height);
} else {
mPopup.setHeight(mDropDownHeight);
}
}
mPopup.setWindowLayoutMode(widthSpec, heightSpec);
setPopupClipToScreenEnabled(true);
// use outside touchable to dismiss drop down when touching outside of it, so
// only set this if the dropdown is not always visible
mPopup.setOutsideTouchable(!mForceIgnoreOutsideTouch && !mDropDownAlwaysVisible);
mPopup.setTouchInterceptor(mTouchInterceptor);
PopupWindowCompat.showAsDropDown(mPopup, getAnchorView(), mDropDownHorizontalOffset, mDropDownVerticalOffset, mDropDownGravity);
mDropDownList.setSelection(ListView.INVALID_POSITION);
if (!mModal || mDropDownList.isInTouchMode()) {
clearListSelection();
}
if (!mModal) {
mHandler.post(mHideSelector);
}
// show item animation
if (mItemAnimationId != 0)
mPopup.getContentView().getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
mPopup.getContentView().getViewTreeObserver().removeOnPreDrawListener(this);
for (int i = 0, count = mDropDownList.getChildCount(); i < count; i++) {
View v = mDropDownList.getChildAt(i);
Animation anim = AnimationUtils.loadAnimation(mContext, mItemAnimationId);
anim.setStartOffset(mItemAnimationOffset * i);
v.startAnimation(anim);
}
return false;
}
});
}
}
use of android.view.animation.Animation in project material by rey5137.
the class ToolbarManager method animateOut.
private void animateOut() {
ActionMenuView menuView = getMenuView();
int count = menuView == null ? 0 : menuView.getChildCount();
Animation slowestAnimation = null;
mAnimations.clear();
mAnimations.ensureCapacity(count);
for (int i = 0; i < count; i++) {
View child = menuView.getChildAt(i);
Animation anim = mAnimator.getOutAnimation(child, i);
mAnimations.add(anim);
if (anim != null)
if (slowestAnimation == null || slowestAnimation.getStartOffset() + slowestAnimation.getDuration() < anim.getStartOffset() + anim.getDuration())
slowestAnimation = anim;
}
if (slowestAnimation == null)
mOutAnimationEndListener.onAnimationEnd(null);
else {
slowestAnimation.setAnimationListener(mOutAnimationEndListener);
for (int i = 0; i < count; i++) {
Animation anim = mAnimations.get(i);
if (anim != null)
menuView.getChildAt(i).startAnimation(anim);
}
}
mAnimations.clear();
}
use of android.view.animation.Animation in project material by rey5137.
the class RecurringPickerDialog method animOut.
private void animOut(final View v, final boolean setGone, final boolean immediately) {
if (!isShowing() || v.getVisibility() != View.VISIBLE || immediately) {
v.setVisibility(setGone ? View.GONE : View.INVISIBLE);
return;
}
Animation anim = new AlphaAnimation(1f, 0f);
anim.setDuration(getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime));
anim.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
v.setVisibility(setGone ? View.GONE : View.INVISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
v.startAnimation(anim);
}
use of android.view.animation.Animation in project material by rey5137.
the class RecurringPickerDialog method animIn.
private void animIn(final View v, boolean immediately) {
if (v.getVisibility() == View.VISIBLE)
return;
if (!isShowing() || immediately) {
v.setVisibility(View.VISIBLE);
return;
}
Animation anim = new AlphaAnimation(0f, 1f);
anim.setDuration(getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime));
anim.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
v.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationEnd(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
v.startAnimation(anim);
}
use of android.view.animation.Animation in project android-Ultra-Pull-To-Refresh by liaohuqiu.
the class RentalsSunDrawable method setupAnimations.
private void setupAnimations() {
mAnimation = new Animation() {
@Override
public void applyTransformation(float interpolatedTime, Transformation t) {
setRotate(interpolatedTime);
}
};
mAnimation.setRepeatCount(Animation.INFINITE);
mAnimation.setRepeatMode(Animation.RESTART);
mAnimation.setInterpolator(LINEAR_INTERPOLATOR);
mAnimation.setDuration(ANIMATION_DURATION);
}
Aggregations