Search in sources :

Example 21 with BaseFragment

use of org.telegram.ui.ActionBar.BaseFragment in project Telegram-FOSS by Telegram-FOSS-Team.

the class ChatActivity method migrateToNewChat.

private void migrateToNewChat(MessageObject obj) {
    if (parentLayout == null) {
        return;
    }
    final long channelId = obj.messageOwner.action.channel_id;
    final BaseFragment lastFragment = parentLayout.fragmentsStack.size() > 0 ? parentLayout.fragmentsStack.get(parentLayout.fragmentsStack.size() - 1) : null;
    int index = parentLayout.fragmentsStack.indexOf(ChatActivity.this);
    final ActionBarLayout actionBarLayout = parentLayout;
    if (index > 0 && !(lastFragment instanceof ChatActivity) && !(lastFragment instanceof ProfileActivity) && currentChat.creator) {
        for (int a = index, N = actionBarLayout.fragmentsStack.size() - 1; a < N; a++) {
            BaseFragment fragment = actionBarLayout.fragmentsStack.get(a);
            if (fragment instanceof ChatActivity) {
                final Bundle bundle = new Bundle();
                bundle.putLong("chat_id", channelId);
                actionBarLayout.addFragmentToStack(new ChatActivity(bundle), a);
                fragment.removeSelfFromStack();
            } else if (fragment instanceof ProfileActivity) {
                Bundle args = new Bundle();
                args.putLong("chat_id", channelId);
                actionBarLayout.addFragmentToStack(new ProfileActivity(args), a);
                fragment.removeSelfFromStack();
            } else if (fragment instanceof ChatEditActivity) {
                Bundle args = new Bundle();
                args.putLong("chat_id", channelId);
                actionBarLayout.addFragmentToStack(new ChatEditActivity(args), a);
                fragment.removeSelfFromStack();
            } else if (fragment instanceof ChatUsersActivity) {
                ChatUsersActivity usersActivity = (ChatUsersActivity) fragment;
                if (!usersActivity.hasSelectType()) {
                    Bundle args = fragment.getArguments();
                    args.putLong("chat_id", channelId);
                    actionBarLayout.addFragmentToStack(new ChatUsersActivity(args), a);
                }
                fragment.removeSelfFromStack();
            }
        }
    } else {
        AndroidUtilities.runOnUIThread(() -> {
            if (lastFragment instanceof NotificationCenter.NotificationCenterDelegate) {
                getNotificationCenter().removeObserver((NotificationCenter.NotificationCenterDelegate) lastFragment, NotificationCenter.closeChats);
            }
            getNotificationCenter().postNotificationName(NotificationCenter.closeChats);
            final Bundle bundle = new Bundle();
            bundle.putLong("chat_id", obj.messageOwner.action.channel_id);
            actionBarLayout.addFragmentToStack(new ChatActivity(bundle), actionBarLayout.fragmentsStack.size() - 1);
            lastFragment.finishFragment();
        });
    }
    AndroidUtilities.runOnUIThread(() -> getMessagesController().loadFullChat(channelId, 0, true), 1000);
}
Also used : Bundle(android.os.Bundle) NotificationCenter(org.telegram.messenger.NotificationCenter) ActionBarLayout(org.telegram.ui.ActionBar.ActionBarLayout) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) Paint(android.graphics.Paint) TextSelectionHint(org.telegram.ui.Components.TextSelectionHint) TextPaint(android.text.TextPaint) SuppressLint(android.annotation.SuppressLint)

Example 22 with BaseFragment

use of org.telegram.ui.ActionBar.BaseFragment in project Telegram-FOSS by Telegram-FOSS-Team.

the class ChatActivity method onCustomTransitionAnimation.

