Search in sources :

Example 6 with SlideView

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

the class LoginActivity method setPage.

public void setPage(int page, boolean animated, Bundle params, boolean back) {
    final boolean needFloatingButton = page == 0 || page == 5 || page == 6 || page == 7 || page == 9 || page == 10 || page == 11;
    if (needFloatingButton) {
        if (page == 0) {
            checkPermissions = true;
            checkShowPermissions = true;
        }
        currentDoneType = DONE_TYPE_ACTION;
        showDoneButton(false, animated);
        currentDoneType = DONE_TYPE_FLOATING;
        showEditDoneProgress(false, false);
        if (!animated) {
            showDoneButton(true, false);
        }
    } else {
        currentDoneType = DONE_TYPE_FLOATING;
        showDoneButton(false, animated);
        if (page != 8) {
            currentDoneType = DONE_TYPE_ACTION;
        }
    }
    if (animated) {
        final SlideView outView = views[currentViewNum];
        final SlideView newView = views[page];
        currentViewNum = page;
        actionBar.setBackButtonImage(newView.needBackButton() || newAccount ? R.drawable.ic_ab_back : 0);
        newView.setParams(params, false);
        actionBar.setTitle(newView.getHeaderName());
        setParentActivityTitle(newView.getHeaderName());
        newView.onShow();
        newView.setX(back ? -AndroidUtilities.displaySize.x : AndroidUtilities.displaySize.x);
        newView.setVisibility(View.VISIBLE);
        AnimatorSet pagesAnimation = new AnimatorSet();
        pagesAnimation.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                if (currentDoneType == DONE_TYPE_FLOATING && needFloatingButton) {
                    showDoneButton(true, true);
                }
                outView.setVisibility(View.GONE);
                outView.setX(0);
            }
        });
        pagesAnimation.playTogether(ObjectAnimator.ofFloat(outView, View.TRANSLATION_X, back ? AndroidUtilities.displaySize.x : -AndroidUtilities.displaySize.x), ObjectAnimator.ofFloat(newView, View.TRANSLATION_X, 0));
        pagesAnimation.setDuration(300);
        pagesAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
        pagesAnimation.start();
    } else {
        actionBar.setBackButtonImage(views[page].needBackButton() || newAccount ? R.drawable.ic_ab_back : 0);
        views[currentViewNum].setVisibility(View.GONE);
        currentViewNum = page;
        views[page].setParams(params, false);
        views[page].setVisibility(View.VISIBLE);
        actionBar.setTitle(views[page].getHeaderName());
        setParentActivityTitle(views[page].getHeaderName());
        views[page].onShow();
    }
}
Also used : StateListAnimator(android.animation.StateListAnimator) VerticalPositionAutoAnimator(org.telegram.ui.Components.VerticalPositionAutoAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) AnimatorSet(android.animation.AnimatorSet) SlideView(org.telegram.ui.Components.SlideView)

Aggregations

SlideView (org.telegram.ui.Components.SlideView)6 Animator (android.animation.Animator)4 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)4 AnimatorSet (android.animation.AnimatorSet)4 ObjectAnimator (android.animation.ObjectAnimator)4 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)4 SuppressLint (android.annotation.SuppressLint)2 Paint (android.graphics.Paint)2 TextPaint (android.text.TextPaint)2 StateListAnimator (android.animation.StateListAnimator)1 SharedPreferences (android.content.SharedPreferences)1 Bundle (android.os.Bundle)1 VerticalPositionAutoAnimator (org.telegram.ui.Components.VerticalPositionAutoAnimator)1