Program: 187243
Project: 187243
Buggy source:
private void initActivityList(View view){
  LinearLayout lView=(LinearLayout)view;
  LinearLayout.LayoutParams lp1=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT);
  lp1.setMargins(0,30,0,5);
  LinearLayout.LayoutParams lp2=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT);
  lp2.setMargins(40,0,0,0);
  Context context=view.getContext();
  Button button;
  Drawable img;
  button=new Button(context);
  button.setText(R.string.home_new_story);
  button.setBackgroundColor(Color.WHITE);
  img=context.getResources().getDrawable(R.drawable.ic_list_projects);
  img.setBounds(0,0,80,60);
  button.setCompoundDrawables(img,null,null,null);
  button.setGravity(Gravity.LEFT | Gravity.CENTER);
  button.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      startActivity(new Intent(getActivity(),LessonsActivity.class));
    }
  }
);
  lView.addView(button,lp1);
  ArrayList<Project> listProjects=Project.getAllAsList(context);
  for (int i=listProjects.size() - 1; i > listProjects.size() - 3 && i > -1; i--) {
    Project project=listProjects.get(i);
    button=new Button(context);
    button.setText(project.getTitle());
    button.setBackgroundColor(Color.WHITE);
    button.setGravity(Gravity.LEFT | Gravity.CENTER);
    button.setOnClickListener(new OnClickListener(){
      @Override public void onClick(      View v){
        startActivity(new Intent(getActivity(),StoryNewActivity.class));
      }
    }
);
    Media[] mediaList=project.getMediaAsArray();
    if (mediaList != null && mediaList.length > 0) {
      for (      Media media : mediaList)       if (media != null) {
        img=getThumbnailDrawable(media);
        if (img != null) {
          img.setBounds(0,0,60,60);
          button.setCompoundDrawables(img,null,null,null);
          break;
        }
      }
    }
    lView.addView(button,lp2);
  }
  button=new Button(context);
  button.setText(R.string.home_start_a_lesson);
  button.setBackgroundColor(Color.WHITE);
  img=context.getResources().getDrawable(R.drawable.ic_list_lessons);
  img.setBounds(0,0,60,60);
  button.setCompoundDrawables(img,null,null,null);
  button.setGravity(Gravity.LEFT | Gravity.CENTER);
  button.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      startActivity(new Intent(getActivity(),LessonsActivity.class));
    }
  }
);
  lView.addView(button,lp1);
  ArrayList<Lesson> lessonsCompleted=getLessonsCompleted(context);
  for (int i=lessonsCompleted.size() - 1; i > lessonsCompleted.size() - 3 && i > -1; i--) {
    Lesson lesson=lessonsCompleted.get(i);
    button=new Button(context);
    button.setText(lesson.mTitle + "String_Node_Str");
    button.setBackgroundColor(Color.WHITE);
    button.setGravity(Gravity.LEFT | Gravity.CENTER);
    button.setOnClickListener(new OnClickListener(){
      @Override public void onClick(      View v){
        startActivity(new Intent(getActivity(),LessonsActivity.class));
      }
    }
);
    lView.addView(button,lp2);
  }
}

Fixed version (ground truth):
private void initActivityList(View view){
  LinearLayout lView=(LinearLayout)view;
  LinearLayout.LayoutParams lp1=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT);
  lp1.setMargins(0,30,0,5);
  LinearLayout.LayoutParams lp2=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT);
  lp2.setMargins(40,0,0,0);
  Context context=view.getContext();
  Button button;
  Drawable img;
  button=new Button(context);
  button.setText(R.string.home_new_story);
  button.setBackgroundColor(Color.WHITE);
  img=context.getResources().getDrawable(R.drawable.ic_list_projects);
  img.setBounds(0,0,80,60);
  button.setCompoundDrawables(img,null,null,null);
  button.setGravity(Gravity.LEFT | Gravity.CENTER);
  button.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      startActivity(new Intent(getActivity(),StoryNewActivity.class));
    }
  }
);
  lView.addView(button,lp1);
  ArrayList<Project> listProjects=Project.getAllAsList(context);
  for (int i=listProjects.size() - 1; i > listProjects.size() - 3 && i > -1; i--) {
    Project project=listProjects.get(i);
    button=new Button(context);
    button.setText(project.getTitle());
    button.setBackgroundColor(Color.WHITE);
    button.setGravity(Gravity.LEFT | Gravity.CENTER);
    button.setOnClickListener(new OnClickListener(){
      @Override public void onClick(      View v){
        showProject(((Button)v).getText().toString());
      }
    }
);
    Media[] mediaList=project.getMediaAsArray();
    if (mediaList != null && mediaList.length > 0) {
      for (      Media media : mediaList)       if (media != null) {
        img=getThumbnailDrawable(media);
        if (img != null) {
          img.setBounds(0,0,30,30);
          button.setCompoundDrawables(img,null,null,null);
          break;
        }
      }
    }
    lView.addView(button,lp2);
  }
  button=new Button(context);
  button.setText(R.string.home_start_a_lesson);
  button.setBackgroundColor(Color.WHITE);
  img=context.getResources().getDrawable(R.drawable.ic_list_lessons);
  img.setBounds(0,0,60,60);
  button.setCompoundDrawables(img,null,null,null);
  button.setGravity(Gravity.LEFT | Gravity.CENTER);
  button.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      startActivity(new Intent(getActivity(),LessonsActivity.class));
    }
  }
);
  lView.addView(button,lp1);
  ArrayList<Lesson> lessonsCompleted=getLessonsCompleted(context);
  for (int i=lessonsCompleted.size() - 1; i > lessonsCompleted.size() - 3 && i > -1; i--) {
    Lesson lesson=lessonsCompleted.get(i);
    button=new Button(context);
    button.setText(lesson.mTitle + "String_Node_Str");
    button.setBackgroundColor(Color.WHITE);
    button.setGravity(Gravity.LEFT | Gravity.CENTER);
    button.setOnClickListener(new OnClickListener(){
      @Override public void onClick(      View v){
        startActivity(new Intent(getActivity(),LessonsActivity.class));
      }
    }
);
    lView.addView(button,lp2);
  }
}