@Override
protected AnimatorSet onCustomTransitionAnimation(boolean isOpen, Runnable callback) {
    if (isOpen && fromPullingDownTransition && getParentLayout().fragmentsStack.size() > 1) {
        BaseFragment previousFragment = getParentLayout().fragmentsStack.get(getParentLayout().fragmentsStack.size() - 2);
        if (previousFragment instanceof ChatActivity) {
            ChatActivity previousChat = (ChatActivity) previousFragment;
            previousChat.setTransitionToChatActivity(this);
            fragmentView.setAlpha(0);
            contentView.setSkipBackgroundDrawing(true);
            avatarContainer.setTranslationY(AndroidUtilities.dp(8));
            avatarContainer.getAvatarImageView().setAlpha(0);
            avatarContainer.getAvatarImageView().setTranslationY(-AndroidUtilities.dp(8));
            toPullingDownTransition = true;
            ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1f);
            boolean useAlphaForContextView = previousChat.fragmentContextView.getMeasuredHeight() != fragmentContextView.getMeasuredHeight();
            valueAnimator.addUpdateListener(valueAnimator1 -> {
                float progress = (float) valueAnimator1.getAnimatedValue();
                previousChat.setTransitionToChatProgress(progress);
                float y = AndroidUtilities.dp(8) * (1f - progress);
                avatarContainer.setTranslationY(y);
                avatarContainer.getAvatarImageView().setTranslationY(-y);
                y = -AndroidUtilities.dp(8) * progress;
                previousChat.avatarContainer.setTranslationY(y);
                previousChat.avatarContainer.getAvatarImageView().setTranslationY(-y);
                avatarContainer.getAvatarImageView().setScaleX(0.8f + 0.2f * progress);
                avatarContainer.getAvatarImageView().setScaleY(0.8f + 0.2f * progress);
                avatarContainer.getAvatarImageView().setAlpha(progress);
                previousChat.avatarContainer.getAvatarImageView().setScaleX(0.8f + 0.2f * (1f - progress));
                previousChat.avatarContainer.getAvatarImageView().setScaleY(0.8f + 0.2f * (1f - progress));
                previousChat.avatarContainer.getAvatarImageView().setAlpha(1f - progress);
                if (useAlphaForContextView) {
                    previousChat.fragmentContextView.setAlpha(1f - progress);
                }
                previousChat.pinnedMessageView.setAlpha(1f - progress);
                previousChat.topChatPanelView.setAlpha(1f - progress);
            });
            updateChatListViewTopPadding();
            fragmentTransition = new AnimatorSet();
            fragmentTransition.addListener(new AnimatorListenerAdapter() {

                int index;

                @Override
                public void onAnimationStart(Animator animation) {
                    super.onAnimationStart(animation);
                    index = NotificationCenter.getInstance(currentAccount).setAnimationInProgress(index, null);
                }

                @Override
                public void onAnimationEnd(Animator animation) {
                    fragmentTransition = null;
                    NotificationCenter.getInstance(currentAccount).onAnimationFinish(index);
                    super.onAnimationEnd(animation);
                    contentView.invalidate();
                    contentView.setSkipBackgroundDrawing(false);
                    toPullingDownTransition = false;
                    previousChat.setTransitionToChatProgress(0);
                    previousChat.setTransitionToChatActivity(null);
                    fragmentView.setAlpha(1f);
                    callback.run();
                    avatarContainer.setTranslationY(0);
                    previousChat.avatarContainer.setTranslationY(0);
                    previousChat.avatarContainer.getAvatarImageView().setTranslationY(0);
                    avatarContainer.getAvatarImageView().setScaleX(1f);
                    avatarContainer.getAvatarImageView().setScaleY(1f);
                    avatarContainer.getAvatarImageView().setAlpha(1f);
                    previousChat.avatarContainer.getAvatarImageView().setScaleX(1f);
                    previousChat.avatarContainer.getAvatarImageView().setScaleY(1f);
                    previousChat.avatarContainer.getAvatarImageView().setAlpha(1f);
                    previousChat.pinnedMessageView.setAlpha(1f);
                    previousChat.topChatPanelView.setAlpha(1f);
                }
            });
            fragmentTransition.setDuration(300);
            fragmentTransition.setInterpolator(CubicBezierInterpolator.DEFAULT);
            fragmentTransition.playTogether(valueAnimator);
            AndroidUtilities.runOnUIThread(fragmentTransitionRunnable, 200);
            return fragmentTransition;
        }
    }
    return null;
}
Also used : Animator(android.animation.Animator) ChatListItemAnimator(androidx.recyclerview.widget.ChatListItemAnimator) ValueAnimator(android.animation.ValueAnimator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorSet(android.animation.AnimatorSet) ValueAnimator(android.animation.ValueAnimator) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) Paint(android.graphics.Paint) TextSelectionHint(org.telegram.ui.Components.TextSelectionHint) TextPaint(android.text.TextPaint) SuppressLint(android.annotation.SuppressLint)

