androidx.constraintlayout.widget.ConstraintSet Java Examples

The following examples show how to use androidx.constraintlayout.widget.ConstraintSet. 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: GradientColorsActivity.java    From PercentageChartView with Apache License 2.0 6 votes vote down vote up
private void changeMode(int pendingMode) {
    switch (pendingMode) {
        case MODE_PIE:
            mConstraintSet.setVisibility(R.id.pie_chart, ConstraintSet.VISIBLE);
            mConstraintSet.setVisibility(R.id.fill_chart, ConstraintSet.GONE);
            mConstraintSet.setVisibility(R.id.ring_chart, ConstraintSet.GONE);
            break;
        case MODE_FILL:
            mConstraintSet.setVisibility(R.id.pie_chart, ConstraintSet.GONE);
            mConstraintSet.setVisibility(R.id.fill_chart, ConstraintSet.VISIBLE);
            mConstraintSet.setVisibility(R.id.ring_chart, ConstraintSet.GONE);
            break;
        case MODE_RING:
            mConstraintSet.setVisibility(R.id.pie_chart, ConstraintSet.GONE);
            mConstraintSet.setVisibility(R.id.fill_chart, ConstraintSet.GONE);
            mConstraintSet.setVisibility(R.id.ring_chart, ConstraintSet.VISIBLE);
            break;
    }

    displayedMode = pendingMode;
    applyTransition();
}
 
Example #3
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 #4
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 #5
Source File: AdaptiveColorsActivity.java    From PercentageChartView with Apache License 2.0 6 votes vote down vote up
private void changeMode(int pendingMode) {
    switch (pendingMode) {
        case MODE_PIE:
            mConstraintSet.setVisibility(R.id.pie_chart, ConstraintSet.VISIBLE);
            mConstraintSet.setVisibility(R.id.fill_chart, ConstraintSet.GONE);
            mConstraintSet.setVisibility(R.id.ring_chart, ConstraintSet.GONE);
            break;
        case MODE_FILL:
            mConstraintSet.setVisibility(R.id.pie_chart, ConstraintSet.GONE);
            mConstraintSet.setVisibility(R.id.fill_chart, ConstraintSet.VISIBLE);
            mConstraintSet.setVisibility(R.id.ring_chart, ConstraintSet.GONE);
            break;
        case MODE_RING:
            mConstraintSet.setVisibility(R.id.pie_chart, ConstraintSet.GONE);
            mConstraintSet.setVisibility(R.id.fill_chart, ConstraintSet.GONE);
            mConstraintSet.setVisibility(R.id.ring_chart, ConstraintSet.VISIBLE);
            break;
    }

    displayedMode = pendingMode;
    applyTransition();
}
 
Example #6
Source File: EditImageActivity.java    From PhotoEditor with MIT License 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 #7
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 #8
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 #9
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 #10
Source File: ContactSelectionListFragment.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
private void removeChipForContact(@NonNull SelectedContact contact) {
  for (int i = chipGroup.getChildCount() - 1; i >= 0; i--) {
    View v = chipGroup.getChildAt(i);
    if (v instanceof ContactChip && contact.matches(((ContactChip) v).getContact())) {
      chipGroup.removeView(v);
    }
  }

  updateGroupLimit(getChipCount());

  if (getChipCount() == 0) {
    setChipGroupVisibility(ConstraintSet.GONE);
  }
}
 
Example #11
Source File: MainActivity.java    From LTECleanerFOSS with Apache License 2.0 5 votes vote down vote up
public void animateBtn() {
    TransitionManager.beginDelayedTransition(layout);
    constraintSet.clear(R.id.cleanButton,ConstraintSet.TOP);
    constraintSet.clear(R.id.statusTextView,ConstraintSet.BOTTOM);
    constraintSet.setMargin(R.id.statusTextView,ConstraintSet.TOP,50);
    constraintSet.applyTo(layout);
}
 
Example #12
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 #13
Source File: BaseActivity.java    From Ruisi with Apache License 2.0 5 votes vote down vote up
protected void addToolbarView(View v) {
    ConstraintLayout toolbar = findViewById(R.id.myToolBar);
    if (toolbar != null) {
        ConstraintLayout.LayoutParams pls = new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT);
        v.setLayoutParams(pls);
        int padding = DimenUtils.dip2px(this, 12);
        v.setPadding(padding, padding, padding, padding);
        pls.setMarginEnd(padding);
        pls.bottomToBottom = ConstraintSet.PARENT_ID;
        pls.topToTop = ConstraintSet.PARENT_ID;
        pls.endToEnd = ConstraintSet.PARENT_ID;
        //pls.gravity = Gravity.END;
        toolbar.addView(v);
    }
}
 
Example #14
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 #15
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 #16
Source File: ConstraintSetHelper.java    From opentok-android-sdk-samples with MIT License 5 votes vote down vote up
public void layoutViewAboveView(int aboveViewId, int belowViewId) {
    //  above
    //  below

    set.constrainHeight(aboveViewId, 0);
    set.constrainHeight(belowViewId, 0);
    set.connect(aboveViewId, ConstraintSet.BOTTOM, belowViewId, ConstraintSet.TOP);
    set.connect(belowViewId, ConstraintSet.TOP, aboveViewId, ConstraintSet.BOTTOM);
}
 
