Java Code Examples for androidx.constraintlayout.widget.ConstraintSet#applyTo()

The following examples show how to use androidx.constraintlayout.widget.ConstraintSet#applyTo() . 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: ProgramEventDetailActivity.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 7 votes vote down vote up
@Override
public void showHideFilter() {
    Transition transition = new ChangeBounds();
    transition.setDuration(200);
    TransitionManager.beginDelayedTransition(binding.backdropLayout, transition);
    backDropActive = !backDropActive;
    ConstraintSet initSet = new ConstraintSet();
    initSet.clone(binding.backdropLayout);
    binding.filterOpen.setVisibility(backDropActive ? View.VISIBLE : View.GONE);

    if (backDropActive) {
        initSet.connect(R.id.eventsLayout, ConstraintSet.TOP, R.id.filterLayout, ConstraintSet.BOTTOM, 50);
    } else {
        initSet.connect(R.id.eventsLayout, ConstraintSet.TOP, R.id.backdropGuideTop, ConstraintSet.BOTTOM, 0);
    }

    initSet.applyTo(binding.backdropLayout);
}
 
Example 2
Source File: SingleCGroupAdapter.java    From call_manage with MIT License 6 votes vote down vote up
@SuppressLint("ClickableViewAccessibility")
@Override
public void onBindViewHolder(@NonNull ContactHolder holder, int position) {
    Contact contact = mData.get(position);

    holder.name.setText(contact.getName());
    holder.number.setText(contact.getMainPhoneNumber());

    holder.dragHandle.setOnTouchListener((v, event) -> {
        if (event.getActionMasked() ==
                MotionEvent.ACTION_DOWN) {
            mItemTouchHelperListener.onStartDrag(holder);
        }
        return false;
    });

    holder.removeItem.setOnClickListener(v -> onItemDismiss(holder.getAdapterPosition()));

    ConstraintLayout itemRoot = (ConstraintLayout) holder.itemView;
    ConstraintSet set = new ConstraintSet();
    int layoutId = mEditModeEnabled ? R.layout.item_contact_editable_modified : R.layout.item_contact_editable;
    set.load(mContext, layoutId);
    set.applyTo(itemRoot);
}
 
Example 3
Source File: MainFragment.java    From InviZible with GNU General Public License v3.0 6 votes vote down vote up
@SuppressLint("SetTextI18n")
@Override
public void setITPDLogViewText() {
    if (getActivity() != null && tvITPDLog == null && !orientationLandscape) {
        tvITPDLog = getActivity().findViewById(R.id.tvITPDLog);
        clITPDLog = getActivity().findViewById(R.id.clITPDLog);
    }

    if (tvITPDLog != null) {
        tvITPDLog.setText(getText(R.string.tvITPDDefaultLog) + " " + ITPDVersion);
        tvITPDLog.setGravity(Gravity.CENTER);

        if (clITPDLog != null) {
            ConstraintSet set = new ConstraintSet();
            set.clone(clITPDLog);
            set.connect(tvITPDLog.getId(), ConstraintSet.TOP, clITPDLog.getId(), ConstraintSet.TOP);
            set.applyTo(clITPDLog);
        }
    }
}
 
Example 4
Source File: MainFragment.java    From InviZible with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void setITPDLogViewText(Spanned text) {
    if (getActivity() != null && tvITPDLog == null && !orientationLandscape) {
        tvITPDLog = getActivity().findViewById(R.id.tvITPDLog);
        clITPDLog = getActivity().findViewById(R.id.clITPDLog);
    }

    if (tvITPDLog != null) {
        tvITPDLog.setText(text);
        tvITPDLog.setGravity(Gravity.NO_GRAVITY);

        if (clITPDLog != null) {
            ConstraintSet set = new ConstraintSet();
            set.clone(clITPDLog);
            set.clear(tvITPDLog.getId(), ConstraintSet.TOP);
            set.applyTo(clITPDLog);
        }
    }
}
 
Example 5
Source File: DataSetDetailActivity.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void showHideFilter() {
    Transition transition = new ChangeBounds();
    transition.setDuration(200);
    TransitionManager.beginDelayedTransition(binding.backdropLayout, transition);
    backDropActive = !backDropActive;
    ConstraintSet initSet = new ConstraintSet();
    initSet.clone(binding.backdropLayout);
    if (backDropActive) {
        initSet.connect(R.id.eventsLayout, ConstraintSet.TOP, R.id.filterLayout, ConstraintSet.BOTTOM, 50);
    }
    else {
        initSet.connect(R.id.eventsLayout, ConstraintSet.TOP, R.id.backdropGuideTop, ConstraintSet.BOTTOM, 0);
    }
    initSet.applyTo(binding.backdropLayout);

    binding.filterOpen.setVisibility(backDropActive ? View.VISIBLE : View.GONE);
}
 
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: 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 8
Source File: TimePickerView.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
private void updateToggleConstraints() {
  if (toggle.getVisibility() == VISIBLE) {
    // The clock display would normally be centered, clear the constraint on one side to make
    // room for the toggle
    ConstraintSet constraintSet = new ConstraintSet();
    constraintSet.clone(this);
    boolean isLtr = ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_LTR;
    int sideToClear = isLtr ? ConstraintSet.RIGHT : ConstraintSet.LEFT;
    constraintSet.clear(R.id.material_clock_display, sideToClear);
    constraintSet.applyTo(this);
  }
}
 
