Program: 170746
Project: 170746
Buggy source:
@SuppressLint("String_Node_Str") @Override protected void onLayout(boolean changed,int l,int t,int r,int b){
switch (expandDirection) {
case EXPAND_UP:
case EXPAND_DOWN:
    boolean expandUp=expandDirection == EXPAND_UP;
  touchDelegateGroup.clearTouchDelegates();
int addButtonY=expandUp ? b - t - menuButton.getMeasuredHeight() : 0;
if (expandUp) addButtonY-=menuBottomMargin;
 else addButtonY+=menuTopMargin;
int buttonsHorizontalCenter=labelsPosition == LABELS_ON_LEFT_SIDE ? r - l - maxButtonWidth / 2 : maxButtonWidth / 2;
buttonsHorizontalCenter-=labelsPosition == LABELS_ON_LEFT_SIDE ? menuRightMargin : menuLeftMargin;
int addButtonLeft=buttonsHorizontalCenter - menuButton.getMeasuredWidth() / 2;
menuButton.layout(addButtonLeft,addButtonY,addButtonLeft + menuButton.getMeasuredWidth(),addButtonY + menuButton.getMeasuredHeight());
int labelsOffset=maxButtonWidth / 2 + labelsMargin;
int labelsXNearButton=labelsPosition == LABELS_ON_LEFT_SIDE ? buttonsHorizontalCenter - labelsOffset : buttonsHorizontalCenter + labelsOffset;
int nextY=expandUp ? addButtonY - buttonSpacing : addButtonY + menuButton.getMeasuredHeight() + buttonSpacing;
for (int i=buttonsCount - 1; i >= 0; i--) {
final View child=getChildAt(i);
if (child == menuButton || child.getVisibility() == GONE) continue;
int childX=buttonsHorizontalCenter - child.getMeasuredWidth() / 2;
int childY=expandUp ? nextY - child.getMeasuredHeight() : nextY;
child.layout(childX,childY,childX + child.getMeasuredWidth(),childY + child.getMeasuredHeight());
float collapsedTranslation=addButtonY - childY;
float expandedTranslation=0f;
child.setTranslationY(expanded ? expandedTranslation : collapsedTranslation);
child.setAlpha(expanded ? 1f : 0f);
LayoutParams params=(LayoutParams)child.getLayoutParams();
params.mCollapseDir.setFloatValues(expandedTranslation,collapsedTranslation);
params.mExpandDir.setFloatValues(collapsedTranslation,expandedTranslation);
params.setAnimationsTarget(child);
View label=(View)child.getTag(R.id.fab_label);
if (label != null) {
int labelXAwayFromButton=labelsPosition == LABELS_ON_LEFT_SIDE ? labelsXNearButton - label.getMeasuredWidth() : labelsXNearButton + label.getMeasuredWidth();
int labelLeft=labelsPosition == LABELS_ON_LEFT_SIDE ? labelXAwayFromButton : labelsXNearButton;
int labelRight=labelsPosition == LABELS_ON_LEFT_SIDE ? labelsXNearButton : labelXAwayFromButton;
int labelTop=childY - labelsVerticalOffset + (child.getMeasuredHeight() - label.getMeasuredHeight()) / 2;
label.layout(labelLeft,labelTop,labelRight,labelTop + label.getMeasuredHeight());
Rect touchArea=new Rect(Math.min(childX,labelLeft),childY - buttonSpacing / 2,Math.max(childX + child.getMeasuredWidth(),labelRight),childY + child.getMeasuredHeight() + buttonSpacing / 2);
touchDelegateGroup.addTouchDelegate(new TouchDelegate(touchArea,child));
label.setTranslationY(expanded ? expandedTranslation : collapsedTranslation);
label.setAlpha(expanded ? 1f : 0f);
LayoutParams labelParams=(LayoutParams)label.getLayoutParams();
labelParams.mCollapseDir.setFloatValues(expandedTranslation,collapsedTranslation);
labelParams.mExpandDir.setFloatValues(collapsedTranslation,expandedTranslation);
labelParams.setAnimationsTarget(label);
}
nextY=expandUp ? childY - buttonSpacing : childY + child.getMeasuredHeight() + buttonSpacing;
}
break;
case EXPAND_LEFT:
case EXPAND_RIGHT:
boolean expandLeft=expandDirection == EXPAND_LEFT;
int addButtonX=expandLeft ? r - l - menuButton.getMeasuredWidth() : 0;
if (expandLeft) addButtonX-=menuRightMargin;
 else addButtonX+=menuLeftMargin;
int addButtonTop=b - t - maxButtonHeight + (maxButtonHeight - menuButton.getMeasuredHeight()) / 2;
addButtonTop-=menuBottomMargin;
menuButton.layout(addButtonX,addButtonTop,addButtonX + menuButton.getMeasuredWidth(),addButtonTop + menuButton.getMeasuredHeight());
int nextX=expandLeft ? addButtonX - buttonSpacing : addButtonX + menuButton.getMeasuredWidth() + buttonSpacing;
for (int i=buttonsCount - 1; i >= 0; i--) {
final View child=getChildAt(i);
if (child == menuButton || child.getVisibility() == GONE) continue;
int childX=expandLeft ? nextX - child.getMeasuredWidth() : nextX;
int childY=addButtonTop + (menuButton.getMeasuredHeight() - child.getMeasuredHeight()) / 2;
child.layout(childX,childY,childX + child.getMeasuredWidth(),childY + child.getMeasuredHeight());
float collapsedTranslation=addButtonX - childX;
float expandedTranslation=0f;
child.setTranslationX(expanded ? expandedTranslation : collapsedTranslation);
child.setAlpha(expanded ? 1f : 0f);
LayoutParams params=(LayoutParams)child.getLayoutParams();
params.mCollapseDir.setFloatValues(expandedTranslation,collapsedTranslation);
params.mExpandDir.setFloatValues(collapsedTranslation,expandedTranslation);
params.setAnimationsTarget(child);
nextX=expandLeft ? childX - buttonSpacing : childX + child.getMeasuredWidth() + buttonSpacing;
}
break;
}
}

