Program: 3030
Project: 3030
Buggy source:
/** 
 * Renders the Views(the squares in the Grid). A bit "hackish" in the sense that we put in time as textview for the first slots to represent the time.
 */
public View getView(int position,View convertView,ViewGroup parent){
  if (position < ZOOMTYPE.getColumns()) {
    Log.i(this.getClass().getSimpleName() + "String_Node_Str","String_Node_Str" + ZOOMTYPE.toString());
    TextView textView=new TextView(mContext);
switch (ZOOMTYPE.getType()) {
case Utilities.DAY_MODE:
      textView.setText("String_Node_Str" + String.valueOf(position) + "String_Node_Str");
    textView.setTag(position);
  break;
case Utilities.HOUR_MODE:
textView.setText("String_Node_Str" + getZoomDate().getHours() + "String_Node_Str"+ getMinuteOnPosition(position));
break;
case Utilities.WEEK_MODE:
Calendar cal2=Calendar.getInstance();
cal2.setTime(Utilities.getFirstDayOfWeek(getZoomDate()));
cal2.add(Calendar.DATE,(position));
int displayDate=cal2.get(Calendar.DAY_OF_MONTH);
int displaymonth=cal2.get(Calendar.MONTH);
textView.setText("String_Node_Str" + displayDate + "String_Node_Str"+ (displaymonth + 1));
textView.setTag(cal2.getTime());
break;
case Utilities.MONTH_MODE:
textView.setText("String_Node_Str" + Utilities.getDayName(position));
Calendar monthCal=Calendar.getInstance();
monthCal.setTime(Utilities.getFirstDayOfWeek(getZoomDate()));
monthCal.set(Calendar.DAY_OF_MONTH,1);
textView.setTag(-1);
break;
default :
break;
}
textView.setGravity(Gravity.CENTER_HORIZONTAL);
textView.setTextSize(12);
textView.setTextColor(mContext.getResources().getColor(android.R.color.black));
textView.setPadding(0,0,0,10);
((AdapterView<?>)parent).setOnItemClickListener(new OnItemClickListener(){
public void onItemClick(AdapterView<?> arg0,View v,int arg2,long arg3){
handleClick(v);
}
}
);
return textView;
}
 else {
if (ZOOMTYPE == Zoom.MONTH) {
((AdapterView<?>)parent).setOnLongClickListener(null);
((AdapterView<?>)parent).setOnCreateContextMenuListener(null);
TextView textView=new TextView(mContext);
try {
textView.setText(String.valueOf(Utilities.convertGridPositionToDate(position,getZoomDate()).getDate()));
}
 catch (NullPointerException e) {
textView.setText("String_Node_Str");
}
textView.setGravity(Gravity.CENTER);
textView.setTextSize(18);
textView.setPadding(10,6,10,6);
if (displayedEvents.containsKey(position)) {
textView.setTextColor(mContext.getResources().getColor(R.color.Green));
textView.setTag(Utilities.convertGridPositionToDate(position,getZoomDate()));
}
 else {
textView.setTextColor(mContext.getResources().getColor(android.R.color.black));
textView.setTag(null);
}
((AdapterView<?>)parent).setOnItemClickListener(new OnItemClickListener(){
public void onItemClick(AdapterView<?> arg0,View v,int arg2,long arg3){
handleClick(v);
}
}
);
return textView;
}
{
ImageView imageView;
imageView=new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(40,40));
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setPadding(0,0,0,0);
if (displayedEvents.containsKey(Integer.valueOf(position))) {
BaseEvent ex=displayedEvents.get(position);
imageView.setTag(ex);
if (ex instanceof Event) {
imageView.setImageResource(Utilities.getImageIcon((Event)ex));
}
 else if (ex instanceof MoodEvent) {
imageView.setImageResource(((MoodEvent)ex).getMood().getIcon());
}
imageView.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
handleClick(v);
}
}
);
imageView.setOnCreateContextMenuListener(new OnCreateContextMenuListener(){
public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
menu.add(R.id.MENU_DELETE_EVENT,0,0,R.string.Delete_event_label);
}
}
);
imageView.setOnLongClickListener(new View.OnLongClickListener(){
public boolean onLongClick(View v){
((TimelineActivity)mActivity).setSelectedEvent((Event)v.getTag());
Log.i(TimelineGridAdapter.class.toString(),"String_Node_Str" + ((Event)v.getTag()).getId());
return false;
}
}
);
}
return imageView;
}
}
}