Example 9
Source File: ScrollingHelper.java    From BaldPhone with Apache License 2.0 5 votes vote down vote up
private void setArrowsVisibility(boolean visible) {
    final int width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, visible ? verticalScrollerLength : 0, displayMetrics);

    ConstraintSet constraintSet = new ConstraintSet();
    if (whereBar == RIGHT) {
        constraintSet.constrainHeight(childId, ConstraintSet.MATCH_CONSTRAINT);
        constraintSet.constrainWidth(childId, ConstraintSet.MATCH_CONSTRAINT);
        constraintSet.connect(childId, ConstraintSet.LEFT, ConstraintSet.PARENT_ID, ConstraintSet.LEFT);
        constraintSet.connect(childId, ConstraintSet.RIGHT, ConstraintSet.PARENT_ID, ConstraintSet.RIGHT);
        constraintSet.connect(childId, ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP);
        constraintSet.connect(childId, ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM);
        constraintSet.setMargin(childId, ConstraintSet.RIGHT, width);

        constraintSet.constrainHeight(containerId, ConstraintSet.MATCH_CONSTRAINT);
        constraintSet.constrainWidth(containerId, width);
        constraintSet.connect(containerId, ConstraintSet.RIGHT, ConstraintSet.PARENT_ID, ConstraintSet.RIGHT);
        constraintSet.connect(containerId, ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP);
        constraintSet.connect(containerId, ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM);

    } else {
        constraintSet.constrainHeight(childId, ConstraintSet.MATCH_CONSTRAINT);
        constraintSet.constrainWidth(childId, ConstraintSet.MATCH_CONSTRAINT);
        constraintSet.connect(childId, ConstraintSet.LEFT, ConstraintSet.PARENT_ID, ConstraintSet.LEFT);
        constraintSet.connect(childId, ConstraintSet.RIGHT, ConstraintSet.PARENT_ID, ConstraintSet.RIGHT);
        constraintSet.connect(childId, ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP);
        constraintSet.connect(childId, ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM);
        constraintSet.setMargin(childId, ConstraintSet.LEFT, width);

        constraintSet.constrainHeight(containerId, ConstraintSet.MATCH_CONSTRAINT);
        constraintSet.constrainWidth(containerId, width);
        constraintSet.connect(containerId, ConstraintSet.LEFT, ConstraintSet.PARENT_ID, ConstraintSet.LEFT);
        constraintSet.connect(containerId, ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP);
        constraintSet.connect(containerId, ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM);

    }
    constraintSet.applyTo(this);

}
 
Example 10
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 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: CommentsListingRecyclerViewAdapter.java    From Infinity-For-Reddit with GNU Affero General Public License v3.0 4 votes vote down vote up
CommentViewHolder(View itemView) {
    super(itemView);
    ButterKnife.bind(this, itemView);

    if (mVoteButtonsOnTheRight) {
        ConstraintSet constraintSet = new ConstraintSet();
        constraintSet.clone(bottomConstraintLayout);
        constraintSet.clear(upvoteButton.getId(), ConstraintSet.START);
        constraintSet.clear(scoreTextView.getId(), ConstraintSet.START);
        constraintSet.clear(downvoteButton.getId(), ConstraintSet.START);
        constraintSet.clear(expandButton.getId(), ConstraintSet.END);
        constraintSet.clear(replyButton.getId(), ConstraintSet.END);
        constraintSet.connect(upvoteButton.getId(), ConstraintSet.END, scoreTextView.getId(), ConstraintSet.START);
        constraintSet.connect(scoreTextView.getId(), ConstraintSet.END, downvoteButton.getId(), ConstraintSet.START);
        constraintSet.connect(downvoteButton.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END);
        constraintSet.connect(moreButton.getId(), ConstraintSet.START, expandButton.getId(), ConstraintSet.END);
        constraintSet.connect(moreButton.getId(), ConstraintSet.END, upvoteButton.getId(), ConstraintSet.END);
        constraintSet.connect(expandButton.getId(), ConstraintSet.START, replyButton.getId(), ConstraintSet.END);
        constraintSet.connect(replyButton.getId(), ConstraintSet.START, replyButton.getId(), ConstraintSet.END);
        constraintSet.setHorizontalBias(moreButton.getId(), 0);
        constraintSet.applyTo(bottomConstraintLayout);
    }

    if (mShowCommentDivider) {
        commentDivider.setVisibility(View.VISIBLE);
    }

    itemView.setBackgroundColor(mCommentBackgroundColor);
    authorTextView.setTextColor(mUsernameColor);
    authorFlairTextView.setTextColor(mAuthorFlairColor);
    commentTimeTextView.setTextColor(mSecondaryTextColor);
    awardsTextView.setTextColor(mSecondaryTextColor);
    commentMarkdownView.setTextColor(mCommentColor);
    upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
    scoreTextView.setTextColor(mCommentIconAndInfoColor);
    downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
    moreButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
    expandButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
    saveButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
    replyButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
    commentDivider.setBackgroundColor(mDividerColor);
}
 
