package com.icecondor.nest;

import android.app.ListActivity;
import android.database.Cursor;
import android.database.DataSetObserver;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ListAdapter;
import android.widget.SimpleCursorAdapter;

import com.icecondor.nest.db.GeoRss;

public class ActivityLog extends ListActivity {
	GeoRss rssdb;
	LogObserver logob;

	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activitylog);

        rssdb = new GeoRss(this);
		rssdb.open();		

		Cursor logs = rssdb.findActivityLogs();
        ListAdapter adapter=new SimpleCursorAdapter(this,
                R.layout.activitylog_row, logs,
                new String[] {"date", "description"},
                new int[] {R.id.date, R.id.description});
        logob = new LogObserver();
        setListAdapter(adapter);
	}
	
    @Override
    public void onPause() {
    	super.onPause();
    	rssdb.close();
    }
    
	public boolean onCreateOptionsMenu(Menu menu) {
		boolean result = super.onCreateOptionsMenu(menu);
		menu.add(Menu.NONE, 1, Menu.NONE, "Clear").setIcon(android.R.drawable.ic_delete);
		return result;
	}

	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case 1:
			rssdb.clearLog();
			break;
		}
		return false;
	}

	class LogObserver extends DataSetObserver {
		public void onChanged() {
		}
		public void onInvalidated() {
			
		}
	}
}



@@ -154,16 +154,41 @@
 Bundle;%0A
+import android.util.Log;%0A
 import a
@@ -235,16 +235,42 @@
 nuItem;%0A
+import android.view.View;%0A
 import a
@@ -338,16 +338,48 @@
 Adapter;
+%0Aimport android.widget.TextView;
 %0A%0Aimport
@@ -456,16 +456,127 @@
 ctivity 
+implements Constants, %0A                                                         SimpleCursorAdapter.ViewBinder 
 %7B%0A%09GeoRs
@@ -850,20 +850,28 @@
         
-List
+SimpleCursor
 Adapter 
@@ -877,17 +877,19 @@
  adapter
-=
+ = 
 new Simp
@@ -1101,24 +1101,61 @@
 Observer();%0A
+        adapter.setViewBinder(this);%0A
         setL
@@ -1710,51 +1710,556 @@
 %7B%0A%09%09
-%7D%0A%09%09public void onInvalidated() %7B%0A%09%09%09%0A%09%09%7D%0A%09
+    Log.i(%22LogObserver%22, %22changed!%22);%0A%09%09%7D%0A%09%09public void onInvalidated() %7B%0A            Log.i(%22LogObserver%22, %22invalidated!%22);%09%09%09%0A%09%09%7D%0A%09%7D%0A%0A    @Override%0A    public boolean setViewValue(View view, Cursor cursor, int columnIndex) %7B%0A        TextView tv = (TextView) view;%0A        String str = cursor.getString(columnIndex);%0A        Log.i(%22setViewValue%22,%22binding column %22+columnIndex);%0A        if(columnIndex == cursor.getColumnIndex(GeoRss.ACTIVITY_DATE)) %7B%0A            str = str.substring(11);%0A        %7D%0A        tv.setText(str);%0A        return true;%0A    
 %7D%0A%7D%0A

cut off the date in the log display