Fixed version (ground truth):
@SuppressLint("String_Node_Str") @Override protected void onLayout(boolean changed,int l,int t,int r,int b){
switch (expandDirection) {
case EXPAND_UP:
case EXPAND_DOWN:
    boolean expandUp=expandDirection == EXPAND_UP;
  touchDelegateGroup.clearTouchDelegates();
int addButtonY=expandUp ? b - t - menuButton.getMeasuredHeight() : 0;
if (expandUp) addButtonY-=menuBottomMargin;
 else addButtonY+=menuTopMargin;
int buttonsHorizontalCenter=labelsPosition == LABELS_ON_LEFT_SIDE ? r - l - maxButtonWidth / 2 : maxButtonWidth / 2;
buttonsHorizontalCenter-=labelsPosition == LABELS_ON_LEFT_SIDE ? menuRightMargin : -menuLeftMargin;
int addButtonLeft=buttonsHorizontalCenter - menuButton.getMeasuredWidth() / 2;
menuButton.layout(addButtonLeft,addButtonY,addButtonLeft + menuButton.getMeasuredWidth(),addButtonY + menuButton.getMeasuredHeight());
int labelsOffset=maxButtonWidth / 2 + labelsMargin;
int labelsXNearButton=labelsPosition == LABELS_ON_LEFT_SIDE ? buttonsHorizontalCenter - labelsOffset : buttonsHorizontalCenter + labelsOffset;
int nextY=expandUp ? addButtonY - buttonSpacing : addButtonY + menuButton.getMeasuredHeight() + buttonSpacing;
for (int i=buttonsCount - 1; i >= 0; i--) {
final View child=getChildAt(i);
if (child == menuButton || child.getVisibility() == GONE) continue;
int childX=buttonsHorizontalCenter - child.getMeasuredWidth() / 2;
int childY=expandUp ? nextY - child.getMeasuredHeight() : nextY;
child.layout(childX,childY,childX + child.getMeasuredWidth(),childY + child.getMeasuredHeight());
float collapsedTranslation=addButtonY - childY;
float expandedTranslation=0f;
child.setTranslationY(expanded ? expandedTranslation : collapsedTranslation);
child.setAlpha(expanded ? 1f : 0f);
LayoutParams params=(LayoutParams)child.getLayoutParams();
params.mCollapseDir.setFloatValues(expandedTranslation,collapsedTranslation);
params.mExpandDir.setFloatValues(collapsedTranslation,expandedTranslation);
params.setAnimationsTarget(child);
View label=(View)child.getTag(R.id.fab_label);
if (label != null) {
int labelXAwayFromButton=labelsPosition == LABELS_ON_LEFT_SIDE ? labelsXNearButton - label.getMeasuredWidth() : labelsXNearButton + label.getMeasuredWidth();
int labelLeft=labelsPosition == LABELS_ON_LEFT_SIDE ? labelXAwayFromButton : labelsXNearButton;
int labelRight=labelsPosition == LABELS_ON_LEFT_SIDE ? labelsXNearButton : labelXAwayFromButton;
int labelTop=childY - labelsVerticalOffset + (child.getMeasuredHeight() - label.getMeasuredHeight()) / 2;
label.layout(labelLeft,labelTop,labelRight,labelTop + label.getMeasuredHeight());
Rect touchArea=new Rect(Math.min(childX,labelLeft),childY - buttonSpacing / 2,Math.max(childX + child.getMeasuredWidth(),labelRight),childY + child.getMeasuredHeight() + buttonSpacing / 2);
touchDelegateGroup.addTouchDelegate(new TouchDelegate(touchArea,child));
label.setTranslationY(expanded ? expandedTranslation : collapsedTranslation);
label.setAlpha(expanded ? 1f : 0f);
LayoutParams labelParams=(LayoutParams)label.getLayoutParams();
labelParams.mCollapseDir.setFloatValues(expandedTranslation,collapsedTranslation);
labelParams.mExpandDir.setFloatValues(collapsedTranslation,expandedTranslation);
labelParams.setAnimationsTarget(label);
}
nextY=expandUp ? childY - buttonSpacing : childY + child.getMeasuredHeight() + buttonSpacing;
}
break;
case EXPAND_LEFT:
case EXPAND_RIGHT:
boolean expandLeft=expandDirection == EXPAND_LEFT;
int addButtonX=expandLeft ? r - l - menuButton.getMeasuredWidth() : 0;
if (expandLeft) addButtonX-=menuRightMargin;
 else addButtonX+=menuLeftMargin;
int addButtonTop=b - t - maxButtonHeight + (maxButtonHeight - menuButton.getMeasuredHeight()) / 2;
addButtonTop-=menuBottomMargin;
menuButton.layout(addButtonX,addButtonTop,addButtonX + menuButton.getMeasuredWidth(),addButtonTop + menuButton.getMeasuredHeight());
int nextX=expandLeft ? addButtonX - buttonSpacing : addButtonX + menuButton.getMeasuredWidth() + buttonSpacing;
for (int i=buttonsCount - 1; i >= 0; i--) {
final View child=getChildAt(i);
if (child == menuButton || child.getVisibility() == GONE) continue;
int childX=expandLeft ? nextX - child.getMeasuredWidth() : nextX;
int childY=addButtonTop + (menuButton.getMeasuredHeight() - child.getMeasuredHeight()) / 2;
child.layout(childX,childY,childX + child.getMeasuredWidth(),childY + child.getMeasuredHeight());
float collapsedTranslation=addButtonX - childX;
float expandedTranslation=0f;
child.setTranslationX(expanded ? expandedTranslation : collapsedTranslation);
child.setAlpha(expanded ? 1f : 0f);
LayoutParams params=(LayoutParams)child.getLayoutParams();
params.mCollapseDir.setFloatValues(expandedTranslation,collapsedTranslation);
params.mExpandDir.setFloatValues(collapsedTranslation,expandedTranslation);
params.setAnimationsTarget(child);
nextX=expandLeft ? childX - buttonSpacing : childX + child.getMeasuredWidth() + buttonSpacing;
}
break;
}
}