Search in sources :

Example 1 with BluredView

use of org.telegram.ui.Components.BluredView 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

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