Example #17
Source File: AbstractMessageViewHolder.java    From adamant-android with GNU General Public License v3.0 5 votes vote down vote up
protected void displayIsSameSenderPadding(boolean isNextMessageWithSameSender) {
    if (isNextMessageWithSameSender) {
        constraintSet.connect(messageBlockView.getId(), ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP, sameSenderTopPadding);
    } else {
        constraintSet.connect(messageBlockView.getId(), ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP, notSameSenderTopPadding);
    }
}
 
Example #18
Source File: AbstractMessageViewHolder.java    From adamant-android with GNU General Public License v3.0 5 votes vote down vote up
private void companionToldModification(boolean isNextMessageWithSameSender) {
    constraintSet.clear(messageBlockView.getId(), ConstraintSet.START);
    constraintSet.clear(messageBlockView.getId(), ConstraintSet.END);
    constraintSet.connect(messageBlockView.getId(), ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START, parentPadding);

    displayIsSameSenderPadding(isNextMessageWithSameSender);

    constraintSet.applyTo(constraintLayout);
}
 
Example #19
Source File: SearchTEActivity.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void activeFilter(boolean general) {
    ConstraintSet initSet = new ConstraintSet();
    initSet.clone(binding.backdropLayout);

    if (backDropActive) {
        initSet.connect(R.id.mainLayout, ConstraintSet.TOP, general ? R.id.filterLayout : R.id.form_recycler, ConstraintSet.BOTTOM, 50);
    } else {
        initSet.connect(R.id.mainLayout, ConstraintSet.TOP, R.id.backdropGuideTop, ConstraintSet.BOTTOM, 0);
    }

    initSet.applyTo(binding.backdropLayout);
}
 
Example #20
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 #21
Source File: ConstraintSetHelper.java    From opentok-android-sdk-samples with MIT License 5 votes vote down vote up
private void layoutViewNextToView(int leftViewId, int rightViewId, int leftBoundViewId, int rightBoundViewId) {
    // leftBound | leftView | rightView \ rightBound

    set.constrainWidth(leftViewId, 0);
    set.constrainWidth(rightViewId, 0);

    set.connect(leftViewId, ConstraintSet.LEFT, leftBoundViewId, ConstraintSet.LEFT);
    set.connect(leftViewId, ConstraintSet.RIGHT, rightViewId, ConstraintSet.LEFT);

    set.connect(rightViewId, ConstraintSet.RIGHT, rightBoundViewId, ConstraintSet.RIGHT);
    set.connect(rightViewId, ConstraintSet.LEFT, leftViewId, ConstraintSet.RIGHT);
}
 
Example #22
Source File: AdaptiveColorsActivity.java    From PercentageChartView with Apache License 2.0 5 votes vote down vote up
private void setupLayoutAnimation() {
    Explode transition = new Explode();
    transition.setDuration(600);
    transition.setInterpolator(new OvershootInterpolator(1f));
    getWindow().setEnterTransition(transition);

    displayedMode = MODE_PIE;

    mConstraintSet = new ConstraintSet();
    mConstraintSet.clone(mConstraintLayout);

    fade = new Fade();
    fade.setDuration(400);
}
 
Example #23
Source File: GradientColorsActivity.java    From PercentageChartView with Apache License 2.0 5 votes vote down vote up
private void setupLayoutAnimation() {
    Explode transition = new Explode();
    transition.setDuration(600);
    transition.setInterpolator(new OvershootInterpolator(1f));
    getWindow().setEnterTransition(transition);

    displayedMode = MODE_PIE;

    mConstraintSet = new ConstraintSet();
    mConstraintSet.clone(mConstraintLayout);

    fade = new Fade();
    fade.setDuration(400);
}
 
Example #24
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 #25
Source File: ConstraintSetHelper.java    From opentok-android-sdk-samples with MIT License 5 votes vote down vote up
private void layoutViewOccupyingAllRow(int viewId, int leftBoundViewId, int rightBoundViewId) {
    // leftBound | view | rightBound
    set.constrainWidth(viewId, 0);

    set.connect(viewId, ConstraintSet.LEFT, leftBoundViewId, ConstraintSet.LEFT);
    set.connect(viewId, ConstraintSet.RIGHT, rightBoundViewId, ConstraintSet.RIGHT);
}
 
Example #26
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 #27
Source File: ConstraintSetHelper.java    From opentok-android-sdk-samples with MIT License 4 votes vote down vote up
public void layoutViewWithTopBound(int viewId, int topBound) {
    set.connect(viewId, ConstraintSet.TOP, topBound, ConstraintSet.TOP);
}
 
Example #28
Source File: ConstraintSetHelper.java    From opentok-android-sdk-samples with MIT License 4 votes vote down vote up
public void layoutViewWithBottomBound(int viewId, int bottomBound) {
    set.connect(viewId, ConstraintSet.BOTTOM, bottomBound, ConstraintSet.BOTTOM);
}
 
Example #29
Source File: ConstraintSetHelper.java    From opentok-android-sdk-samples with MIT License 4 votes vote down vote up
public ConstraintSetHelper(int containerViewId) {
    set = new ConstraintSet();
    container = containerViewId;
}
 
Example #30
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);
    }
  }
}