use of com.nineoldandroids.animation.ValueAnimator in project DropListView by ufo22940268.
the class DropListView method getDropViewScrollAnimator.
private ValueAnimator getDropViewScrollAnimator(int to) {
ValueAnimator restoreAnimator = ValueAnimator.ofFloat(mHeaderView.getBottom(), to);
restoreAnimator.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));
restoreAnimator.setInterpolator(new AccelerateInterpolator());
restoreAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float v = ((Float) (animation.getAnimatedValue())).floatValue();
updateDropviewScroll((int) v);
}
});
return restoreAnimator;
}
use of com.nineoldandroids.animation.ValueAnimator in project SuperRecyclerView by Malinskiy.
the class SwipeDismissRecyclerViewTouchListener method performDismiss.
private void performDismiss(final View dismissView, final int dismissPosition) {
// Animate the dismissed list item to zero-height and fire the dismiss callback when
// all dismissed list item animations have completed. This triggers layout on each animation
// frame; in the future we may want to do something smarter and more performant.
final ViewGroup.LayoutParams lp = dismissView.getLayoutParams();
final int originalHeight = dismissView.getHeight();
ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
--mDismissAnimationRefCount;
if (mDismissAnimationRefCount == 0) {
// No active animations, process all pending dismisses.
// Sort by descending position
Collections.sort(mPendingDismisses);
int[] dismissPositions = new int[mPendingDismisses.size()];
for (int i = mPendingDismisses.size() - 1; i >= 0; i--) {
dismissPositions[i] = mPendingDismisses.get(i).position;
}
mCallbacks.onDismiss(mRecyclerView, dismissPositions);
// Reset mDownPosition to avoid MotionEvent.ACTION_UP trying to start a dismiss
// animation with a stale position
mDownPosition = INVALID_POSITION;
ViewGroup.LayoutParams lp;
for (PendingDismissData pendingDismiss : mPendingDismisses) {
// Reset view presentation
setAlpha(pendingDismiss.view, 1f);
setTranslationX(pendingDismiss.view, 0);
lp = pendingDismiss.view.getLayoutParams();
lp.height = originalHeight;
pendingDismiss.view.setLayoutParams(lp);
}
// Send a cancel event
long time = SystemClock.uptimeMillis();
MotionEvent cancelEvent = MotionEvent.obtain(time, time, MotionEvent.ACTION_CANCEL, 0, 0, 0);
mRecyclerView.dispatchTouchEvent(cancelEvent);
mPendingDismisses.clear();
}
}
});
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
lp.height = (Integer) valueAnimator.getAnimatedValue();
dismissView.setLayoutParams(lp);
}
});
mPendingDismisses.add(new PendingDismissData(dismissPosition, dismissView));
animator.start();
}
use of com.nineoldandroids.animation.ValueAnimator in project BeautifulRefreshLayout by android-cjj.
the class BeautifulRefreshLayout method init.
/**
* 初始化
*/
private void init(AttributeSet attrs) {
/**
* attrs 需要在xml设置什么属性 自己自定义吧 啊哈哈
*/
/**
* 初始化headView
*/
final View headView = LayoutInflater.from(getContext()).inflate(R.layout.view_head, null);
final WaveView waveView = (WaveView) headView.findViewById(R.id.draweeView);
final TextView tv_tip = (TextView) headView.findViewById(R.id.tv_tip);
final RippleView rippleView = (RippleView) headView.findViewById(R.id.ripple);
final RainView rain = (RainView) headView.findViewById(R.id.rain);
rain.setVisibility(View.GONE);
rippleView.setRippleListener(new RippleView.RippleListener() {
@Override
public void onRippleFinish() {
if (listener != null) {
listener.onRefresh(BeautifulRefreshLayout.this);
}
}
});
/**
* 设置波浪的高度
*/
setWaveHeight(DensityUtil.dip2px(getContext(), waveHeight));
/**
* 设置headView的高度
*/
setHeaderHeight(DensityUtil.dip2px(getContext(), headHeight));
/**
* 设置headView
*/
setHeaderView(headView);
/**
* 监听波浪变化监听
*/
setPullWaveListener(new PullWaveListener() {
@Override
public void onPulling(RefreshLayout refreshLayout, float fraction) {
float headW = DensityUtil.dip2px(getContext(), waveHeight);
waveView.setHeadHeight((int) (DensityUtil.dip2px(getContext(), headHeight) * limitValue(1, fraction)));
waveView.setWaveHeight((int) (headW * Math.max(0, fraction - 1)));
waveView.invalidate();
if (DensityUtil.dip2px(getContext(), headHeight) > (int) (DensityUtil.dip2px(getContext(), headHeight) * limitValue(1, fraction))) {
tv_tip.setText("下拉下雨");
} else {
tv_tip.setText("松开下雨");
}
}
@Override
public void onPullReleasing(RefreshLayout refreshLayout, float fraction) {
if (!refreshLayout.isRefreshing) {
}
}
});
/**
* 松开后的监听
*/
setPullToRefreshListener(new PullToRefreshListener() {
@Override
public void onRefresh(RefreshLayout refreshLayout) {
tv_tip.setText("下雨中...");
rain.setVisibility(View.VISIBLE);
rain.StartRain();
waveView.setHeadHeight((int) (DensityUtil.dip2px(getContext(), headHeight)));
ValueAnimator animator = ValueAnimator.ofInt(waveView.getWaveHeight(), 0, -300, 0, -100, 0);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
Log.i("anim", "value--->" + (int) animation.getAnimatedValue());
waveView.setWaveHeight((int) animation.getAnimatedValue());
waveView.invalidate();
}
});
animator.setInterpolator(new BounceInterpolator());
animator.setDuration(1000);
animator.start();
refreshLayout.postDelayed(new Runnable() {
@Override
public void run() {
rippleView.startReveal();
rain.stopRain();
}
}, 3000);
}
});
}
use of com.nineoldandroids.animation.ValueAnimator in project MaterialList by dexafree.
the class SwipeDismissRecyclerViewTouchListener method performDismiss.
private void performDismiss(final View dismissView, final int dismissPosition) {
// Animate the dismissed list item to zero-height and fire the dismiss callback when
// all dismissed list item animations have completed. This triggers layout on each animation
// frame; in the future we may want to do something smarter and more performant.
final ViewGroup.LayoutParams lp = dismissView.getLayoutParams();
final int originalHeight = dismissView.getHeight();
ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
--mDismissAnimationRefCount;
if (mDismissAnimationRefCount == 0) {
// No active animations, process all pending dismisses.
// Sort by descending position
Collections.sort(mPendingDismisses);
int[] dismissPositions = new int[mPendingDismisses.size()];
for (int i = mPendingDismisses.size() - 1; i >= 0; i--) {
dismissPositions[i] = mPendingDismisses.get(i).position;
}
mCallbacks.onDismiss(mRecyclerView, dismissPositions);
// Reset mDownPosition to avoid MotionEvent.ACTION_UP trying to start a dismiss
// animation withProvider a stale position
mDownPosition = ListView.INVALID_POSITION;
ViewGroup.LayoutParams lp;
for (PendingDismissData pendingDismiss : mPendingDismisses) {
// Reset view presentation
setAlpha(pendingDismiss.view, 1f);
setTranslationX(pendingDismiss.view, 0);
lp = pendingDismiss.view.getLayoutParams();
lp.height = originalHeight;
pendingDismiss.view.setLayoutParams(lp);
}
// Send a cancel event
long time = SystemClock.uptimeMillis();
MotionEvent cancelEvent = MotionEvent.obtain(time, time, MotionEvent.ACTION_CANCEL, 0, 0, 0);
mRecyclerView.dispatchTouchEvent(cancelEvent);
mPendingDismisses.clear();
}
}
});
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
lp.height = (Integer) valueAnimator.getAnimatedValue();
dismissView.setLayoutParams(lp);
}
});
mPendingDismisses.add(new PendingDismissData(dismissPosition, dismissView));
animator.start();
}
use of com.nineoldandroids.animation.ValueAnimator in project fresco by facebook.
the class AnimatedDrawableSupport method createValueAnimator.
@Override
public ValueAnimator createValueAnimator(int maxDurationMs) {
ValueAnimator animator = createValueAnimator();
int repeatCount = Math.max((maxDurationMs / getAnimatedDrawableBackend().getDurationMs()), 1);
animator.setRepeatCount(repeatCount);
return animator;
}
Aggregations