@Override public void addView(View child, int index, ViewGroup.LayoutParams params) { super.addView(child, index, params); if (child.getTag() == null || (!child.getTag().equals(LOADING) && !child.getTag().equals(EMPTY) && !child.getTag().equals(ERROR))) { contentViews.add(child); } }
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); }
@Override public void showMainView() { detailConstraint.setVisibility(View.VISIBLE); }
private void inflateEmptyView() { if (emptyState == null) { view = inflater.inflate(R.layout.view_empty, null); emptyState = view.findViewById(R.id.layout_empty); emptyState.setTag(EMPTY); emptyStateImageView = view.findViewById(R.id.image_icon); emptyStateTitleTextView = view.findViewById(R.id.text_title); emptyStateContentTextView = view.findViewById(R.id.text_description); emptyStateImageView.getLayoutParams().width = emptyStateImageWidth; emptyStateImageView.getLayoutParams().height = emptyStateImageHeight; emptyStateImageView.requestLayout(); emptyStateTitleTextView.setTextSize(emptyStateTitleTextSize); emptyStateTitleTextView.setTextColor(emptyStateTitleTextColor); emptyStateContentTextView.setTextSize(emptyStateContentTextSize); emptyStateContentTextView.setTextColor(emptyStateContentTextColor); if (emptyStateBackgroundColor != Color.TRANSPARENT) { this.setBackgroundColor(emptyStateBackgroundColor); } LayoutParams layoutParams = new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); layoutParams.topToTop = ConstraintSet.PARENT_ID; layoutParams.bottomToBottom = ConstraintSet.PARENT_ID; layoutParams.startToStart = ConstraintSet.PARENT_ID; layoutParams.endToEnd = ConstraintSet.PARENT_ID; addView(emptyState, layoutParams); } else { emptyState.setVisibility(VISIBLE); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.constraintset_example_main); mRootLayout = (ConstraintLayout) findViewById(R.id.activity_constraintset_example); // Note that this can also be achieved by calling // `mConstraintSetNormal.load(this, R.layout.constraintset_example_main);` // Since we already have an inflated ConstraintLayout in `mRootLayout`, clone() is // faster and considered the best practice. mConstraintSetNormal.clone(mRootLayout); // Load the constraints from the layout where ImageView is enlarged. mConstraintSetBig.load(this, R.layout.constraintset_example_big); if (savedInstanceState != null) { boolean previous = savedInstanceState.getBoolean(SHOW_BIG_IMAGE); if (previous != mShowBigImage) { mShowBigImage = previous; applyConfig(); } } }
public void alignLeft() { LayoutParams params = (LayoutParams)mContentLayout.getLayoutParams(); params.leftMargin = 0; mContentLayout.setLayoutParams(params); }
private void initGuideLine() { ConstraintLayout.LayoutParams lp = (ConstraintLayout.LayoutParams) topGuide.getLayoutParams(); lp.guidePercent = isHalloween ? 0.34f : 0.3f; topGuide.setLayoutParams(lp); }
@Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); mHandler.removeCallbacksAndMessages(null); }
backgroundDark = (Integer) evaluator.evaluate(positionOffset, backgroundDark, backgroundDarkNext); miFrame.setBackgroundColor(background);
@Override protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); activityCreated = true; updateTaskDescription(); updateButtonNextDrawable(); updateButtonBackDrawable(); updateScrollPositions(); miFrame.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { updateScrollPositions(); v.removeOnLayoutChangeListener(this); } }); }
@Override public void onAnimationEnd(Animation animation) { mRootView.removeView(focusImageView); }
@Override public void setEmptyStateVisible() { emptyView.setVisibility(View.VISIBLE); noPermissionsLayout.setVisibility(View.GONE); }
private void inflateLoadingView() { if (loadingState == null) { view = inflater.inflate(R.layout.view_loading, null); loadingState = view.findViewById(R.id.layout_loading); loadingState.setTag(LOADING); loadingStateProgressBar = view.findViewById(R.id.progress_bar_loading); loadingStateProgressBar.getLayoutParams().width = loadingStateProgressBarWidth; loadingStateProgressBar.getLayoutParams().height = loadingStateProgressBarHeight; loadingStateProgressBar.getIndeterminateDrawable() .setColorFilter(loadingStateProgressBarColor, PorterDuff.Mode.SRC_IN); loadingStateProgressBar.requestLayout(); if (loadingStateBackgroundColor != Color.TRANSPARENT) { this.setBackgroundColor(loadingStateBackgroundColor); } LayoutParams layoutParams = new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); layoutParams.topToTop = ConstraintSet.PARENT_ID; layoutParams.bottomToBottom = ConstraintSet.PARENT_ID; layoutParams.startToStart = ConstraintSet.PARENT_ID; layoutParams.endToEnd = ConstraintSet.PARENT_ID; addView(loadingState, layoutParams); } else { loadingState.setVisibility(VISIBLE); } }
@Override public void onClick(View view) { // TransitionManager.beginDelayedTransition(constraintLayout); second.applyTo(constraintLayout); } });
public void alignRight() { LayoutParams params = (LayoutParams)mContentLayout.getLayoutParams(); params.rightMargin = 0; mContentLayout.setLayoutParams(params); }
@Override public void setEmptyStateInvisible() { emptyView.setVisibility(View.GONE); noPermissionsLayout.setVisibility(View.GONE); }
LayoutParams layoutParams = new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); layoutParams.topToTop = ConstraintSet.PARENT_ID;
@Override protected void onPostExecute(Void aVoid) { if (mHistoryAdapter != null) { mHistoryAdapter.deleteHistory(); } mEmptyStatusLayout.setVisibility(View.VISIBLE); } }