androidx.transition.Transition Java Examples

The following examples show how to use androidx.transition.Transition. 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: TransitionMusicLibraryDemoFragment.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
/**
 * Add or replace the RecyclerView containing the list of albums with a new RecyclerView that is
 * either a list/grid and sorted/unsorted according to the given arguments.
 */
private void setList(boolean listTypeGrid, boolean listSorted, Transition transition) {
  this.listTypeGrid = listTypeGrid;
  this.listSorted = listSorted;

  // Use a Transition to animate the removal and addition of the RecyclerViews.
  RecyclerView recyclerView = createRecyclerView(listTypeGrid);
  transition.addTarget(recyclerView);
  View currentRecyclerView = listContainer.getChildAt(0);
  if (currentRecyclerView != null) {
    transition.addTarget(currentRecyclerView);
  }
  TransitionManager.beginDelayedTransition(listContainer, transition);

  AlbumsAdapter adapter = new AlbumsAdapter(this, listTypeGrid);
  recyclerView.setAdapter(adapter);
  List<Album> albums = new ArrayList<>(MusicData.ALBUMS);
  if (!listSorted) {
    Collections.reverse(albums);
  }
  adapter.submitList(albums);

  listContainer.removeAllViews();
  listContainer.addView(recyclerView);
}
 
Example #2
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 #3
Source File: Scale.java    From Transitions-Everywhere with Apache License 2.0 5 votes vote down vote up
@Nullable
private Animator createAnimation(@NonNull final View view, float startScale, float endScale, @Nullable TransitionValues values) {
    final float initialScaleX = view.getScaleX();
    final float initialScaleY = view.getScaleY();
    float startScaleX = initialScaleX * startScale;
    float endScaleX = initialScaleX * endScale;
    float startScaleY = initialScaleY * startScale;
    float endScaleY = initialScaleY * endScale;

    if (values != null) {
        Float savedScaleX = (Float) values.values.get(PROPNAME_SCALE_X);
        Float savedScaleY = (Float) values.values.get(PROPNAME_SCALE_Y);
        // if saved value is not equal initial value it means that previous
        // transition was interrupted and in the onTransitionEnd
        // we've applied endScale. we should apply proper value to
        // continue animation from the interrupted state
        if (savedScaleX != null && savedScaleX != initialScaleX) {
            startScaleX = savedScaleX;
        }
        if (savedScaleY != null && savedScaleY != initialScaleY) {
            startScaleY = savedScaleY;
        }
    }

    view.setScaleX(startScaleX);
    view.setScaleY(startScaleY);

    Animator animator = TransitionUtils.mergeAnimators(
        ObjectAnimator.ofFloat(view, View.SCALE_X, startScaleX, endScaleX),
        ObjectAnimator.ofFloat(view, View.SCALE_Y, startScaleY, endScaleY));
    addListener(new TransitionListenerAdapter() {
        @Override
        public void onTransitionEnd(@NonNull Transition transition) {
            view.setScaleX(initialScaleX);
            view.setScaleY(initialScaleY);
            transition.removeListener(this);
        }
    });
    return animator;
}
 
Example #4
Source File: InterpolatorDurationStartDelaySample.java    From Transitions-Everywhere with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_interpolator, container, false);

    final ViewGroup transitionsContainer = view.findViewById(R.id.transitions_container);
    final View button = transitionsContainer.findViewById(R.id.button);

    button.setOnClickListener(new View.OnClickListener() {

        boolean mToRightAnimation;

        @Override
        public void onClick(View v) {
            mToRightAnimation = !mToRightAnimation;

            Transition transition = new ChangeBounds();
            transition.setDuration(mToRightAnimation ? 700 : 300);
            transition.setInterpolator(mToRightAnimation ? new FastOutSlowInInterpolator() : new AccelerateInterpolator());
            transition.setStartDelay(mToRightAnimation ? 0 : 500);
            TransitionManager.beginDelayedTransition(transitionsContainer, transition);

            FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) button.getLayoutParams();
            params.gravity = mToRightAnimation ? (Gravity.RIGHT | Gravity.TOP) : (Gravity.LEFT | Gravity.TOP);
            button.setLayoutParams(params);
        }

    });

    return view;
}
 