Example 23 with BaseFragment

use of org.telegram.ui.ActionBar.BaseFragment in project Telegram-FOSS by Telegram-FOSS-Team.

the class ChatActivity method onTransitionAnimationEnd.

@Override
public void onTransitionAnimationEnd(boolean isOpen, boolean backward) {
    super.onTransitionAnimationEnd(isOpen, backward);
    if (isOpen) {
        if (backward) {
            if (showPinBulletin && pinBulletin != null) {
                pinBulletin.show();
                showPinBulletin = false;
            }
        }
    }
    if (cancelFixedPositionRunnable != null) {
        AndroidUtilities.cancelRunOnUIThread(cancelFixedPositionRunnable);
    }
    fixedKeyboardHeight = -1;
    if (isOpen) {
        checkShowBlur(false);
        openAnimationEnded = true;
        getNotificationCenter().onAnimationFinish(transitionAnimationIndex);
        if (Build.VERSION.SDK_INT >= 21) {
            createChatAttachView();
        }
        checkGroupCallJoin(lastCallCheckFromServer);
        if (chatActivityEnterView.hasRecordVideo() && !chatActivityEnterView.isSendButtonVisible()) {
            boolean isChannel = false;
            if (currentChat != null) {
                isChannel = ChatObject.isChannel(currentChat) && !currentChat.megagroup;
            }
            SharedPreferences preferences = MessagesController.getGlobalMainSettings();
            String key = isChannel ? "needShowRoundHintChannel2" : "needShowRoundHint2";
            int showCount = preferences.getInt(key, 0);
            if (showCount < 3) {
                if (Utilities.random.nextFloat() <= 0.2f) {
                    showVoiceHint(false, chatActivityEnterView.isInVideoMode());
                    preferences.edit().putInt(key, ++showCount).commit();
                }
            }
        }
        if (!backward && parentLayout != null && needRemovePreviousSameChatActivity) {
            for (int a = 0, N = parentLayout.fragmentsStack.size() - 1; a < N; a++) {
                BaseFragment fragment = parentLayout.fragmentsStack.get(a);
                if (fragment != this && fragment instanceof ChatActivity) {
                    ChatActivity chatActivity = (ChatActivity) fragment;
                    if (chatActivity.needRemovePreviousSameChatActivity && chatActivity.dialog_id == dialog_id && chatActivity.getChatMode() == getChatMode() && chatActivity.threadMessageId == threadMessageId && chatActivity.reportType == reportType) {
                        fragment.removeSelfFromStack();
                        break;
                    }
                }
            }
        }
        showScheduledOrNoSoundHint();
        if (!backward && firstOpen) {
            if (chatActivityEnterView != null && threadMessageObject != null && threadMessageObject.getRepliesCount() == 0 && ChatObject.canSendMessages(currentChat)) {
                chatActivityEnterView.setFieldFocused();
                chatActivityEnterView.openKeyboard();
            }
            if (getMessagesController().isPromoDialog(dialog_id, true)) {
                int type = getMessagesController().promoDialogType;
                String message;
                SharedPreferences preferences = MessagesController.getGlobalNotificationsSettings();
                boolean check;
                if (type == MessagesController.PROMO_TYPE_PROXY) {
                    if (AndroidUtilities.getPrefIntOrLong(preferences, "proxychannel", 0) != dialog_id) {
                        message = LocaleController.getString("UseProxySponsorInfo", R.string.UseProxySponsorInfo);
                    } else {
                        message = null;
                    }
                } else if (type == MessagesController.PROMO_TYPE_PSA) {
                    String psaType = getMessagesController().promoPsaType;
                    if (!preferences.getBoolean(psaType + "_shown", false)) {
                        message = LocaleController.getString("PsaInfo_" + psaType);
                        if (TextUtils.isEmpty(message)) {
                            message = LocaleController.getString("PsaInfoDefault", R.string.PsaInfoDefault);
                        }
                    } else {
                        message = null;
                    }
                } else {
                    message = null;
                }
                if (!TextUtils.isEmpty(message)) {
                    if (topUndoView != null) {
                        if (type == MessagesController.PROMO_TYPE_PROXY) {
                            preferences.edit().putLong("proxychannel", dialog_id).commit();
                        } else if (type == MessagesController.PROMO_TYPE_PSA) {
                            String psaType = getMessagesController().promoPsaType;
                            preferences.edit().putBoolean(psaType + "_shown", true).commit();
                        }
                        SpannableStringBuilder stringBuilder = new SpannableStringBuilder(message);
                        MessageObject.addLinks(false, stringBuilder);
                        topUndoView.showWithAction(0, UndoView.ACTION_TEXT_INFO, stringBuilder, null, null);
                    }
                }
            }
            firstOpen = false;
        }
        if (!backward && fromPullingDownTransition && parentLayout != null && parentLayout.fragmentsStack.size() >= 2) {
            BaseFragment fragment = parentLayout.fragmentsStack.get(parentLayout.fragmentsStack.size() - 2);
            if (fragment instanceof ChatActivity) {
                backToPreviousFragment = (ChatActivity) fragment;
                parentLayout.fragmentsStack.remove(backToPreviousFragment);
            }
        }
        if (pendingRequestsDelegate != null && backward) {
            pendingRequestsDelegate.onBackToScreen();
        }
        updateMessagesVisiblePart(false);
    } else {
        getNotificationCenter().onAnimationFinish(transitionAnimationIndex);
    }
    contentView.invalidate();
}
Also used : SharedPreferences(android.content.SharedPreferences) SpannableString(android.text.SpannableString) Paint(android.graphics.Paint) TextSelectionHint(org.telegram.ui.Components.TextSelectionHint) TextPaint(android.text.TextPaint) SuppressLint(android.annotation.SuppressLint) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) SpannableStringBuilder(android.text.SpannableStringBuilder)

