Program: 160206
Project: 160206
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  FragmentManager fragmentManager=getFragmentManager();
  squareFragment=new SquareFragment();
  fragmentManager.beginTransaction().replace(R.id.content_frame,squareFragment).commit();
  setContentView(R.layout.activity_main);
  title=drawerTitle=getTitle();
  partTitle=getResources().getStringArray(R.array.drawer_titel);
  descriptions=getResources().getStringArray(R.array.drawer_descriptions);
  drawerLayout=(DrawerLayout)findViewById(R.id.drawer_layout);
  drawerListView=(ListView)findViewById(R.id.left_drawer);
  drawerLayout.setDrawerShadow(R.drawable.drawer_shadow,GravityCompat.START);
  BaseAdapter adapter=new BaseAdapter(){
    @Override public View getView(    final int position,    View convertView,    ViewGroup parent){
      View item=convertView;
      View headerItem=LayoutInflater.from(getApplicationContext()).inflate(R.layout.lv_header_layout,parent,false);
      TextView title=(TextView)headerItem.findViewById(R.id.lv_list_hdr);
      View styleItem=LayoutInflater.from(getApplicationContext()).inflate(R.layout.lv_style,parent,false);
      CheckBox box=(CheckBox)styleItem.findViewById(R.id.checkBox1);
      View githubItem=LayoutInflater.from(getApplicationContext()).inflate(R.layout.lv_github,parent,false);
      TextView githublink=(TextView)githubItem.findViewById(R.id.textView1);
      View signerItem=LayoutInflater.from(getApplicationContext()).inflate(R.layout.lv_signer,parent,false);
      View imageItem=LayoutInflater.from(getApplicationContext()).inflate(R.layout.lv_image,parent,false);
      ImageView imagePreview=(ImageView)imageItem.findViewById(R.id.imageView1);
      TextView imageDesc=(TextView)imageItem.findViewById(R.id.imagetag);
switch (position) {
case 0:
        title.setText("String_Node_Str");
      return headerItem;
case 11:
    title.setText("String_Node_Str");
  return headerItem;
case 12:
box.setText(R.string.opacity);
box.setChecked(squareFragment.squareProgressBar.isOpacity());
box.setOnCheckedChangeListener(new OnCheckedChangeListener(){
@Override public void onCheckedChanged(CompoundButton buttonView,boolean isChecked){
squareFragment.squareProgressBar.setOpacity(isChecked);
}
}
);
return styleItem;
case 13:
title.setText("String_Node_Str");
return headerItem;
case 14:
imagePreview.setImageResource(R.drawable.city);
imageDesc.setText("String_Node_Str");
imageItem.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
squareFragment.squareProgressBar.setImage(R.drawable.city);
}
}
);
return imageItem;
case 15:
imagePreview.setImageResource(R.drawable.millennium_stadium);
imageDesc.setText("String_Node_Str");
imageItem.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
squareFragment.squareProgressBar.setImage(R.drawable.millennium_stadium);
}
}
);
return imageItem;
case 16:
imagePreview.setImageResource(R.drawable.edinburgh);
imageDesc.setText("String_Node_Str");
imageItem.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
squareFragment.squareProgressBar.setImage(R.drawable.edinburgh);
}
}
);
return imageItem;
case 17:
imagePreview.setImageResource(R.drawable.holyroodpark);
imageDesc.setText("String_Node_Str");
imageItem.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
squareFragment.squareProgressBar.setImage(R.drawable.holyroodpark);
}
}
);
return imageItem;
case 18:
title.setText("String_Node_Str");
return headerItem;
case 19:
String text="String_Node_Str";
githublink.setText(Html.fromHtml(text));
githubItem.setOnClickListener(new OnClickListener(){
@Override public void onClick(View arg0){
Intent browserIntent=new Intent(Intent.ACTION_VIEW,Uri.parse("String_Node_Str"));
startActivity(browserIntent);
}
}
);
return githubItem;
case 20:
signerItem.setOnClickListener(new OnClickListener(){
@Override public void onClick(View arg0){
Intent browserIntent=new Intent(Intent.ACTION_VIEW,Uri.parse("String_Node_Str"));
startActivity(browserIntent);
}
}
);
return signerItem;
default :
break;
}
ArrayList<Integer> colourArray=new ArrayList<Integer>();
colourArray.add(color.holo_blue_bright);
colourArray.add(color.holo_blue_dark);
colourArray.add(color.holo_blue_light);
colourArray.add(color.holo_green_dark);
colourArray.add(color.holo_green_light);
colourArray.add(color.holo_orange_dark);
colourArray.add(color.holo_orange_light);
colourArray.add(color.holo_purple);
colourArray.add(color.holo_red_dark);
colourArray.add(color.holo_red_light);
if (position <= 10) {
Context context=getApplicationContext();
item=LayoutInflater.from(context).inflate(R.layout.lv_colour,parent,false);
View colourView=item.findViewById(R.id.colour_preview);
final Integer integer=colourArray.get(position - 1);
colourView.setBackgroundColor(context.getResources().getColor(integer));
item.setOnClickListener(new OnClickListener(){
@Override public void onClick(View arg0){
squareFragment.squareProgressBar.setHoloColor(integer);
selectItem(position);
}
}
);
TextView textView=(TextView)item.findViewById(R.id.colour_name);
textView.setText(getName(position - 1));
}
return item;
}
@Override public long getItemId(int position){
return position;
}
@Override public Object getItem(int position){
return position;
}
@Override public int getCount(){
return 21;
}
}
;
drawerListView.setAdapter(adapter);
drawerListView.setOnItemClickListener(new DrawerItemClickListener());
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
drawerToggle=new ActionBarDrawerToggle(this,drawerLayout,R.drawable.ic_drawer,R.string.drawer_open,R.string.drawer_close){
@Override public void onDrawerClosed(View view){
getActionBar().setTitle(title);
invalidateOptionsMenu();
}
@Override public void onDrawerOpened(View drawerView){
getActionBar().setTitle(drawerTitle);
invalidateOptionsMenu();
}
}
;
drawerLayout.setDrawerListener(drawerToggle);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  FragmentManager fragmentManager=getFragmentManager();
  squareFragment=new SquareFragment();
  fragmentManager.beginTransaction().replace(R.id.content_frame,squareFragment).commit();
  setContentView(R.layout.activity_main);
  title=drawerTitle=getTitle();
  partTitle=getResources().getStringArray(R.array.drawer_titel);
  descriptions=getResources().getStringArray(R.array.drawer_descriptions);
  drawerLayout=(DrawerLayout)findViewById(R.id.drawer_layout);
  drawerListView=(ListView)findViewById(R.id.left_drawer);
  drawerLayout.setDrawerShadow(R.drawable.drawer_shadow,GravityCompat.START);
  BaseAdapter adapter=new BaseAdapter(){
    @Override public View getView(    final int position,    View convertView,    ViewGroup parent){
      View item=convertView;
      View headerItem=LayoutInflater.from(getApplicationContext()).inflate(R.layout.lv_header_layout,parent,false);
      TextView title=(TextView)headerItem.findViewById(R.id.lv_list_hdr);
      View styleItem=LayoutInflater.from(getApplicationContext()).inflate(R.layout.lv_style,parent,false);
      CheckBox box=(CheckBox)styleItem.findViewById(R.id.checkBox1);
      View githubItem=LayoutInflater.from(getApplicationContext()).inflate(R.layout.lv_github,parent,false);
      TextView githublink=(TextView)githubItem.findViewById(R.id.textView1);
      View signerItem=LayoutInflater.from(getApplicationContext()).inflate(R.layout.lv_signer,parent,false);
      View imageItem=LayoutInflater.from(getApplicationContext()).inflate(R.layout.lv_image,parent,false);
      ImageView imagePreview=(ImageView)imageItem.findViewById(R.id.imageView1);
      TextView imageDesc=(TextView)imageItem.findViewById(R.id.imagetag);
switch (position) {
case 0:
        title.setText("String_Node_Str");
      return headerItem;
case 11:
    title.setText("String_Node_Str");
  return headerItem;
case 12:
box.setText(R.string.opacity);
box.setChecked(squareFragment.squareProgressBar.isOpacity());
box.setOnCheckedChangeListener(new OnCheckedChangeListener(){
@Override public void onCheckedChanged(CompoundButton buttonView,boolean isChecked){
squareFragment.squareProgressBar.setOpacity(isChecked);
}
}
);
return styleItem;
case 13:
title.setText("String_Node_Str");
return headerItem;
case 14:
imagePreview.setImageResource(R.drawable.city);
imageDesc.setText("String_Node_Str");
imageItem.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
squareFragment.squareProgressBar.setImage(R.drawable.city);
}
}
);
return imageItem;
case 15:
imagePreview.setImageResource(R.drawable.millennium_stadium);
imageDesc.setText("String_Node_Str");
imageItem.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
squareFragment.squareProgressBar.setImage(R.drawable.millennium_stadium);
}
}
);
return imageItem;
case 16:
imagePreview.setImageResource(R.drawable.edinburgh);
imageDesc.setText("String_Node_Str");
imageItem.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
squareFragment.squareProgressBar.setImage(R.drawable.edinburgh);
}
}
);
return imageItem;
case 17:
imagePreview.setImageResource(R.drawable.holyroodpark);
imageDesc.setText("String_Node_Str");
imageItem.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
squareFragment.squareProgressBar.setImage(R.drawable.holyroodpark);
}
}
);
return imageItem;
case 18:
title.setText("String_Node_Str");
return headerItem;
case 19:
String text="String_Node_Str";
githublink.setText(Html.fromHtml(text));
githubItem.setOnClickListener(new OnClickListener(){
@Override public void onClick(View arg0){
Intent browserIntent=new Intent(Intent.ACTION_VIEW,Uri.parse("String_Node_Str"));
startActivity(browserIntent);
}
}
);
return githubItem;
case 20:
signerItem.setOnClickListener(new OnClickListener(){
@Override public void onClick(View arg0){
Intent browserIntent=new Intent(Intent.ACTION_VIEW,Uri.parse("String_Node_Str"));
startActivity(browserIntent);
}
}
);
return signerItem;
default :
break;
}
ArrayList<Integer> colourArray=new ArrayList<Integer>();
colourArray.add(color.holo_blue_bright);
colourArray.add(color.holo_blue_dark);
colourArray.add(color.holo_blue_light);
colourArray.add(color.holo_green_dark);
colourArray.add(color.holo_green_light);
colourArray.add(color.holo_orange_dark);
colourArray.add(color.holo_orange_light);
colourArray.add(color.holo_purple);
colourArray.add(color.holo_red_dark);
colourArray.add(color.holo_red_light);
if (position <= 10) {
Context context=getApplicationContext();
item=LayoutInflater.from(context).inflate(R.layout.lv_colour,parent,false);
View colourView=item.findViewById(R.id.colour_preview);
final Integer integer=colourArray.get(position - 1);
colourView.setBackgroundColor(context.getResources().getColor(integer));
item.setOnClickListener(new OnClickListener(){
@Override public void onClick(View arg0){
squareFragment.squareProgressBar.setHoloColor(integer);
selectItem(position);
lastPosition=position;
}
}
);
TextView textView=(TextView)item.findViewById(R.id.colour_name);
textView.setText(getName(position - 1));
}
return item;
}
@Override public long getItemId(int position){
return position;
}
@Override public Object getItem(int position){
return position;
}
@Override public int getCount(){
return 21;
}
}
;
drawerListView.setAdapter(adapter);
drawerListView.setOnItemClickListener(new DrawerItemClickListener());
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
drawerToggle=new ActionBarDrawerToggle(this,drawerLayout,R.drawable.ic_drawer,R.string.drawer_open,R.string.drawer_close){
@Override public void onDrawerClosed(View view){
getActionBar().setTitle(title);
invalidateOptionsMenu();
}
@Override public void onDrawerOpened(View drawerView){
getActionBar().setTitle(drawerTitle);
invalidateOptionsMenu();
}
}
;
drawerLayout.setDrawerListener(drawerToggle);
}