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();
}
}
Aggregations