Java Code Examples for androidx.transition.TransitionManager#beginDelayedTransition()

The following examples show how to use androidx.transition.TransitionManager#beginDelayedTransition() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EditImageActivity.java    From indigenous-android with GNU General Public License v3.0 6 votes vote down vote up
void showFilter(boolean isVisible) {
    mIsFilterVisible = isVisible;
    mConstraintSet.clone(mRootView);

    if (isVisible) {
        mConstraintSet.clear(mRvFilters.getId(), ConstraintSet.START);
        mConstraintSet.connect(mRvFilters.getId(), ConstraintSet.START,
                ConstraintSet.PARENT_ID, ConstraintSet.START);
        mConstraintSet.connect(mRvFilters.getId(), ConstraintSet.END,
                ConstraintSet.PARENT_ID, ConstraintSet.END);
    } else {
        mConstraintSet.connect(mRvFilters.getId(), ConstraintSet.START,
                ConstraintSet.PARENT_ID, ConstraintSet.END);
        mConstraintSet.clear(mRvFilters.getId(), ConstraintSet.END);
    }

    ChangeBounds changeBounds = new ChangeBounds();
    changeBounds.setDuration(350);
    changeBounds.setInterpolator(new AnticipateOvershootInterpolator(1.0f));
    TransitionManager.beginDelayedTransition(mRootView, changeBounds);

    mConstraintSet.applyTo(mRootView);
}
 
Example 2
Source File: TransitionContainerTransformViewDemoFragment.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
private void showEndView(@Nullable View startView) {
  // Save a reference to the start view that triggered the transition in order to know which view
  // to transition into during the return transition.
  this.startView = startView;

  // Construct a container transform transition between two views.
  MaterialContainerTransform transition = buildContainerTransform(true);
  transition.setStartView(startView);
  transition.setEndView(endCard);

  // Add a single target to avoid the container transform from running on both the start
  // and end view
  transition.addTarget(startView);

  // Trigger the container transform transition.
  TransitionManager.beginDelayedTransition(root, transition);
  if (startView != null) {
    startView.setVisibility(View.INVISIBLE);
  }
  if (endCard != null) {
    endCard.setVisibility(View.VISIBLE);
  }
}
 
Example 3
Source File: TransitionContainerTransformViewDemoFragment.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
private void showStartView() {
  // Construct a container transform transition between two views.
  MaterialContainerTransform transition = buildContainerTransform(false);
  transition.setStartView(endCard);
  transition.setEndView(startView);

  // Add a single target to avoid the container transform from running on both the start
  // and end view
  transition.addTarget(startView);

  // Trigger the container transform transition.
  TransitionManager.beginDelayedTransition(root, transition);
  if (startView != null) {
    startView.setVisibility(View.VISIBLE);
  }
  if (endCard != null) {
    endCard.setVisibility(View.INVISIBLE);
  }
}
 
Example 4
Source File: MeActivity.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void drawProfile() {
    TransitionManager.beginDelayedTransition(container);
    if (AuthManager.getInstance().getUser() != null) {
        profile.drawMeProfile(this, AuthManager.getInstance().getUser());
    }
    if (AuthManager.getInstance().getUser() != null) {
        drawTabTitles(AuthManager.getInstance().getUser());
    }
}
 
Example 5
Source File: DynamicRecyclerViewFrame.java    From dynamic-support with Apache License 2.0 5 votes vote down vote up
/**
 * Show progress bar and hide the recycler view.
 *
 * @param animate {@code true} to animate the changes.
 */
public void showProgress(boolean animate) {
    if (mProgressBar != null) {
        if (animate) {
            TransitionManager.beginDelayedTransition(this);
        }

        mProgressBar.setVisibility(VISIBLE);
        mRecyclerView.setVisibility(GONE);
        mProgressBar.show();
    }
}
 
