use of android.view.animation.OvershootInterpolator in project Signal-Android by signalapp.
the class RegistrationActivity method displayRestoreView.
private void displayRestoreView(@NonNull BackupUtil.BackupInfo backup) {
title.animate().translationX(title.getWidth()).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {
@Override
public void onAnimationEnd(Animator animation) {
title.setText(R.string.RegistrationActivity_restore_from_backup);
title.clearAnimation();
title.setTranslationX(-1 * title.getWidth());
title.animate().translationX(0).setListener(null).setInterpolator(new OvershootInterpolator()).setDuration(SCENE_TRANSITION_DURATION).start();
}
}).start();
subtitle.animate().translationX(subtitle.getWidth()).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {
@Override
public void onAnimationEnd(Animator animation) {
subtitle.setText(R.string.RegistrationActivity_restore_your_messages_and_media_from_a_local_backup);
subtitle.clearAnimation();
subtitle.setTranslationX(-1 * subtitle.getWidth());
subtitle.animate().translationX(0).setListener(null).setInterpolator(new OvershootInterpolator()).setDuration(SCENE_TRANSITION_DURATION).start();
}
}).start();
registrationContainer.animate().translationX(registrationContainer.getWidth()).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {
@Override
public void onAnimationEnd(Animator animation) {
registrationContainer.clearAnimation();
registrationContainer.setVisibility(View.INVISIBLE);
registrationContainer.setTranslationX(0);
restoreContainer.setTranslationX(-1 * registrationContainer.getWidth());
restoreContainer.setVisibility(View.VISIBLE);
restoreButton.setProgress(0);
restoreButton.setIndeterminateProgressMode(false);
restoreButton.setOnClickListener(v -> handleRestore(backup));
restoreBackupSize.setText(getString(R.string.RegistrationActivity_backup_size_s, Util.getPrettyFileSize(backup.getSize())));
restoreBackupTime.setText(getString(R.string.RegistrationActivity_backup_timestamp_s, DateUtils.getExtendedRelativeTimeSpanString(RegistrationActivity.this, Locale.US, backup.getTimestamp())));
restoreBackupProgress.setText("");
restoreContainer.animate().translationX(0).setDuration(SCENE_TRANSITION_DURATION).setListener(null).setInterpolator(new OvershootInterpolator()).start();
}
}).start();
fab.animate().rotationBy(375f).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {
@Override
public void onAnimationEnd(Animator animation) {
fab.clearAnimation();
fab.setImageResource(R.drawable.ic_restore_white_24dp);
fab.animate().rotationBy(360f).setDuration(SCENE_TRANSITION_DURATION).setListener(null).start();
}
}).start();
}
use of android.view.animation.OvershootInterpolator in project Signal-Android by signalapp.
the class RegistrationActivity method displayPinView.
private void displayPinView(String code, long lockedUntil) {
title.animate().translationX(-1 * title.getWidth()).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {
@Override
public void onAnimationEnd(Animator animation) {
title.setText(R.string.RegistrationActivity_registration_lock_pin);
title.clearAnimation();
title.setTranslationX(title.getWidth());
title.animate().translationX(0).setListener(null).setInterpolator(new OvershootInterpolator()).setDuration(SCENE_TRANSITION_DURATION).start();
}
}).start();
subtitle.animate().translationX(-1 * subtitle.getWidth()).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {
@Override
public void onAnimationEnd(Animator animation) {
subtitle.setText(R.string.RegistrationActivity_this_phone_number_has_registration_lock_enabled_please_enter_the_registration_lock_pin);
subtitle.clearAnimation();
subtitle.setTranslationX(subtitle.getWidth());
subtitle.animate().translationX(0).setListener(null).setInterpolator(new OvershootInterpolator()).setDuration(SCENE_TRANSITION_DURATION).start();
}
}).start();
verificationContainer.animate().translationX(-1 * verificationContainer.getWidth()).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {
@Override
public void onAnimationEnd(Animator animation) {
verificationContainer.clearAnimation();
verificationContainer.setVisibility(View.INVISIBLE);
verificationContainer.setTranslationX(0);
pinContainer.setTranslationX(pinContainer.getWidth());
pinContainer.setVisibility(View.VISIBLE);
pinContainer.animate().translationX(0).setListener(null).setInterpolator(new OvershootInterpolator()).setDuration(SCENE_TRANSITION_DURATION).start();
}
}).start();
fab.animate().rotationBy(-360f).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {
@Override
public void onAnimationEnd(Animator animation) {
fab.clearAnimation();
fab.setImageResource(R.drawable.ic_lock_white_24dp);
fab.animate().rotationBy(-360f).setDuration(SCENE_TRANSITION_DURATION).setListener(null).start();
}
}).start();
pinButton.setOnClickListener(v -> handleVerifyWithPinClicked(code, pin.getText().toString()));
pinForgotButton.setOnClickListener(v -> handleForgottenPin(lockedUntil));
pin.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
if (s != null && code.equals(s.toString()))
pinClarificationContainer.setVisibility(View.VISIBLE);
else if (pinClarificationContainer.getVisibility() == View.VISIBLE)
pinClarificationContainer.setVisibility(View.GONE);
}
});
}
use of android.view.animation.OvershootInterpolator in project CustomViews by AndroidStudy233.
the class ScaleHeadListView method recoverImage.
/**
* 回复ImageView到原来的样子
*/
public void recoverImage() {
// 恢复布局中写的ImageView高度,执行一个属性动画,从当前高度到布局中原来ImageView的高度
final ValueAnimator animator = ValueAnimator.ofInt(iv_header.getHeight(), ivHeight);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
int value = (Integer) animator.getAnimatedValue();
// 逐渐恢复到原始高度
iv_header.getLayoutParams().height = value;
iv_header.requestLayout();
}
});
// 加一个回弹插补器
animator.setInterpolator(new OvershootInterpolator(1.5f));
animator.setDuration(500);
animator.start();
}
use of android.view.animation.OvershootInterpolator in project CustomViews by AndroidStudy233.
the class RecyclerViewActivity method fillContentView.
private void fillContentView() {
View view = View.inflate(this, R.layout.layout_recycler_main, null);
// 初始化SwipeRefreshLayout
swipe_main = (SwipeRefreshLayout) view.findViewById(R.id.swipe_recycler_main);
swipe_main.setColorSchemeResources(R.color.swipe_schema_red, swipe_schema_blue, R.color.swipe_schema_green);
swipe_main.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
MyApplication.getHandler().postDelayed(new Runnable() {
@Override
public void run() {
showToast("刷新成功~");
swipe_main.setRefreshing(false);
}
}, 1500);
}
});
// 初始化RecyclerView
recycler_main = (RecyclerView) view.findViewById(R.id.recycler_recycler_main);
// 设置布局管理者,采用线性布局管理者,竖直排列,不用反转(反转就是数据反序)
recycler_main.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
adapter = new SimpleRecyclerAdapter(this, new SimpleRecyclerAdapter.OnItemClickListener() {
@Override
public void onClick(int position, ImgAndText bean) {
/*
这里有个要注意的地方就是,在adapter中设置侦听的时候你要是用onBindViewHolder方法中的参数position
那么remove之后会position错乱BUG.这是RecyclerView的一个大坑...要用holder.getAdapterPosition传递
*/
System.arraycopy(hits, 1, hits, 0, hits.length - 1);
hits[hits.length - 1] = SystemClock.uptimeMillis();
if (hits[0] >= SystemClock.uptimeMillis() - 500) {
MyLogUtil.debug("position: " + position);
adapter.removeItem(position);
} else {
ToastUtil.toastShort(RecyclerViewActivity.this, "点击了图片");
}
}
});
// 设置拖拽监听, 首先定义一个callback定义拖拽功能, callback中定义listener与adapter传递事件
// 然后将callback传给helper, 并由helper绑定recycle
ItemTouchHelper.Callback callback = new OnRecyclerItemTouchCallBack(adapter);
ItemTouchHelper helper = new ItemTouchHelper(callback);
helper.attachToRecyclerView(recycler_main);
/*
细节注意, 上述方式是通过长按条目来实现拖拽, 比如条目右边有个图标, 希望按住图标实现拖拽呢?
adapter的holder中设置图标触摸事件setOnTouchListener. 这就需要在onTouch方法中调用上面helper的
onStartDrag方法, 怎么调用呢? adapter定义一个接口OnIconDragHandler. 里边定义
onHandleDrag(RecyclerView.ViewHolder viewHolder); 然后通过构造传进来.
这样再让当前activity实现接口, 调用helper的onStartDrag方法. 然后new adapter的时候传过去.
最后具体一下图标的ouTouch方法
如果按下
if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN){
回调RecyclerViewActivity中的onHandleDrag方法
让mItemTouchHelper执行拖拽操作
handler.startDrag(holder);
}
*/
// recycler_main.setAdapter(adapter);
// 使用第三方库中简单的动画来设置适配器,其对象可以setDuration、setInterpolator,甚至可以继续传入形成装饰者
// recycler_main.setAdapter(new ScaleInAnimationAdapter(adapter));
recycler_main.setAdapter(new SlideInLeftAnimationAdapter(adapter));
/*
这里有个非常重要的问题,如果你想使用增删动画,那么在增删操作的时候
你就不能使用notifyDataSetChanged,不然动画不会执行的,需要使用notifyItemRemoved(posi)、notifyItemInserted(posi)
*/
// 设置条目动画,增删的时候会用到
SlideInLeftAnimator animator = new SlideInLeftAnimator();
animator.setInterpolator(new OvershootInterpolator());
recycler_main.setItemAnimator(animator);
// 将填充好的View放到主页面上
frame_main.addView(view);
}
use of android.view.animation.OvershootInterpolator in project PhotoNoter by yydcdut.
the class DetailActivity method upAnimation.
@Override
public void upAnimation() {
View adapterPositionView = mDetailPagerAdapter.getItemView(mViewPager.getCurrentItem());
View blurView;
if (adapterPositionView != null) {
blurView = adapterPositionView.findViewById(R.id.img_blur);
} else {
blurView = mOverlayView;
}
final View finalBlurView = blurView;
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(ObjectAnimator.ofFloat(mCardView, "translationY", mTranslateHeight, 0), ObjectAnimator.ofFloat(mViewPager, "scaleX", 1f, 1.1f), ObjectAnimator.ofFloat(mViewPager, "scaleY", 1f, 1.1f), ObjectAnimator.ofFloat(finalBlurView, "alpha", 0f, 1f));
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
super.onAnimationStart(animation);
finalBlurView.setVisibility(View.VISIBLE);
mOverlayView.setVisibility(View.VISIBLE);
mIsIgnoreClick = true;
}
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
mIsIgnoreClick = false;
}
});
animatorSet.setDuration(400);
animatorSet.setInterpolator(new OvershootInterpolator());
animatorSet.start();
mAnimationHandler.postDelayed(mUpDelayRunnable, 500);
}
Aggregations