use of android.view.ViewPropertyAnimator in project mTHMMY by ThmmyNoLife.
the class EditorView method showMarkdown.
/**
* Animates the showing of the markdown options.
*/
public void showMarkdown() {
if (formatButtonsRecyclerview.getVisibility() == VISIBLE)
return;
ViewPropertyAnimator animator = formatButtonsRecyclerview.animate().translationY(0).setInterpolator(new FastOutSlowInInterpolator()).setDuration(ANIMATION_DURATION);
animator.setListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
formatButtonsRecyclerview.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationEnd(Animator animator) {
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
animator.start();
}
use of android.view.ViewPropertyAnimator in project Telegram-FOSS by Telegram-FOSS-Team.
the class ActionBar method setTitleOverlayText.
public void setTitleOverlayText(String title, int titleId, Runnable action) {
if (!allowOverlayTitle || parentFragment.parentLayout == null) {
return;
}
overlayTitleToSet[0] = title;
overlayTitleToSet[1] = titleId;
overlayTitleToSet[2] = action;
if (overlayTitleAnimationInProgress) {
return;
}
if (lastOverlayTitle == null && title == null || (lastOverlayTitle != null && lastOverlayTitle.equals(title))) {
return;
}
lastOverlayTitle = title;
CharSequence textToSet = title != null ? LocaleController.getString(title, titleId) : lastTitle;
boolean ellipsize = false;
if (title != null) {
int index = TextUtils.indexOf(textToSet, "...");
if (index >= 0) {
SpannableString spannableString = SpannableString.valueOf(textToSet);
ellipsizeSpanAnimator.wrap(spannableString, index);
textToSet = spannableString;
ellipsize = true;
}
}
titleOverlayShown = title != null;
if ((textToSet != null && titleTextView[0] == null) || getMeasuredWidth() == 0 || (titleTextView[0] != null && titleTextView[0].getVisibility() != View.VISIBLE)) {
createTitleTextView(0);
if (supportsHolidayImage) {
titleTextView[0].invalidate();
invalidate();
}
titleTextView[0].setText(textToSet);
if (ellipsize) {
ellipsizeSpanAnimator.addView(titleTextView[0]);
} else {
ellipsizeSpanAnimator.removeView(titleTextView[0]);
}
} else if (titleTextView[0] != null) {
titleTextView[0].animate().cancel();
if (titleTextView[1] != null) {
titleTextView[1].animate().cancel();
}
if (titleTextView[1] == null) {
createTitleTextView(1);
}
titleTextView[1].setText(textToSet);
if (ellipsize) {
ellipsizeSpanAnimator.addView(titleTextView[1]);
}
overlayTitleAnimationInProgress = true;
SimpleTextView tmp = titleTextView[1];
titleTextView[1] = titleTextView[0];
titleTextView[0] = tmp;
titleTextView[0].setAlpha(0);
titleTextView[0].setTranslationY(-AndroidUtilities.dp(20));
titleTextView[0].animate().alpha(1f).translationY(0).setDuration(220).start();
ViewPropertyAnimator animator = titleTextView[1].animate().alpha(0);
if (subtitleTextView == null) {
animator.translationY(AndroidUtilities.dp(20));
} else {
animator.scaleY(0.7f).scaleX(0.7f);
}
requestLayout();
centerScale = true;
animator.setDuration(220).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (titleTextView[1] != null && titleTextView[1].getParent() != null) {
ViewGroup viewGroup = (ViewGroup) titleTextView[1].getParent();
viewGroup.removeView(titleTextView[1]);
}
ellipsizeSpanAnimator.removeView(titleTextView[1]);
titleTextView[1] = null;
overlayTitleAnimationInProgress = false;
setTitleOverlayText((String) overlayTitleToSet[0], (int) overlayTitleToSet[1], (Runnable) overlayTitleToSet[2]);
}
}).start();
}
titleActionRunnable = action != null ? action : lastRunnable;
}
use of android.view.ViewPropertyAnimator in project Telegram-FOSS by Telegram-FOSS-Team.
the class ActionBar method setTitleAnimated.
public void setTitleAnimated(CharSequence title, boolean fromBottom, long duration) {
if (titleTextView[0] == null || title == null) {
setTitle(title);
return;
}
boolean crossfade = overlayTitleAnimation && !TextUtils.isEmpty(subtitle);
if (crossfade) {
if (subtitleTextView.getVisibility() != View.VISIBLE) {
subtitleTextView.setVisibility(View.VISIBLE);
subtitleTextView.setAlpha(0);
}
subtitleTextView.animate().alpha(fromBottom ? 0 : 1f).setDuration(220).start();
}
if (titleTextView[1] != null) {
if (titleTextView[1].getParent() != null) {
ViewGroup viewGroup = (ViewGroup) titleTextView[1].getParent();
viewGroup.removeView(titleTextView[1]);
}
titleTextView[1] = null;
}
titleTextView[1] = titleTextView[0];
titleTextView[0] = null;
setTitle(title);
this.fromBottom = fromBottom;
titleTextView[0].setAlpha(0);
if (!crossfade) {
titleTextView[0].setTranslationY(fromBottom ? AndroidUtilities.dp(20) : -AndroidUtilities.dp(20));
}
titleTextView[0].animate().alpha(1f).translationY(0).setDuration(duration).start();
titleAnimationRunning = true;
ViewPropertyAnimator a = titleTextView[1].animate().alpha(0);
if (!crossfade) {
a.translationY(fromBottom ? -AndroidUtilities.dp(20) : AndroidUtilities.dp(20));
}
a.setDuration(duration).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (titleTextView[1] != null && titleTextView[1].getParent() != null) {
ViewGroup viewGroup = (ViewGroup) titleTextView[1].getParent();
viewGroup.removeView(titleTextView[1]);
}
titleTextView[1] = null;
titleAnimationRunning = false;
if (crossfade && fromBottom) {
subtitleTextView.setVisibility(View.GONE);
}
requestLayout();
}
}).start();
requestLayout();
}
use of android.view.ViewPropertyAnimator 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 android.view.ViewPropertyAnimator 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();
}
}
Aggregations