use of org.telegram.ui.Cells.DialogCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class DialogsItemAnimator method animateAddImpl.
void animateAddImpl(final ViewHolder holder) {
final View view = holder.itemView;
mAddAnimations.add(holder);
final ViewPropertyAnimator animation = view.animate();
animation.alpha(1).setDuration(deleteDuration).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animator) {
dispatchAddStarting(holder);
}
@Override
public void onAnimationCancel(Animator animator) {
view.setAlpha(1);
}
@Override
public void onAnimationEnd(Animator animator) {
animation.setListener(null);
dispatchAddFinished(holder);
mAddAnimations.remove(holder);
dispatchFinishedWhenDone();
if (holder.itemView instanceof DialogCell) {
((DialogCell) holder.itemView).setMoving(false);
}
}
}).start();
}
use of org.telegram.ui.Cells.DialogCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class DialogsItemAnimator method endAnimation.
@Override
public void endAnimation(ViewHolder item) {
final View view = item.itemView;
// this will trigger end callback which should set properties to their target values.
view.animate().cancel();
// TODO if some other animations are chained to end, how do we cancel them as well?
for (int i = mPendingMoves.size() - 1; i >= 0; i--) {
MoveInfo moveInfo = mPendingMoves.get(i);
if (moveInfo.holder == item) {
view.setTranslationY(0);
view.setTranslationX(0);
dispatchMoveFinished(item);
mPendingMoves.remove(i);
}
}
endChangeAnimation(mPendingChanges, item);
if (mPendingRemovals.remove(item)) {
if (view instanceof DialogCell) {
((DialogCell) view).setClipProgress(0.0f);
} else {
view.setAlpha(1);
}
dispatchRemoveFinished(item);
}
if (mPendingAdditions.remove(item)) {
if (view instanceof DialogCell) {
((DialogCell) view).setClipProgress(0.0f);
} else {
view.setAlpha(1);
}
dispatchAddFinished(item);
}
for (int i = mChangesList.size() - 1; i >= 0; i--) {
ArrayList<ChangeInfo> changes = mChangesList.get(i);
endChangeAnimation(changes, item);
if (changes.isEmpty()) {
mChangesList.remove(i);
}
}
for (int i = mMovesList.size() - 1; i >= 0; i--) {
ArrayList<MoveInfo> moves = mMovesList.get(i);
for (int j = moves.size() - 1; j >= 0; j--) {
MoveInfo moveInfo = moves.get(j);
if (moveInfo.holder == item) {
view.setTranslationY(0);
view.setTranslationX(0);
dispatchMoveFinished(item);
moves.remove(j);
if (moves.isEmpty()) {
mMovesList.remove(i);
}
break;
}
}
}
for (int i = mAdditionsList.size() - 1; i >= 0; i--) {
ArrayList<ViewHolder> additions = mAdditionsList.get(i);
if (additions.remove(item)) {
if (view instanceof DialogCell) {
((DialogCell) view).setClipProgress(1.0f);
} else {
view.setAlpha(1);
}
dispatchAddFinished(item);
if (additions.isEmpty()) {
mAdditionsList.remove(i);
}
}
}
if (mRemoveAnimations.remove(item) && DEBUG) {
throw new IllegalStateException("after animation is cancelled, item should not be in " + "mRemoveAnimations list");
}
if (mAddAnimations.remove(item) && DEBUG) {
throw new IllegalStateException("after animation is cancelled, item should not be in " + "mAddAnimations list");
}
if (mChangeAnimations.remove(item) && DEBUG) {
throw new IllegalStateException("after animation is cancelled, item should not be in " + "mChangeAnimations list");
}
if (mMoveAnimations.remove(item) && DEBUG) {
throw new IllegalStateException("after animation is cancelled, item should not be in " + "mMoveAnimations list");
}
dispatchFinishedWhenDone();
}
use of org.telegram.ui.Cells.DialogCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class DialogsItemAnimator method animateRemoveImpl.
private void animateRemoveImpl(final ViewHolder holder) {
final View view = holder.itemView;
mRemoveAnimations.add(holder);
if (view instanceof DialogCell) {
DialogCell dialogCell = (DialogCell) view;
if (view == removingDialog) {
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);
}
if (Build.VERSION.SDK_INT >= 21) {
dialogCell.setElevation(-1);
dialogCell.setOutlineProvider(null);
}
final ObjectAnimator animator = ObjectAnimator.ofFloat(dialogCell, AnimationProperties.CLIP_DIALOG_CELL_PROGRESS, 1.0f).setDuration(deleteDuration);
animator.setInterpolator(sDefaultInterpolator);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animator) {
dispatchRemoveStarting(holder);
}
@Override
public void onAnimationEnd(Animator animator) {
animator.removeAllListeners();
dialogCell.setClipProgress(0.0f);
if (Build.VERSION.SDK_INT >= 21) {
dialogCell.setElevation(0);
}
dispatchRemoveFinished(holder);
mRemoveAnimations.remove(holder);
dispatchFinishedWhenDone();
}
});
animator.start();
} else {
final ObjectAnimator animator = ObjectAnimator.ofFloat(dialogCell, View.ALPHA, 1.0f).setDuration(deleteDuration);
animator.setInterpolator(sDefaultInterpolator);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animator) {
dispatchRemoveStarting(holder);
}
@Override
public void onAnimationEnd(Animator animator) {
animator.removeAllListeners();
dialogCell.setClipProgress(0.0f);
if (Build.VERSION.SDK_INT >= 21) {
dialogCell.setElevation(0);
}
dispatchRemoveFinished(holder);
mRemoveAnimations.remove(holder);
dispatchFinishedWhenDone();
}
});
animator.start();
}
} else {
final ViewPropertyAnimator animation = view.animate();
animation.setDuration(deleteDuration).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);
dispatchRemoveFinished(holder);
mRemoveAnimations.remove(holder);
dispatchFinishedWhenDone();
}
}).start();
}
}
use of org.telegram.ui.Cells.DialogCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class DialogsItemAnimator method animateRemove.
@Override
public boolean animateRemove(final ViewHolder holder, ItemHolderInfo info) {
resetAnimation(holder);
mPendingRemovals.add(holder);
int top = Integer.MIN_VALUE;
DialogCell bottomView = null;
for (int i = 0; i < listView.getChildCount(); i++) {
View view = listView.getChildAt(i);
if (view.getTop() > top && view instanceof DialogCell) {
bottomView = (DialogCell) view;
}
}
if (holder.itemView == bottomView) {
removingDialog = bottomView;
}
return true;
}
use of org.telegram.ui.Cells.DialogCell 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();
}
Aggregations