/**
 * 
 */
package com.simplenote.android.widget;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.simplenote.android.R;
import com.simplenote.android.model.Note;

/**
 * Specialized ListAdapter for converting Note objects into views based on the notes_row layout
 * @author bryanjswift
 */
public class NotesAdapter extends BaseAdapter {
	private final Context context;
	private Note[] notes;
	/**
	 * Default constructor for converting Note objects to ListView rows
	 * @param context where the notes are being viewed
	 * @param notes to use as data
	 */
	public NotesAdapter(Context context, Note[] notes) {
		this.context = context;
		this.notes = notes;
	}
	/**
	 * @see android.widget.Adapter#getCount()
	 */
	public int getCount() {
		return notes.length;
	}
	/**
	 * @see android.widget.Adapter#getItem(int)
	 */
	public Object getItem(int position) {
		return notes[position];
	}
	/**
	 * @see android.widget.Adapter#getItemId(int)
	 */
	public long getItemId(int position) {
		return notes[position].getId();
	}
	/**
	 * @see android.widget.Adapter#getView(int, android.view.View, android.view.ViewGroup)
	 */
	public View getView(int position, View convertView, ViewGroup parent) {
		final View result;
		if (convertView == null) {
			LayoutInflater inflater = LayoutInflater.from(context);
			LinearLayout row = (LinearLayout) inflater.inflate(R.layout.notes_row, parent, false);
			((TextView) row.findViewById(R.id.text_title)).setText(notes[position].getTitle());
			((TextView) row.findViewById(R.id.text_date)).setText(notes[position].getDateModified());
			result = row;
		} else {
			result = convertView;
		}
		return result;
	}
	/**
	 * @return the notes
	 */
	public final Note[] getNotes() {
		return notes;
	}
	/**
	 * @param notes the notes to set
	 */
	public final void setNotes(Note[] notes) {
		this.notes = notes;
	}
}

@@ -77,16 +77,41 @@
 ontext;%0A
+import android.util.Log;%0A
 import a
@@ -299,16 +299,57 @@
 tView;%0A%0A
+import com.simplenote.android.Constants;%0A
 import c
@@ -591,16 +591,91 @@
 apter %7B%0A
+%09private static final String LOGGING_TAG = Constants.TAG + %22NotesAdapter%22;%0A
 %09private
@@ -1532,19 +1532,154 @@
 nal 
-View result
+LinearLayout row;%0A%09%09Log.d(LOGGING_TAG, String.format(%22Getting view for '%25d' with title '%25s'%22,notes%5Bposition%5D.getId(), notes%5Bposition%5D.getTitle()))
 ;%0A%09%09
@@ -1767,29 +1767,16 @@
 xt);%0A%09%09%09
-LinearLayout 
 row = (L
@@ -1838,24 +1838,176 @@
 t, false);%0A%09
+%09%7D else %7B%0A%09%09%09Log.d(LOGGING_TAG, String.format(%22convertView class is '%25s'%22, convertView.getClass().getName()));%0A%09%09%09row = (LinearLayout) convertView;%0A%09%09%7D%0A
 %09%09((TextView
@@ -2080,17 +2080,16 @@
 tle());%0A
-%09
 %09%09((Text
@@ -2176,65 +2176,8 @@
 ));%0A
-%09%09%09result = row;%0A%09%09%7D else %7B%0A%09%09%09result = convertView;%0A%09%09%7D%0A
 %09%09re
@@ -2186,13 +2186,10 @@
 rn r
-esult
+ow
 ;%0A%09%7D

Fix getView of NotesAdapter to update the view passed in