Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,12 @@ public void run() {

@Nullable private final AccessibilityManager accessibilityManager;

/** @hide */
@RestrictTo(LIBRARY_GROUP)
protected interface OnMeasureListener {
void onMeasure(View v);
}

/**
* Constructor for the transient bottom bar.
*
Expand Down Expand Up @@ -747,6 +753,21 @@ protected SwipeDismissBehavior<? extends View> getNewBehavior() {
}

final void showView() {
this.view.setOnMeasureListener(new OnMeasureListener()
{
@Override
public void onMeasure(View v)
{
if (view.getAnimationMode() == ANIMATION_MODE_SLIDE && shouldAnimate()) {
int translationYBottom = getTranslationYBottom();
if (USE_OFFSET_API) {
ViewCompat.offsetTopAndBottom(view, translationYBottom);
} else {
view.setTranslationY(translationYBottom);
}
}
}
});
if (this.view.getParent() == null) {
ViewGroup.LayoutParams lp = this.view.getLayoutParams();

Expand Down Expand Up @@ -1076,7 +1097,7 @@ public void onAnimationUpdate(@NonNull ValueAnimator animator) {
}

private int getTranslationYBottom() {
int translationY = view.getHeight();
int translationY = view.getMeasuredHeight();
LayoutParams layoutParams = view.getLayoutParams();
if (layoutParams instanceof MarginLayoutParams) {
translationY += ((MarginLayoutParams) layoutParams).bottomMargin;
Expand Down Expand Up @@ -1148,6 +1169,7 @@ public boolean onTouch(View v, MotionEvent event) {
}
};

private BaseTransientBottomBar.OnMeasureListener onMeasureListener;
@Nullable private BaseTransientBottomBar<?> baseTransientBottomBar;
@Nullable ShapeAppearanceModel shapeAppearanceModel;
@AnimationMode private int animationMode;
Expand Down Expand Up @@ -1269,6 +1291,13 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {
}
}

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (onMeasureListener != null)
onMeasureListener.onMeasure(this);
}

@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
Expand Down Expand Up @@ -1300,6 +1329,10 @@ public void setLayoutParams(ViewGroup.LayoutParams params) {
}
}

void setOnMeasureListener(BaseTransientBottomBar.OnMeasureListener listener) {
onMeasureListener = listener;
}

@AnimationMode
int getAnimationMode() {
return animationMode;
Expand Down