package course.labs.todomanager;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class ToDoListAdapter extends BaseAdapter {

	private final List<ToDoItem> mItems = new ArrayList<ToDoItem>();
	private final Context mContext;

	private static final String TAG = "Lab-UserInterface";

	public ToDoListAdapter(Context context) {

		mContext = context;

	}

	// Add a ToDoItem to the adapter
	// Notify observers that the data set has changed

	public void add(ToDoItem item) {

		mItems.add(item);
		notifyDataSetChanged();

	}

	// Clears the list adapter of all items.

	public void clear() {

		mItems.clear();
		notifyDataSetChanged();

	}

	// Returns the number of ToDoItems

	@Override
	public int getCount() {

		return mItems.size();

	}

	// Retrieve the number of ToDoItems

	@Override
	public Object getItem(int pos) {

		return mItems.get(pos);

	}

	// Get the ID for the ToDoItem
	// In this case it's just the position

	@Override
	public long getItemId(int pos) {

		return pos;

	}

	// Create a View for the ToDoItem at specified position
	// Remember to check whether convertView holds an already allocated View
	// before created a new View.
	// Consider using the ViewHolder pattern to make scrolling more efficient
	// See: http://developer.android.com/training/improving-layouts/smooth-scrolling.html
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		// TODO - Get the current ToDoItem
		final ToDoItem toDoItem = null;


		// TODO - Inflate the View for this ToDoItem
		// from todo_item.xml
		RelativeLayout itemLayout = null;

		// Fill in specific ToDoItem data
		// Remember that the data that goes in this View
		// corresponds to the user interface elements defined
		// in the layout file

		// TODO - Display Title in TextView
		final TextView titleView = null;


		// TODO - Set up Status CheckBox
		final CheckBox statusView = null;


		// TODO - Must also set up an OnCheckedChangeListener,
		// which is called when the user toggles the status checkbox

		statusView.setOnCheckedChangeListener(new OnCheckedChangeListener() {
					@Override
					public void onCheckedChanged(CompoundButton buttonView,
							boolean isChecked) {



                        
                        
                        
					}
				});

		// TODO - Display Priority in a TextView
		final TextView priorityView = null;



		// TODO - Display Time and Date.
		// Hint - use ToDoItem.FORMAT.format(toDoItem.getDate()) to get date and
		// time String
		final TextView dateView = null;

		// Return the View you just created
		return itemLayout;

	}
}

@@ -1831,20 +1831,36 @@
 oItem = 
-null
+mItems.get(position)
 ;%0A%0A%0A%09%09//
@@ -1932,40 +1932,163 @@
 l%0A%09%09
-RelativeLayout itemLayout = null
+LayoutInflater inflater = LayoutInflater.from(mContext);%0A%09%09RelativeLayout itemLayout = (RelativeLayout) inflater.inflate(R.layout.todo_item, parent, false)
 ;%0A%0A%09
@@ -2325,86 +2325,300 @@
 w = 
-null;%0A%0A%0A%09%09// TODO - Set up Status CheckBox%0A%09%09final CheckBox statusView = null;
+(TextView) itemLayout.findViewById(R.id.titleView);%0A%09%09titleView.setText(toDoItem.getTitle());%0A%0A%0A%09%09// TODO - Set up Status CheckBox%0A%09%09final CheckBox statusView = (CheckBox) itemLayout.findViewById(R.id.statusCheckBox);%0A%09%09statusView.setChecked(toDoItem.getStatus() == ToDoItem.Status.DONE);;%0A%09%09
 %0A%0A%0A%09
@@ -2812,18 +2812,16 @@
 () %7B%0A%09%09%09
-%09%09
 @Overrid
@@ -2822,18 +2822,16 @@
 verride%0A
-%09%09
 %09%09%09publi
@@ -2884,36 +2884,234 @@
 iew,
-%0A%09%09%09%09%09%09%09boolean isChecked) %7B
+ boolean isChecked) %7B%0A%09%09%09%09Log.i(TAG, %22Entered onCheckedChanged()%22);%0A%09%09%09%09if (isChecked)%7B %0A%09%09%09%09%09toDoItem.setStatus(ToDoItem.Status.DONE);%0A%09%09%09%09%09%7D%0A%09%09%09%09%09else%7B%0A%09%09%09%09%09%09toDoItem.setStatus(ToDoItem.Status.NOTDONE);%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D%0A%09%09%09%09%09%09%09%0A
 %0A%0A%0A%0A
@@ -3187,26 +3187,19 @@
      %0A%09%09
-%09%09%09%7D%0A%09%09%09%09%7D
+%7D%0A%09
 );%0A%0A%09%09//
@@ -3269,20 +3269,95 @@
 yView = 
-null
+(TextView) itemLayout.findItemById(R.id.priority???));%0A%09%09priorityView.setText()
 ;%0A%0A%0A%0A%09%09/
@@ -3512,12 +3512,56 @@
 w = 
-null
+TextView) itemLayout.findItemById(R.id.date???))
 ;%0A%0A%09

Update ToDoListAdapter.java