Skip to content
Open
Changes from 1 commit
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 @@ -324,6 +324,12 @@ protected interface OnAttachStateChangeListener {
void onViewDetachedFromWindow(View v);
}

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

/**
* Constructor for the transient bottom bar.
*
Expand Down Expand Up @@ -687,6 +693,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);
}
}
}
});
this.view.setOnAttachStateChangeListener(
new BaseTransientBottomBar.OnAttachStateChangeListener() {
@Override
Expand Down Expand Up @@ -1006,7 +1027,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 @@ -1077,6 +1098,7 @@ public boolean onTouch(View v, MotionEvent event) {

private BaseTransientBottomBar.OnLayoutChangeListener onLayoutChangeListener;
private BaseTransientBottomBar.OnAttachStateChangeListener onAttachStateChangeListener;
private BaseTransientBottomBar.OnMeasureListener onMeasureListener;
@AnimationMode private int animationMode;
private final float backgroundOverlayColorAlpha;
private final float actionTextColorAlpha;
Expand Down Expand Up @@ -1172,6 +1194,14 @@ 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 @@ -1200,6 +1230,10 @@ void setOnAttachStateChangeListener(
onAttachStateChangeListener = listener;
}

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

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