Search in sources :

Example 1 with HideViewAfterAnimation

use of org.telegram.ui.Components.HideViewAfterAnimation in project Telegram-FOSS by Telegram-FOSS-Team.

the class AndroidUtilities method updateViewVisibilityAnimated.

public static void updateViewVisibilityAnimated(View view, boolean show, float scaleFactor, boolean animated) {
    if (view.getParent() == null) {
        animated = false;
    }
    if (!animated) {
        view.animate().setListener(null).cancel();
        view.setVisibility(show ? View.VISIBLE : View.GONE);
        view.setTag(show ? 1 : null);
        view.setAlpha(1f);
        view.setScaleX(1f);
        view.setScaleY(1f);
    } else if (show && view.getTag() == null) {
        view.animate().setListener(null).cancel();
        if (view.getVisibility() != View.VISIBLE) {
            view.setVisibility(View.VISIBLE);
            view.setAlpha(0f);
            view.setScaleX(scaleFactor);
            view.setScaleY(scaleFactor);
        }
        view.animate().alpha(1f).scaleY(1f).scaleX(1f).setDuration(150).start();
        view.setTag(1);
    } else if (!show && view.getTag() != null) {
        view.animate().setListener(null).cancel();
        view.animate().alpha(0).scaleY(scaleFactor).scaleX(scaleFactor).setListener(new HideViewAfterAnimation(view)).setDuration(150).start();
        view.setTag(null);
    }
}
Also used : HideViewAfterAnimation(org.telegram.ui.Components.HideViewAfterAnimation)

Example 2 with HideViewAfterAnimation

use of org.telegram.ui.Components.HideViewAfterAnimation in project Telegram-FOSS by Telegram-FOSS-Team.

the class CalendarActivity method updateTitle.

private void updateTitle() {
    if (!canClearHistory) {
        actionBar.setTitle(LocaleController.getString("Calendar", R.string.Calendar));
        backDrawable.setRotation(0f, true);
        return;
    }
    int daysSelected;
    if (dateSelectedStart == dateSelectedEnd && dateSelectedStart == 0) {
        daysSelected = 0;
    } else {
        daysSelected = 1 + (Math.abs(dateSelectedStart - dateSelectedEnd) / 86400);
    }
    boolean oldInSelectionMode = lastInSelectionMode;
    if (daysSelected != lastDaysSelected || lastInSelectionMode != inSelectionMode) {
        boolean fromBottom = lastDaysSelected > daysSelected;
        lastDaysSelected = daysSelected;
        lastInSelectionMode = inSelectionMode;
        String title;
        if (daysSelected > 0) {
            title = LocaleController.formatPluralString("Days", daysSelected);
            backDrawable.setRotation(1f, true);
        } else if (inSelectionMode) {
            title = LocaleController.getString("SelectDays", R.string.SelectDays);
            backDrawable.setRotation(1f, true);
        } else {
            title = LocaleController.getString("Calendar", R.string.Calendar);
            backDrawable.setRotation(0f, true);
        }
        if (daysSelected > 1) {
            removeDaysButton.setText(LocaleController.formatString("ClearHistoryForTheseDays", R.string.ClearHistoryForTheseDays));
        } else if (daysSelected > 0 || inSelectionMode) {
            removeDaysButton.setText(LocaleController.formatString("ClearHistoryForThisDay", R.string.ClearHistoryForThisDay));
        }
        actionBar.setTitleAnimated(title, fromBottom, 150);
        if ((!inSelectionMode || daysSelected > 0) && selectDaysHint != null) {
            selectDaysHint.hide();
        }
        if (daysSelected > 0 || inSelectionMode) {
            if (removeDaysButton.getVisibility() == View.GONE) {
                removeDaysButton.setAlpha(0f);
                removeDaysButton.setTranslationY(-AndroidUtilities.dp(20));
            }
            removeDaysButton.setVisibility(View.VISIBLE);
            selectDaysButton.animate().setListener(null).cancel();
            removeDaysButton.animate().setListener(null).cancel();
            selectDaysButton.animate().alpha(0f).translationY(AndroidUtilities.dp(20)).setDuration(150).setListener(new HideViewAfterAnimation(selectDaysButton)).start();
            removeDaysButton.animate().alpha(daysSelected == 0 ? 0.5f : 1f).translationY(0).start();
            selectDaysButton.setEnabled(false);
            removeDaysButton.setEnabled(true);
        } else {
            if (selectDaysButton.getVisibility() == View.GONE) {
                selectDaysButton.setAlpha(0f);
                selectDaysButton.setTranslationY(AndroidUtilities.dp(20));
            }
            selectDaysButton.setVisibility(View.VISIBLE);
            selectDaysButton.animate().setListener(null).cancel();
            removeDaysButton.animate().setListener(null).cancel();
            selectDaysButton.animate().alpha(1f).translationY(0).start();
            removeDaysButton.animate().alpha(0f).translationY(-AndroidUtilities.dp(20)).setDuration(150).setListener(new HideViewAfterAnimation(removeDaysButton)).start();
            selectDaysButton.setEnabled(true);
            removeDaysButton.setEnabled(false);
        }
    }
}
Also used : HideViewAfterAnimation(org.telegram.ui.Components.HideViewAfterAnimation) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint)