Example 6
Source File: DynamicRecyclerViewFrame.java    From dynamic-support with Apache License 2.0 5 votes vote down vote up
/**
 * Hide progress bar and show the recycler view.
 *
 * @param animate {@code true} to animate the changes.
 */
public void hideProgress(boolean animate) {
    if (mProgressBar != null) {
        if (animate) {
            TransitionManager.beginDelayedTransition(this);
        }

        mProgressBar.hide();
        mRecyclerView.setVisibility(View.VISIBLE);
    }
}
 
Example 7
Source File: AbstractMessageViewHolder.java    From adamant-android with GNU General Public License v3.0 5 votes vote down vote up
public AbstractMessageViewHolder(
        Context context,
        View itemView,
        AdamantMarkdownProcessor adamantAddressProcessor,
        Avatar avatar
) {
    super(context, itemView);
    this.adamantAddressProcessor = adamantAddressProcessor;
    this.avatar = avatar;
    this.context = context;
    constraintLayout = itemView.findViewById(R.id.message_item);
    TransitionManager.beginDelayedTransition(constraintLayout);
    constraintSet.clone(constraintLayout);

    parentPadding = (int)context.getResources().getDimension(R.dimen.list_item_message_padding);
    lastMessagePadding=(int)context.getResources().getDimension(R.dimen.list_item_message_last_message_padding);
    avatarMargin = (int)context.getResources().getDimension(R.dimen.list_item_message_avatar_margin);
    avatarSize = (int) context.getResources().getDimension(R.dimen.list_item_avatar_size);
    sameSenderTopPadding = (int) context.getResources().getDimension(R.dimen.list_item_message_same_sender_padding);
    notSameSenderTopPadding = (int) context.getResources().getDimension(R.dimen.list_item_message_not_same_sender_padding);

    messageBlockView = itemView.findViewById(R.id.list_item_message_card);

    processedView = itemView.findViewById(R.id.list_item_message_processed);

    timeView = itemView.findViewById(R.id.list_item_message_time);
    errorView = itemView.findViewById(R.id.list_item_message_error_text);
    contentBlock = itemView.findViewById(R.id.list_item_message_content);
}
 
Example 8
Source File: OngoingCallActivity.java    From call_manage with MIT License 5 votes vote down vote up
/**
 * Moves the reject button to the middle
 */
private void moveRejectButtonToMiddle() {
    ConstraintSet ongoingSet = new ConstraintSet();

    ongoingSet.clone(mOngoingCallLayout);
    ongoingSet.connect(R.id.reject_btn, ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.END);
    ongoingSet.connect(R.id.reject_btn, ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.START);
    ongoingSet.setHorizontalBias(R.id.reject_btn, 0.5f);
    ongoingSet.setMargin(R.id.reject_btn, ConstraintSet.END, 0);

    ConstraintSet overlaySet = new ConstraintSet();
    overlaySet.clone(this, R.layout.correction_overlay_reject_call_options);

    if (!mIsCreatingUI) { //Don't animate if the activity is just being created
        Transition transition = new ChangeBounds();
        transition.setInterpolator(new AccelerateDecelerateInterpolator());
        transition.addTarget(mRejectCallOverlay);
        transition.addTarget(mRejectButton);
        TransitionManager.beginDelayedTransition(mOngoingCallLayout, transition);
    }

    ongoingSet.applyTo(mOngoingCallLayout);
    overlaySet.applyTo((ConstraintLayout) mRejectCallOverlay);

    mFloatingRejectCallTimerButton.hide();
    mFloatingCancelOverlayButton.hide();
    mFloatingSendSMSButton.hide();

    mRootView.removeView(mAnswerCallOverlay);
}
 
Example 9
Source File: SingleCGroupAdapter.java    From call_manage with MIT License 5 votes vote down vote up
/**
 * Animates the ContactHolder
 */