Fixed version (ground truth):
/** 
 * Renders the Views(the squares in the Grid). A bit "hackish" in the sense that we put in time as textview for the first slots to represent the time.
 */
public View getView(int position,View convertView,ViewGroup parent){
  if (position < ZOOMTYPE.getColumns()) {
    Log.i(this.getClass().getSimpleName() + "String_Node_Str","String_Node_Str" + ZOOMTYPE.toString());
    TextView textView=new TextView(mContext);
switch (ZOOMTYPE.getType()) {
case Utilities.DAY_MODE:
      textView.setText("String_Node_Str" + String.valueOf(position) + "String_Node_Str");
    textView.setTag(position);
  break;
case Utilities.HOUR_MODE:
textView.setText("String_Node_Str" + getZoomDate().getHours() + "String_Node_Str"+ getMinuteOnPosition(position));
break;
case Utilities.WEEK_MODE:
Calendar cal2=Calendar.getInstance();
cal2.setTime(Utilities.getFirstDayOfWeek(getZoomDate()));
cal2.add(Calendar.DATE,(position));
int displayDate=cal2.get(Calendar.DAY_OF_MONTH);
int displaymonth=cal2.get(Calendar.MONTH);
textView.setText("String_Node_Str" + displayDate + "String_Node_Str"+ (displaymonth + 1));
textView.setTag(cal2.getTime());
break;
case Utilities.MONTH_MODE:
textView.setText("String_Node_Str" + Utilities.getDayName(position));
Calendar monthCal=Calendar.getInstance();
monthCal.setTime(Utilities.getFirstDayOfWeek(getZoomDate()));
monthCal.set(Calendar.DAY_OF_MONTH,1);
textView.setTag(-1);
break;
default :
break;
}
textView.setGravity(Gravity.CENTER_HORIZONTAL);
textView.setTextSize(12);
textView.setTextColor(mContext.getResources().getColor(android.R.color.black));
textView.setPadding(0,0,0,10);
((AdapterView<?>)parent).setOnItemClickListener(new OnItemClickListener(){
public void onItemClick(AdapterView<?> arg0,View v,int arg2,long arg3){
handleClick(v);
}
}
);
return textView;
}
 else {
if (ZOOMTYPE == Zoom.MONTH) {
((AdapterView<?>)parent).setOnLongClickListener(null);
((AdapterView<?>)parent).setOnCreateContextMenuListener(null);
TextView textView=new TextView(mContext);
try {
textView.setText(String.valueOf(Utilities.convertGridPositionToDate(position,getZoomDate()).getDate()));
}
 catch (NullPointerException e) {
textView.setText("String_Node_Str");
}
textView.setGravity(Gravity.CENTER);
textView.setTextSize(18);
textView.setPadding(10,6,10,6);
if (displayedEvents.containsKey(position)) {
textView.setTextColor(mContext.getResources().getColor(R.color.Green));
textView.setTag(Utilities.convertGridPositionToDate(position,getZoomDate()));
}
 else {
textView.setTextColor(mContext.getResources().getColor(android.R.color.black));
textView.setTag(null);
}
((AdapterView<?>)parent).setOnItemClickListener(new OnItemClickListener(){
public void onItemClick(AdapterView<?> arg0,View v,int arg2,long arg3){
handleClick(v);
}
}
);
return textView;
}
{
ImageView imageView;
imageView=new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(40,40));
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setPadding(0,0,0,0);
if (displayedEvents.containsKey(Integer.valueOf(position))) {
BaseEvent ex=displayedEvents.get(position);
imageView.setTag(ex);
if (ex instanceof Event) {
imageView.setImageResource(Utilities.getImageIcon((Event)ex));
}
 else if (ex instanceof MoodEvent) {
imageView.setImageResource(((MoodEvent)ex).getMood().getIcon());
}
imageView.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
handleClick(v);
}
}
);
if (imageView.getTag() instanceof Event) {
imageView.setOnCreateContextMenuListener(new OnCreateContextMenuListener(){
public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
menu.add(R.id.MENU_DELETE_EVENT,0,0,R.string.Delete_event_label);
}
}
);
imageView.setOnLongClickListener(new View.OnLongClickListener(){
public boolean onLongClick(View v){
((TimelineActivity)mActivity).setSelectedEvent((Event)v.getTag());
Log.i(TimelineGridAdapter.class.toString(),"String_Node_Str" + ((Event)v.getTag()).getId());
return false;
}
}
);
}
}
return imageView;
}
}
}