use of android.view.ViewPropertyAnimator in project Telegram-FOSS by Telegram-FOSS-Team.
the class DialogsItemAnimator method animateMoveImpl.
void animateMoveImpl(final ViewHolder holder, ItemHolderInfo info, int fromX, int fromY, int toX, int toY) {
final View view = holder.itemView;
final int deltaX = toX - fromX;
final int deltaY = toY - fromY;
if (deltaX != 0) {
view.animate().translationX(0);
}
if (deltaY != 0) {
view.animate().translationY(0);
}
if (fromY > toY) {
bottomClip = fromY - toY;
} else {
topClip = toY - fromY;
}
if (removingDialog != null) {
if (topClip != Integer.MAX_VALUE) {
bottomClip = removingDialog.getMeasuredHeight() - topClip;
removingDialog.setTopClip(topClip);
removingDialog.setBottomClip(bottomClip);
} else if (bottomClip != Integer.MAX_VALUE) {
topClip = removingDialog.getMeasuredHeight() - bottomClip;
removingDialog.setTopClip(topClip);
removingDialog.setBottomClip(bottomClip);
}
}
// TODO: make EndActions end listeners instead, since end actions aren't called when
// vpas are canceled (and can't end them. why?)
// need listener functionality in VPACompat for this. Ick.
final ViewPropertyAnimator animation = view.animate();
mMoveAnimations.add(holder);
animation.setDuration(deleteDuration).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animator) {
dispatchMoveStarting(holder);
}
@Override
public void onAnimationCancel(Animator animator) {
if (deltaX != 0) {
view.setTranslationX(0);
}
if (deltaY != 0) {
view.setTranslationY(0);
}
if (holder.itemView instanceof DialogCell) {
((DialogCell) holder.itemView).setMoving(false);
} else if (holder.itemView instanceof DialogsAdapter.LastEmptyView) {
((DialogsAdapter.LastEmptyView) holder.itemView).moving = false;
}
}
@Override
public void onAnimationEnd(Animator animator) {
animation.setListener(null);
dispatchMoveFinished(holder);
mMoveAnimations.remove(holder);
dispatchFinishedWhenDone();
if (holder.itemView instanceof DialogCell) {
((DialogCell) holder.itemView).setMoving(false);
} else if (holder.itemView instanceof DialogsAdapter.LastEmptyView) {
((DialogsAdapter.LastEmptyView) holder.itemView).moving = false;
}
view.setTranslationX(0);
view.setTranslationY(0);
}
}).start();
}
use of android.view.ViewPropertyAnimator in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatListItemAnimator method animateAddImpl.
public void animateAddImpl(final RecyclerView.ViewHolder holder, int addedItemsHeight) {
final View view = holder.itemView;
final ViewPropertyAnimator animation = view.animate();
mAddAnimations.add(holder);
view.setTranslationY(addedItemsHeight);
holder.itemView.setScaleX(1);
holder.itemView.setScaleY(1);
ChatMessageCell chatMessageCell = holder.itemView instanceof ChatMessageCell ? (ChatMessageCell) holder.itemView : null;
if (!(chatMessageCell != null && chatMessageCell.getTransitionParams().ignoreAlpha)) {
holder.itemView.setAlpha(1);
}
if (chatMessageCell != null && activity.animatingMessageObjects.contains(chatMessageCell.getMessageObject())) {
activity.animatingMessageObjects.remove(chatMessageCell.getMessageObject());
if (activity.getChatActivityEnterView().canShowMessageTransition()) {
if (chatMessageCell.getMessageObject().isVoice()) {
if (Math.abs(view.getTranslationY()) < view.getMeasuredHeight() * 3f) {
VoiceMessageEnterTransition transition = new VoiceMessageEnterTransition(chatMessageCell, activity.getChatActivityEnterView(), recyclerListView, activity.messageEnterTransitionContainer, resourcesProvider);
transition.start();
}
} else {
if (SharedConfig.getDevicePerformanceClass() != SharedConfig.PERFORMANCE_CLASS_LOW && Math.abs(view.getTranslationY()) < recyclerListView.getMeasuredHeight()) {
TextMessageEnterTransition transition = new TextMessageEnterTransition(chatMessageCell, activity, recyclerListView, activity.messageEnterTransitionContainer, resourcesProvider);
transition.start();
}
}
activity.getChatActivityEnterView().startMessageTransition();
}
}
animation.translationY(0).setDuration(getMoveDuration()).setInterpolator(translationInterpolator).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animator) {
dispatchAddStarting(holder);
}
@Override
public void onAnimationCancel(Animator animator) {
view.setTranslationY(0);
if (view instanceof ChatMessageCell) {
((ChatMessageCell) view).getTransitionParams().messageEntering = false;
}
}
@Override
public void onAnimationEnd(Animator animator) {
if (view instanceof ChatMessageCell) {
((ChatMessageCell) view).getTransitionParams().messageEntering = false;
}
animation.setListener(null);
if (mAddAnimations.remove(holder)) {
dispatchAddFinished(holder);
dispatchFinishedWhenDone();
}
}
}).start();
}
use of android.view.ViewPropertyAnimator in project Telegram-FOSS by Telegram-FOSS-Team.
the class DefaultItemAnimator method animateRemoveImpl.
protected void animateRemoveImpl(final RecyclerView.ViewHolder holder) {
final View view = holder.itemView;
final ViewPropertyAnimator animation = view.animate();
mRemoveAnimations.add(holder);
animation.setDuration(getRemoveDuration()).alpha(0).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animator) {
dispatchRemoveStarting(holder);
}
@Override
public void onAnimationEnd(Animator animator) {
animation.setListener(null);
view.setAlpha(1);
view.setTranslationX(0);
view.setTranslationY(0);
dispatchRemoveFinished(holder);
mRemoveAnimations.remove(holder);
dispatchFinishedWhenDone();
}
}).start();
}
use of android.view.ViewPropertyAnimator in project Telegram-FOSS by Telegram-FOSS-Team.
the class DefaultItemAnimator method animateChangeImpl.
void animateChangeImpl(final ChangeInfo changeInfo) {
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.setTranslationX(0);
view.setTranslationY(0);
dispatchChangeFinished(changeInfo.oldHolder, true);
mChangeAnimations.remove(changeInfo.oldHolder);
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.setTranslationX(0);
newView.setTranslationY(0);
dispatchChangeFinished(changeInfo.newHolder, false);
mChangeAnimations.remove(changeInfo.newHolder);
dispatchFinishedWhenDone();
}
}).start();
}
}
use of android.view.ViewPropertyAnimator in project Telegram-FOSS by Telegram-FOSS-Team.
the class RecyclerListView method checkIfEmpty.
private void checkIfEmpty(boolean animated) {
if (isHidden) {
return;
}
if (getAdapter() == null || emptyView == null) {
if (hiddenByEmptyView && getVisibility() != VISIBLE) {
setVisibility(VISIBLE);
hiddenByEmptyView = false;
}
return;
}
boolean emptyViewVisible = emptyViewIsVisible();
int newVisibility = emptyViewVisible ? VISIBLE : GONE;
if (!animateEmptyView) {
animated = false;
}
if (animated) {
if (emptyViewAnimateToVisibility != newVisibility) {
emptyViewAnimateToVisibility = newVisibility;
if (newVisibility == VISIBLE) {
emptyView.animate().setListener(null).cancel();
if (emptyView.getVisibility() == GONE) {
emptyView.setVisibility(VISIBLE);
emptyView.setAlpha(0);
if (emptyViewAnimationType == 1) {
emptyView.setScaleX(0.7f);
emptyView.setScaleY(0.7f);
}
}
emptyView.animate().alpha(1f).scaleX(1).scaleY(1).setDuration(150).start();
} else {
if (emptyView.getVisibility() != GONE) {
ViewPropertyAnimator animator = emptyView.animate().alpha(0);
if (emptyViewAnimationType == 1) {
animator.scaleY(0.7f).scaleX(0.7f);
}
animator.setDuration(150).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (emptyView != null) {
emptyView.setVisibility(GONE);
}
}
}).start();
}
}
}
} else {
emptyViewAnimateToVisibility = newVisibility;
emptyView.setVisibility(newVisibility);
emptyView.setAlpha(1f);
}
if (hideIfEmpty) {
newVisibility = emptyViewVisible ? INVISIBLE : VISIBLE;
if (getVisibility() != newVisibility) {
setVisibility(newVisibility);
}
hiddenByEmptyView = true;
}
}
Aggregations