public void animate() {
    ConstraintLayout itemRoot = (ConstraintLayout) itemView;
    ConstraintSet set = new ConstraintSet();
    set.clone(itemRoot);

    Transition transition = new AutoTransition();
    transition.setInterpolator(new OvershootInterpolator());
    TransitionManager.beginDelayedTransition(itemRoot, transition);
    int layoutId = mEditModeEnabled ? R.layout.item_contact_editable_modified : R.layout.item_contact_editable;
    set.load(mContext, layoutId);
    set.applyTo(itemRoot);
}
 
Example 10
Source File: BottomNavigationMenuView.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
public void updateMenuView() {
  if (menu == null || buttons == null) {
    return;
  }

  final int menuSize = menu.size();
  if (menuSize != buttons.length) {
    // The size has changed. Rebuild menu view from scratch.
    buildMenuView();
    return;
  }

  int previousSelectedId = selectedItemId;

  for (int i = 0; i < menuSize; i++) {
    MenuItem item = menu.getItem(i);
    if (item.isChecked()) {
      selectedItemId = item.getItemId();
      selectedItemPosition = i;
    }
  }
  if (previousSelectedId != selectedItemId) {
    // Note: this has to be called before BottomNavigationItemView#initialize().
    TransitionManager.beginDelayedTransition(this, set);
  }

  boolean shifting = isShifting(labelVisibilityMode, menu.getVisibleItems().size());
  for (int i = 0; i < menuSize; i++) {
    presenter.setUpdateSuspended(true);
    buttons[i].setLabelVisibilityMode(labelVisibilityMode);
    buttons[i].setShifting(shifting);
    buttons[i].initialize((MenuItemImpl) menu.getItem(i), 0);
    presenter.setUpdateSuspended(false);
  }
}
 
Example 11
Source File: ContactSelectionListFragment.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
private void setChipGroupVisibility(int visibility) {
  TransitionManager.beginDelayedTransition(constraintLayout, new AutoTransition().setDuration(CHIP_GROUP_REVEAL_DURATION_MS));

  ConstraintSet constraintSet = new ConstraintSet();
  constraintSet.clone(constraintLayout);
  constraintSet.setVisibility(R.id.chipGroupScrollContainer, visibility);
  constraintSet.applyTo(constraintLayout);
}
 
Example 12
Source File: UserActivity.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void drawProfile(@Nullable User user) {
    if (user == null) {
        return;
    }
    if (user.isComplete() && userProfileView.getState() == UserProfileView.STATE_LOADING) {
        TransitionManager.beginDelayedTransition(container);
        userProfileView.drawUserInfo(this, user);
    } else if (userProfileView.getState() == UserProfileView.STATE_NORMAL) {
        userProfileView.setRippleButtonState(user);
    }
}
 
Example 13
Source File: WebRtcCallView.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
private void fadeControls(int visibility) {
  Transition transition = new AutoTransition().setDuration(TRANSITION_DURATION_MILLIS);

  TransitionManager.beginDelayedTransition(parent, transition);

  ConstraintSet constraintSet = new ConstraintSet();
  constraintSet.clone(parent);

  for (View view : visibleViewSet) {
    constraintSet.setVisibility(view.getId(), visibility);
  }

  constraintSet.applyTo(parent);
}
 