Example #5
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 #6
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 #7
Source File: MainActivity.java    From views-widgets-samples with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mStaggerCB = (CheckBox) findViewById(R.id.staggerCB);

    mFirstButton = (Button) findViewById(R.id.firstButton);
    mSecondButton = (Button) findViewById(R.id.secondButton);
    mThirdButton = (Button) findViewById(R.id.thirdButton);
    mFourthButton = (Button) findViewById(R.id.fourthButton);

    mSceneRoot = (ViewGroup) findViewById(R.id.activity_main);

    // Create custom transition that 'staggers' the animations by offsetting
    // the individual start times
    mStaggeredTransition = new TransitionSet();
    Transition first = new ChangeBounds();
    Transition second = new ChangeBounds();
    Transition third = new ChangeBounds();
    Transition fourth = new ChangeBounds();

    first.addTarget(mFirstButton);
    second.setStartDelay(50).addTarget(mSecondButton);
    third.setStartDelay(100).addTarget(mThirdButton);
    fourth.setStartDelay(150).addTarget(mFourthButton);

    mStaggeredTransition.addTransition(first).addTransition(second).addTransition(third).
            addTransition(fourth);
}
 
Example #8
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 #9
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 #10
Source File: LnUrlWithdrawBSDFragment.java    From zap-android with MIT License 4 votes vote down vote up
private void switchToFailedScreen(String error) {

        // 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
        mProgressFinishedIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_failed_circle_black_60dp));
        mProgressFinishedIcon.setImageTintList(ColorStateList.valueOf(ContextCompat.getColor(getActivity(), R.color.superRed)));
        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();

        // Set failed states
        mTvFinishedText.setText(R.string.lnurl_withdraw_fail);
        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 #11
Source File: SendBSDFragment.java    From zap-android with MIT License 4 votes vote down vote up
private void switchToFailedScreen(String error) {

        // 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
        mProgressFinishedIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_failed_circle_black_60dp));
        mProgressFinishedIcon.setImageTintList(ColorStateList.valueOf(ContextCompat.getColor(getActivity(), R.color.superRed)));
        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();


        // Set failed states
        mTvFinishedText.setText(R.string.send_fail);
        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 #12
Source File: SendBSDFragment.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 #13
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 #14
Source File: TransitionListenerAdapter.java    From material-components-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onTransitionStart(Transition transition) {}
 
Example #15
Source File: TransitionListenerAdapter.java    From material-components-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onTransitionEnd(Transition transition) {}
 
Example #16
Source File: TransitionListenerAdapter.java    From material-components-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onTransitionCancel(Transition transition) {}
 
Example #17
Source File: TransitionListenerAdapter.java    From material-components-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onTransitionPause(Transition transition) {}
 
Example #18
Source File: TransitionListenerAdapter.java    From material-components-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onTransitionResume(Transition transition) {}
 
Example #19
Source File: TransitionUtils.java    From material-components-android with Apache License 2.0 4 votes vote down vote up
static void maybeAddTransition(TransitionSet transitionSet, @Nullable Transition transition) {
  if (transition != null) {
    transitionSet.addTransition(transition);
  }
}
 
Example #20
Source File: TransitionUtils.java    From material-components-android with Apache License 2.0 4 votes vote down vote up
static void maybeRemoveTransition(TransitionSet transitionSet, @Nullable Transition transition) {
  if (transition != null) {
    transitionSet.removeTransition(transition);
  }
}
 
Example #21
Source File: OpenChannelBSDFragment.java    From zap-android with MIT License 4 votes vote down vote up
private void switchToFailedScreen(String error) {

        // 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
        mProgressFinishedIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_failed_circle_black_60dp));
        mProgressFinishedIcon.setImageTintList(ColorStateList.valueOf(ContextCompat.getColor(getActivity(), R.color.superRed)));
        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.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();
        scaleDownIcon.play(scaleDownX).with(scaleDownY).with(scaleDownX2).with(scaleDownY2);
        scaleDownIcon.start();

        // Set failed states
        mTvFinishedText.setText(getString(R.string.channel_open_error));
        mTvFinishedText.setTextColor(getResources().getColor(R.color.superRed));
        mTvFinishedTextDetail.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);

        mOkButton.setEnabled(true);
    }