Example 24 with BaseFragment

use of org.telegram.ui.ActionBar.BaseFragment in project Telegram-FOSS by Telegram-FOSS-Team.

the class ContactsActivity method onCustomTransitionAnimation.

@Override
protected AnimatorSet onCustomTransitionAnimation(boolean isOpen, Runnable callback) {
    ValueAnimator valueAnimator = isOpen ? ValueAnimator.ofFloat(1f, 0) : ValueAnimator.ofFloat(0, 1f);
    ViewGroup parent = (ViewGroup) fragmentView.getParent();
    BaseFragment previousFragment = parentLayout.fragmentsStack.size() > 1 ? parentLayout.fragmentsStack.get(parentLayout.fragmentsStack.size() - 2) : null;
    DialogsActivity dialogsActivity = null;
    if (previousFragment instanceof DialogsActivity) {
        dialogsActivity = (DialogsActivity) previousFragment;
    }
    if (dialogsActivity == null) {
        return null;
    }
    RLottieImageView previousFab = dialogsActivity.getFloatingButton();
    View previousFabContainer = null;
    if (previousFab.getParent() != null) {
        previousFabContainer = (View) previousFab.getParent();
    }
    if (floatingButtonContainer == null || previousFabContainer == null || previousFab.getVisibility() != View.VISIBLE || Math.abs(previousFabContainer.getTranslationY()) > AndroidUtilities.dp(4) || Math.abs(floatingButtonContainer.getTranslationY()) > AndroidUtilities.dp(4)) {
        return null;
    }
    previousFab.setVisibility(View.GONE);
    if (isOpen) {
        parent.setAlpha(0f);
    }
    valueAnimator.addUpdateListener(valueAnimator1 -> {
        float v = (float) valueAnimator.getAnimatedValue();
        parent.setTranslationX(AndroidUtilities.dp(48) * v);
        parent.setAlpha(1f - v);
    });
    if (floatingButtonContainer != null) {
        ((ViewGroup) fragmentView).removeView(floatingButtonContainer);
        ((FrameLayout) parent.getParent()).addView(floatingButtonContainer);
    }
    valueAnimator.setDuration(150);
    valueAnimator.setInterpolator(new DecelerateInterpolator(1.5f));
    final int currentAccount = this.currentAccount;
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            if (floatingButtonContainer != null) {
                ViewGroup viewParent;
                if (floatingButtonContainer.getParent() instanceof ViewGroup) {
                    viewParent = (ViewGroup) floatingButtonContainer.getParent();
                    viewParent.removeView(floatingButtonContainer);
                }
                ((ViewGroup) fragmentView).addView(floatingButtonContainer);
                previousFab.setVisibility(View.VISIBLE);
                if (!isOpen) {
                    previousFab.setAnimation(R.raw.write_contacts_fab_icon_reverse, 52, 52);
                    previousFab.getAnimatedDrawable().setCurrentFrame(floatingButton.getAnimatedDrawable().getCurrentFrame());
                    previousFab.playAnimation();
                }
            }
            callback.run();
        }
    });
    animatorSet.playTogether(valueAnimator);
    AndroidUtilities.runOnUIThread(() -> {
        animationIndex = getNotificationCenter().setAnimationInProgress(animationIndex, null);
        animatorSet.start();
        if (isOpen) {
            floatingButton.setAnimation(R.raw.write_contacts_fab_icon, 52, 52);
            floatingButton.playAnimation();
        } else {
            floatingButton.setAnimation(R.raw.write_contacts_fab_icon_reverse, 52, 52);
            floatingButton.playAnimation();
        }
        if (bounceIconAnimator != null) {
            bounceIconAnimator.cancel();
        }
        bounceIconAnimator = new AnimatorSet();
        float totalDuration = floatingButton.getAnimatedDrawable().getDuration();
        long delay = 0;
        if (isOpen) {
            for (int i = 0; i < 6; i++) {
                AnimatorSet set = new AnimatorSet();
                if (i == 0) {
                    set.playTogether(ObjectAnimator.ofFloat(floatingButton, View.SCALE_X, 1f, 0.9f), ObjectAnimator.ofFloat(floatingButton, View.SCALE_Y, 1f, 0.9f), ObjectAnimator.ofFloat(previousFab, View.SCALE_X, 1f, 0.9f), ObjectAnimator.ofFloat(previousFab, View.SCALE_Y, 1f, 0.9f));
                    set.setDuration((long) (6f / 47f * totalDuration));
                    set.setInterpolator(CubicBezierInterpolator.EASE_OUT);
                } else if (i == 1) {
                    set.playTogether(ObjectAnimator.ofFloat(floatingButton, View.SCALE_X, 0.9f, 1.06f), ObjectAnimator.ofFloat(floatingButton, View.SCALE_Y, 0.9f, 1.06f), ObjectAnimator.ofFloat(previousFab, View.SCALE_X, 0.9f, 1.06f), ObjectAnimator.ofFloat(previousFab, View.SCALE_Y, 0.9f, 1.06f));
                    set.setDuration((long) (17f / 47f * totalDuration));
                    set.setInterpolator(CubicBezierInterpolator.EASE_BOTH);
                } else if (i == 2) {
                    set.playTogether(ObjectAnimator.ofFloat(floatingButton, View.SCALE_X, 1.06f, 0.9f), ObjectAnimator.ofFloat(floatingButton, View.SCALE_Y, 1.06f, 0.9f), ObjectAnimator.ofFloat(previousFab, View.SCALE_X, 1.06f, 0.9f), ObjectAnimator.ofFloat(previousFab, View.SCALE_Y, 1.06f, 0.9f));
                    set.setDuration((long) (10f / 47f * totalDuration));
                    set.setInterpolator(CubicBezierInterpolator.EASE_BOTH);
                } else if (i == 3) {
                    set.playTogether(ObjectAnimator.ofFloat(floatingButton, View.SCALE_X, 0.9f, 1.03f), ObjectAnimator.ofFloat(floatingButton, View.SCALE_Y, 0.9f, 1.03f), ObjectAnimator.ofFloat(previousFab, View.SCALE_X, 0.9f, 1.03f), ObjectAnimator.ofFloat(previousFab, View.SCALE_Y, 0.9f, 1.03f));
                    set.setDuration((long) (5f / 47f * totalDuration));
                    set.setInterpolator(CubicBezierInterpolator.EASE_BOTH);
                } else if (i == 4) {
                    set.playTogether(ObjectAnimator.ofFloat(floatingButton, View.SCALE_X, 1.03f, 0.98f), ObjectAnimator.ofFloat(floatingButton, View.SCALE_Y, 1.03f, 0.98f), ObjectAnimator.ofFloat(previousFab, View.SCALE_X, 1.03f, 0.98f), ObjectAnimator.ofFloat(previousFab, View.SCALE_Y, 1.03f, 0.98f));
                    set.setDuration((long) (5f / 47f * totalDuration));
                    set.setInterpolator(CubicBezierInterpolator.EASE_BOTH);
                } else {
                    set.playTogether(ObjectAnimator.ofFloat(floatingButton, View.SCALE_X, 0.98f, 1f), ObjectAnimator.ofFloat(floatingButton, View.SCALE_Y, 0.98f, 1f), ObjectAnimator.ofFloat(previousFab, View.SCALE_X, 0.98f, 1f), ObjectAnimator.ofFloat(previousFab, View.SCALE_Y, 0.98f, 1f));
                    set.setDuration((long) (4f / 47f * totalDuration));
                    set.setInterpolator(CubicBezierInterpolator.EASE_IN);
                }
                set.setStartDelay(delay);
                delay += set.getDuration();
                bounceIconAnimator.playTogether(set);
            }
        } else {
            for (int i = 0; i < 5; i++) {
                AnimatorSet set = new AnimatorSet();
                if (i == 0) {
                    set.playTogether(ObjectAnimator.ofFloat(floatingButton, View.SCALE_X, 1f, 0.9f), ObjectAnimator.ofFloat(floatingButton, View.SCALE_Y, 1f, 0.9f), ObjectAnimator.ofFloat(previousFab, View.SCALE_X, 1f, 0.9f), ObjectAnimator.ofFloat(previousFab, View.SCALE_Y, 1f, 0.9f));
                    set.setDuration((long) (7f / 36f * totalDuration));
                    set.setInterpolator(CubicBezierInterpolator.EASE_OUT);
                } else if (i == 1) {
                    set.playTogether(ObjectAnimator.ofFloat(floatingButton, View.SCALE_X, 0.9f, 1.06f), ObjectAnimator.ofFloat(floatingButton, View.SCALE_Y, 0.9f, 1.06f), ObjectAnimator.ofFloat(previousFab, View.SCALE_X, 0.9f, 1.06f), ObjectAnimator.ofFloat(previousFab, View.SCALE_Y, 0.9f, 1.06f));
                    set.setDuration((long) (8f / 36f * totalDuration));
                    set.setInterpolator(CubicBezierInterpolator.EASE_BOTH);
                } else if (i == 2) {
                    set.playTogether(ObjectAnimator.ofFloat(floatingButton, View.SCALE_X, 1.06f, 0.92f), ObjectAnimator.ofFloat(floatingButton, View.SCALE_Y, 1.06f, 0.92f), ObjectAnimator.ofFloat(previousFab, View.SCALE_X, 1.06f, 0.92f), ObjectAnimator.ofFloat(previousFab, View.SCALE_Y, 1.06f, 0.92f));
                    set.setDuration((long) (7f / 36f * totalDuration));
                    set.setInterpolator(CubicBezierInterpolator.EASE_BOTH);
                } else if (i == 3) {
                    set.playTogether(ObjectAnimator.ofFloat(floatingButton, View.SCALE_X, 0.92f, 1.02f), ObjectAnimator.ofFloat(floatingButton, View.SCALE_Y, 0.92f, 1.02f), ObjectAnimator.ofFloat(previousFab, View.SCALE_X, 0.92f, 1.02f), ObjectAnimator.ofFloat(previousFab, View.SCALE_Y, 0.92f, 1.02f));
                    set.setDuration((long) (9f / 36f * totalDuration));
                    set.setInterpolator(CubicBezierInterpolator.EASE_BOTH);
                } else {
                    set.playTogether(ObjectAnimator.ofFloat(floatingButton, View.SCALE_X, 1.02f, 1f), ObjectAnimator.ofFloat(floatingButton, View.SCALE_Y, 1.02f, 1f), ObjectAnimator.ofFloat(previousFab, View.SCALE_X, 1.02f, 1f), ObjectAnimator.ofFloat(previousFab, View.SCALE_Y, 1.02f, 1f));
                    set.setDuration((long) (5f / 47f * totalDuration));
                    set.setInterpolator(CubicBezierInterpolator.EASE_IN);
                }
                set.setStartDelay(delay);
                delay += set.getDuration();
                bounceIconAnimator.playTogether(set);
            }
        }
        bounceIconAnimator.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                floatingButton.setScaleX(1f);
                floatingButton.setScaleY(1f);
                previousFab.setScaleX(1f);
                previousFab.setScaleY(1f);
                bounceIconAnimator = null;
                getNotificationCenter().onAnimationFinish(animationIndex);
            }
        });
        bounceIconAnimator.start();
    }, 50);
    return animatorSet;
}
Also used : AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ViewGroup(android.view.ViewGroup) RLottieImageView(org.telegram.ui.Components.RLottieImageView) AnimatorSet(android.animation.AnimatorSet) ValueAnimator(android.animation.ValueAnimator) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) RLottieImageView(org.telegram.ui.Components.RLottieImageView) StickerEmptyView(org.telegram.ui.Components.StickerEmptyView) FlickerLoadingView(org.telegram.ui.Components.FlickerLoadingView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) Animator(android.animation.Animator) StateListAnimator(android.animation.StateListAnimator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) FrameLayout(android.widget.FrameLayout)