Example 14
Source File: ChannelDetailBSDFragment.java    From zap-android with MIT License 4 votes vote down vote up
private void switchToFinishScreen(boolean success, String error) {
    mFinishedScreen.setVisibility(View.VISIBLE);

    // Animate Layout changes
    ConstraintSet csRoot = new ConstraintSet();
    csRoot.clone(mRootLayout);
    csRoot.connect(mProgressScreen.getId(), ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP);
    csRoot.setVerticalBias(mProgressScreen.getId(), 0.0f);

    Transition transition = new ChangeBounds();
    transition.setInterpolator(new DecelerateInterpolator(3));
    transition.setDuration(1000);
    TransitionManager.beginDelayedTransition(mRootLayout, transition);
    csRoot.applyTo(mRootLayout);

    // Animate result icon switch
    if (!success) {
        mProgressResultIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_failed_circle_black_60dp));
        mProgressResultIcon.setImageTintList(ColorStateList.valueOf(ContextCompat.getColor(getActivity(), R.color.superRed)));
    } else {
        mProgressResultIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_check_circle_black_60dp));
        mProgressResultIcon.setImageTintList(ColorStateList.valueOf(ContextCompat.getColor(getActivity(), R.color.superGreen)));
    }

    ObjectAnimator scaleUpX = ObjectAnimator.ofFloat(mProgressResultIcon, "scaleX", 0f, 1f);
    ObjectAnimator scaleUpY = ObjectAnimator.ofFloat(mProgressResultIcon, "scaleY", 0f, 1f);
    scaleUpX.setDuration(500);
    scaleUpY.setDuration(500);

    AnimatorSet scaleUpIcon = new AnimatorSet();
    scaleUpIcon.play(scaleUpX).with(scaleUpY);
    scaleUpIcon.start();

    ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(mProgressBar, "scaleX", 1f, 0f);
    ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(mProgressBar, "scaleY", 1f, 0f);
    ObjectAnimator scaleDownX2 = ObjectAnimator.ofFloat(mProgressThunderIcon, "scaleX", 1f, 0f);
    ObjectAnimator scaleDownY2 = ObjectAnimator.ofFloat(mProgressThunderIcon, "scaleY", 1f, 0f);
    scaleDownX.setDuration(500);
    scaleDownY.setDuration(500);
    scaleDownX2.setDuration(500);
    scaleDownY2.setDuration(500);

    AnimatorSet scaleDownIcon = new AnimatorSet();
    scaleDownIcon.play(scaleDownX).with(scaleDownY).with(scaleDownX2).with(scaleDownY2);
    scaleDownIcon.start();

    if (success) {
        mTvFinishedText.setText(R.string.success);
        mTvFinishedText2.setText(R.string.channel_close_success);
    } else {
        mTvFinishedText.setText(R.string.channel_close_error);
        mTvFinishedText.setTextColor(getResources().getColor(R.color.superRed));
        mTvFinishedText2.setText(error);
    }

    // Animate in
    mFinishedScreen.setAlpha(1.0f);
    AlphaAnimation animateIn = new AlphaAnimation(0f, 1.0f);
    animateIn.setDuration(300);
    animateIn.setStartOffset(300);
    animateIn.setFillAfter(true);

    mFinishedScreen.startAnimation(animateIn);

    // Enable Ok button
    mOkButton.setEnabled(true);
}
 