Example 3 with HideViewAfterAnimation

use of org.telegram.ui.Components.HideViewAfterAnimation in project Telegram-FOSS by Telegram-FOSS-Team.

the class ChatActivity method checkShowBlur.

private void checkShowBlur(boolean animated) {
    boolean show = (parentLayout != null && parentLayout.isInPreviewMode() && !inPreviewMode) || (forwardingPreviewView != null && forwardingPreviewView.isShowing());
    if (show && (blurredView == null || blurredView.getTag() == null)) {
        if (blurredView == null) {
            blurredView = new BluredView(fragmentView.getContext(), fragmentView, themeDelegate) {

                @Override
                public void setAlpha(float alpha) {
                    super.setAlpha(alpha);
                    fragmentView.invalidate();
                }

                @Override
                public void setVisibility(int visibility) {
                    super.setVisibility(visibility);
                    fragmentView.invalidate();
                }
            };
            contentView.addView(blurredView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
        } else {
            int idx = contentView.indexOfChild(blurredView);
            if (idx != contentView.getChildCount() - 1) {
                contentView.removeView(blurredView);
                contentView.addView(blurredView);
            }
            blurredView.update();
            blurredView.setVisibility(View.VISIBLE);
        }
        blurredView.setAlpha(0.0f);
        blurredView.animate().setListener(null).cancel();
        blurredView.animate().alpha(1f).setListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                chatListView.invalidate();
                fragmentView.invalidate();
            }
        }).start();
        blurredView.setTag(1);
    } else if (!show && blurredView != null && blurredView.getTag() != null) {
        blurredView.animate().setListener(null).cancel();
        blurredView.animate().setListener(new HideViewAfterAnimation(blurredView)).alpha(0).start();
        blurredView.setTag(null);
        chatListView.invalidate();
        fragmentView.invalidate();
    }
}
Also used : Animator(android.animation.Animator) ChatListItemAnimator(androidx.recyclerview.widget.ChatListItemAnimator) ValueAnimator(android.animation.ValueAnimator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) BluredView(org.telegram.ui.Components.BluredView) HideViewAfterAnimation(org.telegram.ui.Components.HideViewAfterAnimation) Paint(android.graphics.Paint) TextSelectionHint(org.telegram.ui.Components.TextSelectionHint) TextPaint(android.text.TextPaint) SuppressLint(android.annotation.SuppressLint)

Aggregations

HideViewAfterAnimation (org.telegram.ui.Components.HideViewAfterAnimation)3 SuppressLint (android.annotation.SuppressLint)2 Paint (android.graphics.Paint)2 TextPaint (android.text.TextPaint)2 Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 ObjectAnimator (android.animation.ObjectAnimator)1 ValueAnimator (android.animation.ValueAnimator)1 ChatListItemAnimator (androidx.recyclerview.widget.ChatListItemAnimator)1 BluredView (org.telegram.ui.Components.BluredView)1 TextSelectionHint (org.telegram.ui.Components.TextSelectionHint)1