Program: 20433
Project: 20433
Buggy source:
private LinearLayout createNavigationItemView(final NavigationItem item){
  if (item.search) {
    SearchLayout searchLayout=new SearchLayout(getContext());
    searchLayout.setCallback(new SearchLayout.SearchLayoutCallback(){
      @Override public void onSearchEntered(      String entered){
        item.searchText=entered;
        callback.onSearchEntered(item,entered);
      }
    }
);
    if (item.searchText != null) {
      searchLayout.setText(item.searchText);
    }
    searchLayout.setHint(callback.getSearchHint(item));
    if (openKeyboardAfterSearchViewCreated) {
      openKeyboardAfterSearchViewCreated=false;
      searchLayout.openKeyboard();
    }
    searchLayout.setPadding(dp(16),searchLayout.getPaddingTop(),searchLayout.getPaddingRight(),searchLayout.getPaddingBottom());
    return searchLayout;
  }
 else {
    @SuppressLint("String_Node_Str") LinearLayout menu=(LinearLayout)LayoutInflater.from(getContext()).inflate(R.layout.toolbar_menu,null);
    menu.setGravity(Gravity.CENTER_VERTICAL);
    FrameLayout titleContainer=(FrameLayout)menu.findViewById(R.id.title_container);
    final TextView titleView=(TextView)menu.findViewById(R.id.title);
    titleView.setTypeface(AndroidUtils.ROBOTO_MEDIUM);
    titleView.setText(item.title);
    titleView.setTextColor(0xffffffff);
    if (item.middleMenu != null) {
      item.middleMenu.setAnchor(titleView,Gravity.LEFT,dp(5),dp(5));
      Drawable drawable=new DropdownArrowDrawable(dp(12),dp(12),true,getAttrColor(getContext(),R.attr.dropdown_light_color),getAttrColor(getContext(),R.attr.dropdown_light_pressed_color));
      titleView.setCompoundDrawablesWithIntrinsicBounds(null,null,drawable,null);
      titleView.setOnClickListener(new OnClickListener(){
        @Override public void onClick(        View v){
          item.middleMenu.show();
        }
      }
);
    }
    TextView subtitleView=(TextView)menu.findViewById(R.id.subtitle);
    if (!TextUtils.isEmpty(item.subtitle)) {
      ViewGroup.LayoutParams titleParams=titleView.getLayoutParams();
      titleParams.height=ViewGroup.LayoutParams.WRAP_CONTENT;
      titleView.setLayoutParams(titleParams);
      subtitleView.setText(item.subtitle);
      subtitleView.setTextColor(0xffffffff);
      titleView.setPadding(titleView.getPaddingLeft(),dp(5f),titleView.getPaddingRight(),titleView.getPaddingBottom());
    }
 else {
      titleContainer.removeView(subtitleView);
    }
    if (item.rightView != null) {
      item.rightView.setPadding(0,0,dp(16),0);
      menu.addView(item.rightView,new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.MATCH_PARENT));
    }
    if (item.menu != null) {
      menu.addView(item.menu,new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.MATCH_PARENT));
    }
    AndroidUtils.waitForMeasure(titleView,new AndroidUtils.OnMeasuredCallback(){
      @Override public boolean onMeasured(      View view){
        if (item.middleMenu != null) {
          item.middleMenu.setPopupWidth(Math.max(dp(200),titleView.getWidth()));
        }
        return false;
      }
    }
);
    return menu;
  }
}

Fixed version (ground truth):
private LinearLayout createNavigationItemView(final NavigationItem item){
  if (item.search) {
    SearchLayout searchLayout=new SearchLayout(getContext());
    searchLayout.setCallback(new SearchLayout.SearchLayoutCallback(){
      @Override public void onSearchEntered(      String entered){
        item.searchText=entered;
        callback.onSearchEntered(item,entered);
      }
    }
);
    if (item.searchText != null) {
      searchLayout.setText(item.searchText);
    }
    searchLayout.setHint(callback.getSearchHint(item));
    if (openKeyboardAfterSearchViewCreated) {
      openKeyboardAfterSearchViewCreated=false;
      searchLayout.openKeyboard();
    }
    searchLayout.setPadding(dp(16),searchLayout.getPaddingTop(),searchLayout.getPaddingRight(),searchLayout.getPaddingBottom());
    return searchLayout;
  }
 else {
    @SuppressLint("String_Node_Str") LinearLayout menu=(LinearLayout)LayoutInflater.from(getContext()).inflate(R.layout.toolbar_menu,null);
    menu.setGravity(Gravity.CENTER_VERTICAL);
    FrameLayout titleContainer=(FrameLayout)menu.findViewById(R.id.title_container);
    final TextView titleView=(TextView)menu.findViewById(R.id.title);
    titleView.setTypeface(AndroidUtils.ROBOTO_MEDIUM);
    titleView.setText(item.title);
    titleView.setTextColor(0xffffffff);
    if (item.middleMenu != null) {
      item.middleMenu.setAnchor(titleView,Gravity.LEFT,dp(5),dp(5));
      Drawable drawable=new DropdownArrowDrawable(dp(12),dp(12),true,getAttrColor(getContext(),R.attr.dropdown_light_color),getAttrColor(getContext(),R.attr.dropdown_light_pressed_color));
      titleView.setCompoundDrawablesWithIntrinsicBounds(null,null,drawable,null);
      titleView.setOnClickListener(new OnClickListener(){
        @Override public void onClick(        View v){
          item.middleMenu.show();
        }
      }
);
    }
    TextView subtitleView=(TextView)menu.findViewById(R.id.subtitle);
    if (!TextUtils.isEmpty(item.subtitle)) {
      ViewGroup.LayoutParams titleParams=titleView.getLayoutParams();
      titleParams.height=ViewGroup.LayoutParams.WRAP_CONTENT;
      titleView.setLayoutParams(titleParams);
      subtitleView.setText(item.subtitle);
      subtitleView.setTextColor(0xffffffff);
      titleView.setPadding(titleView.getPaddingLeft(),dp(5f),titleView.getPaddingRight(),titleView.getPaddingBottom());
    }
 else {
      titleContainer.removeView(subtitleView);
    }
    if (item.rightView != null) {
      item.rightView.setPadding(0,0,dp(16),0);
      menu.addView(item.rightView,new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.MATCH_PARENT));
    }
    if (item.menu != null) {
      menu.addView(item.menu,new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.MATCH_PARENT));
    }
    if (item.middleMenu != null) {
      item.middleMenu.setPopupWidth(FloatingMenu.POPUP_WIDTH_ANCHOR);
    }
    return menu;
  }
}