Example 15
Source File: LnUrlWithdrawBSDFragment.java    From zap-android with MIT License 4 votes vote down vote up
private void switchToSuccessScreen() {

        // Animate Layout changes
        ConstraintSet csRoot = new ConstraintSet();
        csRoot.clone(mRootLayout);
        csRoot.connect(mProgressScreen.getId(), ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP);
        csRoot.setVerticalBias(mProgressScreen.getId(), 0.0f);

        Transition transition = new ChangeBounds();
        transition.setInterpolator(new DecelerateInterpolator(3));
        transition.setDuration(1000);
        //transition.setStartDelay(200);
        TransitionManager.beginDelayedTransition(mRootLayout, transition);
        csRoot.applyTo(mRootLayout);


        // Animate finished Icon switch
        ObjectAnimator scaleUpX = ObjectAnimator.ofFloat(mProgressFinishedIcon, "scaleX", 0f, 1f);
        ObjectAnimator scaleUpY = ObjectAnimator.ofFloat(mProgressFinishedIcon, "scaleY", 0f, 1f);
        scaleUpX.setDuration(500);
        scaleUpY.setDuration(500);

        AnimatorSet scaleUpIcon = new AnimatorSet();
        //scaleUpIcon.setInterpolator(new AnticipateOvershootInterpolator(1.0f));
        scaleUpIcon.play(scaleUpX).with(scaleUpY);
        scaleUpIcon.start();

        ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(mProgressBar, "scaleX", 1f, 0f);
        ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(mProgressBar, "scaleY", 1f, 0f);
        ObjectAnimator scaleDownX2 = ObjectAnimator.ofFloat(mIvProgressPaymentTypeIcon, "scaleX", 1f, 0f);
        ObjectAnimator scaleDownY2 = ObjectAnimator.ofFloat(mIvProgressPaymentTypeIcon, "scaleY", 1f, 0f);
        scaleDownX.setDuration(500);
        scaleDownY.setDuration(500);
        scaleDownX2.setDuration(500);
        scaleDownY2.setDuration(500);

        AnimatorSet scaleDownIcon = new AnimatorSet();
        //scaleUpIcon.setInterpolator(new AnticipateOvershootInterpolator(1.0f));
        scaleDownIcon.play(scaleDownX).with(scaleDownY).with(scaleDownX2).with(scaleDownY2);
        scaleDownIcon.start();


        // Animate in
        mFinishedScreen.setAlpha(1.0f);
        AlphaAnimation animateIn = new AlphaAnimation(0f, 1.0f);
        animateIn.setDuration(300);
        animateIn.setStartOffset(300);
        animateIn.setFillAfter(true);
        mFinishedScreen.startAnimation(animateIn);

        // Enable Ok button
        mOkButton.setEnabled(true);
    }
 
Example 16
Source File: OpenChannelBSDFragment.java    From zap-android with MIT License 4 votes vote down vote up
private void switchToSuccessScreen() {


        // Animate Layout changes
        ConstraintSet csRoot = new ConstraintSet();
        csRoot.clone(mRootLayout);
        csRoot.connect(mProgressScreen.getId(), ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP);
        csRoot.setVerticalBias(mProgressScreen.getId(), 0.0f);

        Transition transition = new ChangeBounds();
        transition.setInterpolator(new DecelerateInterpolator(3));
        transition.setDuration(1000);
        //transition.setStartDelay(200);
        TransitionManager.beginDelayedTransition(mRootLayout, transition);
        csRoot.applyTo(mRootLayout);


        // Animate finished Icon switch
        ObjectAnimator scaleUpX = ObjectAnimator.ofFloat(mProgressFinishedIcon, "scaleX", 0f, 1f);
        ObjectAnimator scaleUpY = ObjectAnimator.ofFloat(mProgressFinishedIcon, "scaleY", 0f, 1f);
        scaleUpX.setDuration(500);
        scaleUpY.setDuration(500);

        AnimatorSet scaleUpIcon = new AnimatorSet();
        //scaleUpIcon.setInterpolator(new AnticipateOvershootInterpolator(1.0f));
        scaleUpIcon.play(scaleUpX).with(scaleUpY);
        scaleUpIcon.start();

        ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(mProgressBar, "scaleX", 1f, 0f);
        ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(mProgressBar, "scaleY", 1f, 0f);
        ObjectAnimator scaleDownX2 = ObjectAnimator.ofFloat(mIvProgressPaymentTypeIcon, "scaleX", 1f, 0f);
        ObjectAnimator scaleDownY2 = ObjectAnimator.ofFloat(mIvProgressPaymentTypeIcon, "scaleY", 1f, 0f);
        scaleDownX.setDuration(500);
        scaleDownY.setDuration(500);
        scaleDownX2.setDuration(500);
        scaleDownY2.setDuration(500);

        AnimatorSet scaleDownIcon = new AnimatorSet();
        //scaleUpIcon.setInterpolator(new AnticipateOvershootInterpolator(1.0f));
        scaleDownIcon.play(scaleDownX).with(scaleDownY).with(scaleDownX2).with(scaleDownY2);
        scaleDownIcon.start();

        mTvFinishedText.setText(R.string.success);
        mTvFinishedTextDetail.setText(R.string.channel_open_success);

        // Animate in

        mFinishedScreen.setAlpha(1.0f);
        AlphaAnimation animateIn = new AlphaAnimation(0f, 1.0f);
        animateIn.setDuration(300);
        animateIn.setStartOffset(300);
        animateIn.setFillAfter(true);


        mFinishedScreen.startAnimation(animateIn);

        // Enable Ok button
        mOkButton.setEnabled(true);
    }
 