Example 25 with BaseFragment

use of org.telegram.ui.ActionBar.BaseFragment in project Telegram-FOSS by Telegram-FOSS-Team.

the class AndroidUtilities method scrollToFragmentRow.

public static void scrollToFragmentRow(ActionBarLayout parentLayout, String rowName) {
    if (parentLayout == null || rowName == null) {
        return;
    }
    BaseFragment openingFragment = parentLayout.fragmentsStack.get(parentLayout.fragmentsStack.size() - 1);
    try {
        Field listViewField = openingFragment.getClass().getDeclaredField("listView");
        listViewField.setAccessible(true);
        RecyclerListView listView = (RecyclerListView) listViewField.get(openingFragment);
        RecyclerListView.IntReturnCallback callback = () -> {
            int position = -1;
            try {
                Field rowField = openingFragment.getClass().getDeclaredField(rowName);
                rowField.setAccessible(true);
                LinearLayoutManager layoutManager = (LinearLayoutManager) listView.getLayoutManager();
                position = rowField.getInt(openingFragment);
                layoutManager.scrollToPositionWithOffset(position, AndroidUtilities.dp(60));
                rowField.setAccessible(false);
                return position;
            } catch (Throwable ignore) {
            }
            return position;
        };
        listView.highlightRow(callback);
        listViewField.setAccessible(false);
    } catch (Throwable ignore) {
    }
}
Also used : Field(java.lang.reflect.Field) RecyclerListView(org.telegram.ui.Components.RecyclerListView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) BaseFragment(org.telegram.ui.ActionBar.BaseFragment)

Aggregations

BaseFragment (org.telegram.ui.ActionBar.BaseFragment)46 Paint (android.graphics.Paint)25 Bundle (android.os.Bundle)18 TLRPC (org.telegram.tgnet.TLRPC)18 FrameLayout (android.widget.FrameLayout)17 ArrayList (java.util.ArrayList)17 SuppressLint (android.annotation.SuppressLint)16 View (android.view.View)15 TextView (android.widget.TextView)15 Animator (android.animation.Animator)14 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)14 ObjectAnimator (android.animation.ObjectAnimator)14 SharedPreferences (android.content.SharedPreferences)14 Canvas (android.graphics.Canvas)14 RecyclerView (androidx.recyclerview.widget.RecyclerView)14 Context (android.content.Context)13 Intent (android.content.Intent)13 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)13 TLObject (org.telegram.tgnet.TLObject)13 AlertDialog (org.telegram.ui.ActionBar.AlertDialog)13