Program: 168370
Project: 168370
Buggy source:
void addQuestion(Question question,LinearLayout parent){
  if (question.getQuestionOptions().getRendering().equals("String_Node_Str")) {
    LinearLayout questionLL=new LinearLayout(getActivity());
    questionLL.setOrientation(LinearLayout.VERTICAL);
    LinearLayout.LayoutParams layoutParams=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT);
    questionLL.setGravity(Gravity.CENTER);
    parent.addView(questionLL);
    Resources r=getActivity().getResources();
    float pxLeftMargin=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,5,r.getDisplayMetrics());
    float pxTopMargin=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,5,r.getDisplayMetrics());
    float pxRightMargin=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,5,r.getDisplayMetrics());
    float pxBottomMargin=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,5,r.getDisplayMetrics());
    layoutParams.setMargins(Math.round(pxLeftMargin),Math.round(pxTopMargin),Math.round(pxRightMargin),Math.round(pxBottomMargin));
    TextView tv=new TextView(getActivity());
    tv.setText(question.getLabel());
    tv.setTextSize(TypedValue.COMPLEX_UNIT_SP,18);
    tv.setTextColor(ContextCompat.getColor(getActivity(),R.color.primary));
    questionLL.addView(tv,layoutParams);
    for (    Question subquestion : question.getQuestions()) {
      addQuestion(subquestion,questionLL);
    }
  }
  if (question.getQuestionOptions().getRendering().equals("String_Node_Str")) {
    LinearLayout.LayoutParams layoutParams=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT);
    Resources r=getActivity().getResources();
    float pxLeftMargin=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,5,r.getDisplayMetrics());
    float pxTopMargin=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,5,r.getDisplayMetrics());
    float pxRightMargin=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,5,r.getDisplayMetrics());
    float pxBottomMargin=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,5,r.getDisplayMetrics());
    layoutParams.setMargins(Math.round(pxLeftMargin),Math.round(pxTopMargin),Math.round(pxRightMargin),Math.round(pxBottomMargin));
    EditText ed=new EditText(getActivity());
    if (question.getQuestionOptions().getMax() != null)     ed.setHint(question.getLabel() + "String_Node_Str" + question.getQuestionOptions().getMin()+ "String_Node_Str"+ question.getQuestionOptions().getMax()+ "String_Node_Str");
 else     ed.setHint(question.getLabel());
    ed.setTextSize(TypedValue.COMPLEX_UNIT_SP,16);
    ed.setInputType(InputType.TYPE_CLASS_NUMBER);
    int id=InputField.generateViewId();
    InputField field=new InputField();
    ed.setId(id);
    field.setId(id);
    field.setConcept(question.getQuestionOptions().getConcept());
    inputFields.add(field);
    parent.addView(ed,layoutParams);
  }
}

Fixed version (ground truth):
void addQuestion(Question question,LinearLayout parent){
  if (question.getQuestionOptions().getRendering().equals("String_Node_Str")) {
    LinearLayout questionLL=new LinearLayout(getActivity());
    questionLL.setOrientation(LinearLayout.VERTICAL);
    LinearLayout.LayoutParams layoutParams=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT);
    questionLL.setGravity(Gravity.CENTER);
    parent.addView(questionLL);
    Resources r=getActivity().getResources();
    float pxLeftMargin=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,5,r.getDisplayMetrics());
    float pxTopMargin=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,5,r.getDisplayMetrics());
    float pxRightMargin=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,5,r.getDisplayMetrics());
    float pxBottomMargin=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,5,r.getDisplayMetrics());
    layoutParams.setMargins(Math.round(pxLeftMargin),Math.round(pxTopMargin),Math.round(pxRightMargin),Math.round(pxBottomMargin));
    TextView tv=new TextView(getActivity());
    tv.setText(question.getLabel());
    tv.setTextSize(TypedValue.COMPLEX_UNIT_SP,18);
    tv.setTextColor(ContextCompat.getColor(getActivity(),R.color.primary));
    questionLL.addView(tv,layoutParams);
    for (    Question subquestion : question.getQuestions()) {
      addQuestion(subquestion,questionLL);
    }
  }
  if (question.getQuestionOptions().getRendering().equals("String_Node_Str")) {
    LinearLayout.LayoutParams layoutParams=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT);
    Resources r=getActivity().getResources();
    float pxLeftMargin=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,5,r.getDisplayMetrics());
    float pxTopMargin=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,5,r.getDisplayMetrics());
    float pxRightMargin=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,5,r.getDisplayMetrics());
    float pxBottomMargin=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,5,r.getDisplayMetrics());
    layoutParams.setMargins(Math.round(pxLeftMargin),Math.round(pxTopMargin),Math.round(pxRightMargin),Math.round(pxBottomMargin));
    RangeEditText ed=new RangeEditText(getActivity());
    ed.setName(question.getLabel());
    if (question.getQuestionOptions().getMax() != null) {
      ed.setHint(question.getLabel() + "String_Node_Str" + question.getQuestionOptions().getMin()+ "String_Node_Str"+ question.getQuestionOptions().getMax()+ "String_Node_Str");
      ed.setUpperlimit(Double.parseDouble(question.getQuestionOptions().getMax()));
      ed.setLowerlimit(Double.parseDouble(question.getQuestionOptions().getMin()));
    }
 else {
      ed.setHint(question.getLabel());
      ed.setLowerlimit(-1.0);
      ed.setUpperlimit(-1.0);
    }
    ed.setTextSize(TypedValue.COMPLEX_UNIT_SP,16);
    ed.setInputType(InputType.TYPE_CLASS_NUMBER);
    int id=InputField.generateViewId();
    InputField field=new InputField();
    ed.setId(id);
    field.setId(id);
    field.setConcept(question.getQuestionOptions().getConcept());
    inputFields.add(field);
    parent.addView(ed,layoutParams);
  }
}