Example 17
Source File: OnChainFeeView.java    From zap-android with MIT License 4 votes vote down vote up
/**
 * Show or hide tabs to choose fee tier
 */
private void toggleFeeTierView(boolean hide) {
    TransitionManager.beginDelayedTransition((ViewGroup) getRootView());
    mFeeArrowUnitImage.setImageResource(hide ? R.drawable.ic_arrow_down_24dp : R.drawable.ic_arrow_up_24dp);
    mClSendFeeDurationLayout.setVisibility(hide ? View.GONE : View.VISIBLE);
}
 
Example 18
Source File: ViewPostDetailActivity.java    From Infinity-For-Reddit with GNU Affero General Public License v3.0 4 votes vote down vote up
public void delayTransition() {
    TransitionManager.beginDelayedTransition(mRecyclerView, new AutoTransition());
}
 
Example 19
Source File: RippleButton.java    From Mysplash with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void requestLayout() {
    super.requestLayout();
    TransitionManager.beginDelayedTransition(this, new ChangeBounds());
}
 
Example 20
Source File: MainActivity.java    From views-widgets-samples with Apache License 2.0 4 votes vote down vote up
private void alignButtons(boolean left, boolean top) {
    LayoutParams params;

    // Trigger a transition to run after the next layout pass
    if (mStaggerCB.isChecked()) {
        TransitionManager.beginDelayedTransition(mSceneRoot, mStaggeredTransition);
    } else {
        TransitionManager.beginDelayedTransition(mSceneRoot);
    }

    // Change layout parameters of the button stack
    int oldAlignmentLR = left ? ALIGN_PARENT_RIGHT : ALIGN_PARENT_LEFT;
    int newAlignmentLR = left ? ALIGN_PARENT_LEFT : ALIGN_PARENT_RIGHT;
    int oldAlignmentTB = top ? ABOVE : BELOW;
    int newAlignmentTB = top ? BELOW : ABOVE;

    params = (LayoutParams) mFirstButton.getLayoutParams();
    params.addRule(top ? ALIGN_PARENT_BOTTOM : BELOW, 0);
    params.addRule(oldAlignmentLR, 0);
    params.addRule(top ? BELOW : ALIGN_PARENT_BOTTOM, top ? R.id.staggerCB : 1);
    params.addRule(newAlignmentLR);
    mFirstButton.setLayoutParams(params);

    params = (LayoutParams) mSecondButton.getLayoutParams();
    params.addRule(oldAlignmentLR, 0);
    params.addRule(oldAlignmentTB, 0);
    params.addRule(newAlignmentLR);
    params.addRule(newAlignmentTB, R.id.firstButton);
    mSecondButton.setLayoutParams(params);

    params = (LayoutParams) mThirdButton.getLayoutParams();
    params.addRule(oldAlignmentLR, 0);
    params.addRule(oldAlignmentTB, 0);
    params.addRule(newAlignmentLR);
    params.addRule(newAlignmentTB, R.id.secondButton);
    mThirdButton.setLayoutParams(params);

    params = (LayoutParams) mFourthButton.getLayoutParams();
    params.addRule(oldAlignmentLR, 0);
    params.addRule(oldAlignmentTB, 0);
    params.addRule(newAlignmentLR);
    params.addRule(newAlignmentTB, R.id.thirdButton);
    mFourthButton.setLayoutParams(params);
}