Example 13
Source File: VideoFragment.java    From googleads-ima-android with Apache License 2.0 4 votes vote down vote up
private void initUi(View rootView) {
  VideoPlayerWithAdPlayback mVideoPlayerWithAdPlayback =
      rootView.findViewById(R.id.videoPlayerWithAdPlayback);
  View playButton = rootView.findViewById(R.id.playButton);
  View playPauseToggle = rootView.findViewById(R.id.videoContainer);
  ViewGroup companionAdSlot = rootView.findViewById(R.id.companionAdSlot);
  mVideoTitle = rootView.findViewById(R.id.video_title);
  mVideoExampleLayout = rootView.findViewById(R.id.videoExampleLayout);
  mVideoExampleLayout.setOverScrollMode(View.OVER_SCROLL_ALWAYS);
  mVideoExampleLayout.setSmoothScrollingEnabled(true);

  // Make the dummyScrollContent height the size of the screen height.
  DisplayMetrics displayMetrics = new DisplayMetrics();
  getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
  ConstraintLayout constraintLayout = rootView.findViewById(R.id.constraintLayout);
  ConstraintSet forceHeight = new ConstraintSet();
  forceHeight.clone(constraintLayout);
  forceHeight.constrainHeight(R.id.dummyScrollContent, displayMetrics.heightPixels);
  forceHeight.applyTo(constraintLayout);

  final TextView logText = rootView.findViewById(R.id.logText);

  // Provide an implementation of a logger so we can output SDK events to the UI.
  VideoPlayerController.Logger logger =
      new VideoPlayerController.Logger() {
        @Override
        public void log(String message) {
          Log.i("ImaExample", message);
          if (logText != null) {
            logText.append(message);
          }
        }
      };

  mVideoPlayerController =
      new VideoPlayerController(
          this.getActivity(),
          mVideoPlayerWithAdPlayback,
          playButton,
          playPauseToggle,
          getString(R.string.ad_ui_lang),
          companionAdSlot,
          logger);

  // If we've already selected a video, load it now.
  if (mVideoItem != null) {
    loadVideo(mVideoItem);
  }
}
 
Example 14
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);
    }
 
Example 15
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 16
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 17
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 18
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 19
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 20
Source File: ConversationReactionOverlay.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
private void setupSelectedEmoji() {
  final String oldEmoji = getOldEmoji(messageRecord);

  if (oldEmoji == null) {
    selectedView.setVisibility(View.GONE);
  }

  boolean foundSelected = false;

  for (int i = 0; i < emojiViews.length; i++) {
    final EmojiImageView view = emojiViews[i];

    view.setScaleX(1.0f);
    view.setScaleY(1.0f);
    view.setTranslationY(0);

    boolean isAtCustomIndex                      = i == customEmojiIndex;
    boolean isNotAtCustomIndexAndOldEmojiMatches = !isAtCustomIndex && ReactionEmoji.values()[i].emoji.equals(oldEmoji);
    boolean isAtCustomIndexAndOldEmojiExists     = isAtCustomIndex && oldEmoji != null;

    if (!foundSelected &&
        (isNotAtCustomIndexAndOldEmojiMatches || isAtCustomIndexAndOldEmojiExists))
    {
      foundSelected = true;
      selectedView.setVisibility(View.VISIBLE);

      ConstraintSet constraintSet = new ConstraintSet();
      constraintSet.clone(foregroundView);
      constraintSet.clear(selectedView.getId(), ConstraintSet.LEFT);
      constraintSet.clear(selectedView.getId(), ConstraintSet.RIGHT);
      constraintSet.connect(selectedView.getId(), ConstraintSet.LEFT, view.getId(), ConstraintSet.LEFT);
      constraintSet.connect(selectedView.getId(), ConstraintSet.RIGHT, view.getId(), ConstraintSet.RIGHT);
      constraintSet.applyTo(foregroundView);

      if (isAtCustomIndex) {
        view.setImageEmoji(oldEmoji);
        view.setTag(oldEmoji);
      } else {
        view.setImageEmoji(ReactionEmoji.values()[i].emoji);
      }
    } else if (isAtCustomIndex) {
      view.setImageDrawable(AppCompatResources.getDrawable(getContext(), R.drawable.ic_any_emoji_32));
      view.setTag(null);
    } else {
      view.setImageEmoji(ReactionEmoji.values()[i].emoji);
    }
  }
}