use of com.nineoldandroids.animation.ValueAnimator in project CoCoin by Nightonke.
the class RiseNumberTextView method runFloat.
private void runFloat() {
ValueAnimator valueAnimator = ValueAnimator.ofFloat(fromNumber, number);
valueAnimator.setDuration(duration);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
setText(fnum.format(Float.parseFloat(valueAnimator.getAnimatedValue().toString())));
if (valueAnimator.getAnimatedFraction() >= 1) {
mPlayingState = STOPPED;
if (mEndListener != null)
mEndListener.onEndFinish();
}
}
});
valueAnimator.start();
}
use of com.nineoldandroids.animation.ValueAnimator in project CoCoin by Nightonke.
the class RiseNumberTextView method runInt.
private void runInt() {
ValueAnimator valueAnimator = ValueAnimator.ofInt((int) fromNumber, (int) number);
valueAnimator.setDuration(duration);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
setText(valueAnimator.getAnimatedValue().toString());
if (valueAnimator.getAnimatedFraction() >= 1) {
mPlayingState = STOPPED;
if (mEndListener != null)
mEndListener.onEndFinish();
}
}
});
valueAnimator.start();
}
use of com.nineoldandroids.animation.ValueAnimator in project SimplifyReader by chentao0707.
the class CaptureActivity method initViewsAndEvents.
@Override
protected void initViewsAndEvents() {
hasSurface = false;
mInactivityTimer = new InactivityTimer(this);
mBeepManager = new BeepManager(this);
initCropViewAnimator();
capturePictureBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
readyGoForResult(CommonImagePickerListActivity.class, IMAGE_PICKER_REQUEST_CODE);
}
});
captureLightBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isLightOn) {
cameraManager.setTorch(false);
captureLightBtn.setSelected(false);
} else {
cameraManager.setTorch(true);
captureLightBtn.setSelected(true);
}
isLightOn = !isLightOn;
}
});
captureModeGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (checkedId == R.id.capture_mode_barcode) {
PropertyValuesHolder qr2barWidthVH = PropertyValuesHolder.ofFloat("width", 1.0f, (float) mBarcodeCropWidth / mQrcodeCropWidth);
PropertyValuesHolder qr2barHeightVH = PropertyValuesHolder.ofFloat("height", 1.0f, (float) mBarcodeCropHeight / mQrcodeCropHeight);
ValueAnimator valueAnimator = ValueAnimator.ofPropertyValuesHolder(qr2barWidthVH, qr2barHeightVH);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
Float fractionW = (Float) animation.getAnimatedValue("width");
Float fractionH = (Float) animation.getAnimatedValue("height");
RelativeLayout.LayoutParams parentLayoutParams = (RelativeLayout.LayoutParams) captureCropView.getLayoutParams();
parentLayoutParams.width = (int) (mQrcodeCropWidth * fractionW);
parentLayoutParams.height = (int) (mQrcodeCropHeight * fractionH);
captureCropView.setLayoutParams(parentLayoutParams);
}
});
valueAnimator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
initCrop();
setDataMode(DecodeUtils.DECODE_DATA_MODE_BARCODE);
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
valueAnimator.start();
} else if (checkedId == R.id.capture_mode_qrcode) {
PropertyValuesHolder bar2qrWidthVH = PropertyValuesHolder.ofFloat("width", 1.0f, (float) mQrcodeCropWidth / mBarcodeCropWidth);
PropertyValuesHolder bar2qrHeightVH = PropertyValuesHolder.ofFloat("height", 1.0f, (float) mQrcodeCropHeight / mBarcodeCropHeight);
ValueAnimator valueAnimator = ValueAnimator.ofPropertyValuesHolder(bar2qrWidthVH, bar2qrHeightVH);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
Float fractionW = (Float) animation.getAnimatedValue("width");
Float fractionH = (Float) animation.getAnimatedValue("height");
RelativeLayout.LayoutParams parentLayoutParams = (RelativeLayout.LayoutParams) captureCropView.getLayoutParams();
parentLayoutParams.width = (int) (mBarcodeCropWidth * fractionW);
parentLayoutParams.height = (int) (mBarcodeCropHeight * fractionH);
captureCropView.setLayoutParams(parentLayoutParams);
}
});
valueAnimator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
initCrop();
setDataMode(DecodeUtils.DECODE_DATA_MODE_QRCODE);
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
valueAnimator.start();
}
}
});
}
use of com.nineoldandroids.animation.ValueAnimator in project SunDay by iQuick.
the class SwipeListViewTouchListener method performDismiss.
/**
* Perform dismiss action
*
* @param dismissView View
* @param dismissPosition Position of list
*/
protected void performDismiss(final View dismissView, final int dismissPosition, boolean doPendingDismiss) {
final ViewGroup.LayoutParams lp = dismissView.getLayoutParams();
final int originalHeight = dismissView.getHeight();
ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(animationTime);
if (doPendingDismiss) {
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
--dismissAnimationRefCount;
if (dismissAnimationRefCount == 0) {
removePendingDismisses(originalHeight);
}
}
});
}
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
lp.height = (Integer) valueAnimator.getAnimatedValue();
dismissView.setLayoutParams(lp);
}
});
pendingDismisses.add(new PendingDismissData(dismissPosition, dismissView));
animator.start();
}
use of com.nineoldandroids.animation.ValueAnimator in project AndroidSweetSheet by zzz40500.
the class CircleRevealHelper method circularReveal.
public void circularReveal(int centerX, int centerY, float startRadius, float endRadius, long duration, Interpolator interpolator) {
mAnchorX = centerX;
mAnchorY = centerY;
if (mView.getParent() == null) {
return;
}
if (Build.VERSION.SDK_INT >= 21) {
Animator animator = ViewAnimationUtils.createCircularReveal(mView, mAnchorX, mAnchorY, startRadius, endRadius);
animator.setInterpolator(interpolator);
animator.setDuration(duration);
animator.start();
} else {
ValueAnimator valueAnimator = ValueAnimator.ofFloat(startRadius, endRadius);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mRadius = (float) animation.getAnimatedValue();
mView.invalidate();
}
});
valueAnimator.setInterpolator(interpolator);
valueAnimator.addListener(new SimpleAnimationListener() {
@Override
public void onAnimationStart(com.nineoldandroids.animation.Animator animation) {
isCircularReveal = true;
}
@Override
public void onAnimationEnd(com.nineoldandroids.animation.Animator animation) {
isCircularReveal = false;
}
@Override
public void onAnimationCancel(com.nineoldandroids.animation.Animator animation) {
isCircularReveal = false;
}
});
valueAnimator.setDuration(duration);
valueAnimator.start();
}
}
Aggregations