use of android.view.ViewPropertyAnimator in project Hentoid by avluis.
the class ZoomableRecyclerView method zoomFling.
boolean zoomFling(int velocityX, int velocityY) {
if (scale <= DEFAULT_SCALE)
return false;
float distanceTimeFactor = 0.4f;
Float newX = null;
Float newY = null;
if (velocityX != 0 && canMoveHorizontally()) {
float dx = (distanceTimeFactor * velocityX / 2);
newX = getPositionX(getX() + dx);
}
if (velocityY != 0 && canMoveVertically()) {
float dy = (distanceTimeFactor * velocityY / 2);
newY = getPositionY(getY() + dy);
}
ViewPropertyAnimator animation = animate();
if (newX != null)
animation.x(newX);
if (newY != null)
animation.y(newY);
animation.setInterpolator(new DecelerateInterpolator()).setDuration(400).start();
return true;
}
use of android.view.ViewPropertyAnimator in project Telegram-FOSS by Telegram-FOSS-Team.
the class LocationActivityAdapter method onCreateViewHolder.
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view;
switch(viewType) {
case 0:
// view = emptyCell = new EmptyCell(mContext) {
// @Override
// public ViewPropertyAnimator animate() {
// ViewPropertyAnimator animator = super.animate();
// if (Build.VERSION.SDK_INT >= 19) {
// animator.setUpdateListener(animation -> {
// if (updateRunnable != null) {
// updateRunnable.run();
// }
// });
// }
// return animator;
// }
// };
view = emptyCell = new FrameLayout(mContext);
emptyCell.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, overScrollHeight));
break;
case 1:
view = new SendLocationCell(mContext, false, resourcesProvider);
break;
case 2:
view = new HeaderCell(mContext, resourcesProvider);
break;
case 3:
LocationCell locationCell = new LocationCell(mContext, false, resourcesProvider);
view = locationCell;
break;
case 4:
view = new LocationLoadingCell(mContext, resourcesProvider);
break;
case 5:
view = new LocationPoweredCell(mContext, resourcesProvider);
break;
case 6:
{
SendLocationCell cell = new SendLocationCell(mContext, true, resourcesProvider);
cell.setDialogId(dialogId);
view = cell;
break;
}
case 7:
view = new SharingLiveLocationCell(mContext, true, locationType == LocationActivity.LOCATION_TYPE_GROUP || locationType == LocationActivity.LOCATION_TYPE_GROUP_VIEW ? 16 : 54, resourcesProvider);
break;
case 8:
{
LocationDirectionCell cell = new LocationDirectionCell(mContext, resourcesProvider);
cell.setOnButtonClick(v -> onDirectionClick());
view = cell;
break;
}
case 9:
{
view = new ShadowSectionCell(mContext);
Drawable drawable = Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow);
CombinedDrawable combinedDrawable = new CombinedDrawable(new ColorDrawable(getThemedColor(Theme.key_windowBackgroundGray)), drawable);
combinedDrawable.setFullsize(true);
view.setBackgroundDrawable(combinedDrawable);
break;
}
case 10:
default:
{
view = new View(mContext);
break;
}
}
return new RecyclerListView.Holder(view);
}
use of android.view.ViewPropertyAnimator in project Telegram-FOSS by Telegram-FOSS-Team.
the class SideMenultItemAnimator method animateAddImpl.
void animateAddImpl(final RecyclerView.ViewHolder holder, int num, int addCount, int totalHeight) {
final View view = holder.itemView;
final ViewPropertyAnimator animation = view.animate();
mAddAnimations.add(holder);
view.setAlpha(1.0f);
view.setTranslationY(-totalHeight);
animation.translationY(0.0f).setDuration(220).setInterpolator(CubicBezierInterpolator.EASE_OUT).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animator) {
dispatchAddStarting(holder);
}
@Override
public void onAnimationCancel(Animator animator) {
view.setTranslationY(0.0f);
}
@Override
public void onAnimationEnd(Animator animator) {
animation.setListener(null);
dispatchAddFinished(holder);
mAddAnimations.remove(holder);
dispatchFinishedWhenDone();
}
}).start();
}
use of android.view.ViewPropertyAnimator in project Telegram-FOSS by Telegram-FOSS-Team.
the class SideMenultItemAnimator method animateRemoveImpl.
private void animateRemoveImpl(final RecyclerView.ViewHolder holder, int totalHeight) {
final View view = holder.itemView;
final ViewPropertyAnimator animation = view.animate();
mRemoveAnimations.add(holder);
animation.setDuration(220).translationY(-totalHeight).setInterpolator(CubicBezierInterpolator.EASE_OUT).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animator) {
dispatchRemoveStarting(holder);
}
@Override
public void onAnimationEnd(Animator animator) {
animation.setListener(null);
dispatchRemoveFinished(holder);
mRemoveAnimations.remove(holder);
dispatchFinishedWhenDone();
}
}).start();
}
use of android.view.ViewPropertyAnimator in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatListItemAnimator method animateChangeImpl.
void animateChangeImpl(final ChangeInfo changeInfo) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("animate change impl");
}
final RecyclerView.ViewHolder holder = changeInfo.oldHolder;
final View view = holder == null ? null : holder.itemView;
final RecyclerView.ViewHolder newHolder = changeInfo.newHolder;
final View newView = newHolder != null ? newHolder.itemView : null;
if (view != null) {
final ViewPropertyAnimator oldViewAnim = view.animate().setDuration(getChangeDuration());
mChangeAnimations.add(changeInfo.oldHolder);
oldViewAnim.translationX(changeInfo.toX - changeInfo.fromX);
oldViewAnim.translationY(changeInfo.toY - changeInfo.fromY);
oldViewAnim.alpha(0).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animator) {
dispatchChangeStarting(changeInfo.oldHolder, true);
}
@Override
public void onAnimationEnd(Animator animator) {
oldViewAnim.setListener(null);
view.setAlpha(1);
view.setScaleX(1f);
view.setScaleX(1f);
if (view instanceof ChatMessageCell) {
((ChatMessageCell) view).setAnimationOffsetX(0);
} else {
view.setTranslationX(0);
}
view.setTranslationY(0);
if (mChangeAnimations.remove(changeInfo.oldHolder)) {
dispatchChangeFinished(changeInfo.oldHolder, true);
dispatchFinishedWhenDone();
}
}
}).start();
}
if (newView != null) {
final ViewPropertyAnimator newViewAnimation = newView.animate();
mChangeAnimations.add(changeInfo.newHolder);
newViewAnimation.translationX(0).translationY(0).setDuration(getChangeDuration()).alpha(1).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animator) {
dispatchChangeStarting(changeInfo.newHolder, false);
}
@Override
public void onAnimationEnd(Animator animator) {
newViewAnimation.setListener(null);
newView.setAlpha(1);
newView.setScaleX(1f);
newView.setScaleX(1f);
if (newView instanceof ChatMessageCell) {
((ChatMessageCell) newView).setAnimationOffsetX(0);
} else {
newView.setTranslationX(0);
}
newView.setTranslationY(0);
if (mChangeAnimations.remove(changeInfo.newHolder)) {
dispatchChangeFinished(changeInfo.newHolder, false);
dispatchFinishedWhenDone();
}
}
}).start();
}
}
Aggregations