Permalink
Browse files

Revert 163d7c5^..HEAD

  • Loading branch information...
1 parent 163d7c5 commit 581c6789c3bc050b1581642e397f936994bebf1b @lsiegert committed Jul 1, 2011
View
@@ -4,5 +4,3 @@ bin/
.settings/
.classpath
.project
-
-res/.DS_Store
View
Binary file not shown.
@@ -1,6 +1,5 @@
package com.lsiegert;
-import java.net.URL;
import java.util.ArrayList;
import java.util.List;
@@ -4,6 +4,7 @@
import android.database.Cursor;
import android.os.Bundle;
import android.widget.ListView;
+import android.widget.SimpleCursorAdapter;
public class ScheduleActivity extends ListActivity {
private DatabaseHelper dbHelper = null;
@@ -32,8 +33,11 @@ public void onCreate(Bundle savedInstanceState) {
String season = seasons.getString(0);
Cursor games = dbHelper.getGamesBySeason(season);
startManagingCursor(games);
- ScheduleAdapter scheduleAdapter = new ScheduleAdapter(this, R.layout.schedule_row, games, null, null, dbHelper);
- adapter.addSection(season, scheduleAdapter);
+ //ScheduleAdapter scheduleAdapter = new ScheduleAdapter(this, R.layout.schedule_row, games, null, null, dbHelper);
+ SimpleCursorAdapter cursorAdapter = new SimpleCursorAdapter(this, R.layout.schedule_row, games, null, null);
+ ScheduleViewBinder viewBinder = new ScheduleViewBinder();
+ cursorAdapter.setViewBinder(viewBinder);
+ adapter.addSection(season, cursorAdapter);
seasons.moveToNext();
}
@@ -76,16 +76,22 @@ else if (nuscore < oppscore) {
else { gameScore.setTextColor(Color.WHITE); }
CheckBox checkBox = (CheckBox) convertView.findViewById(R.id.attended);
- checkBox.setTag(Integer.parseInt(this.games.getString(this.games.getColumnIndex("_id"))));
+
+ int tag = Integer.parseInt(this.games.getString(this.games.getColumnIndex("_id")));
+ checkBox.setTag(tag);
- if (this.games.getString(this.games.getColumnIndex("attended")) != null
- && Integer.parseInt(this.games.getString(this.games.getColumnIndex("attended"))) != 0) {
+ String attended = this.games.getString(this.games.getColumnIndex("attended"));
+ if (attended != null && Integer.parseInt(attended) != 0) {
+ checkBox.setOnCheckedChangeListener(null);
checkBox.setChecked(true);
} else {
+ checkBox.setOnCheckedChangeListener(null);
checkBox.setChecked(false);
}
checkBox.setOnClickListener(this);
+ System.out.println(this.games.getString(this.games.getColumnIndex("attended")));
+ //System.out.println(tag + " " + checkBox.isChecked() + " " + attended);
return convertView;
}
@@ -95,6 +101,6 @@ public void onClick(View view) {
ContentValues values = new ContentValues();
values.put(" attended", checkbox.isChecked() ? 1 : 0);
- this.dbHelper.myDb.update("Games", values, "_id=?", new String[]{Integer.toString(_id)});
+ this.dbHelper.myDb.update("Games", values, "_id=?", new String[]{Integer.toString(_id)});
}
}
@@ -0,0 +1,32 @@
+package com.lsiegert;
+
+import android.database.Cursor;
+import android.view.View;
+import android.widget.CheckBox;
+import android.widget.TextView;
+import android.widget.SimpleCursorAdapter.ViewBinder;
+
+public class ScheduleViewBinder implements ViewBinder {
+
+ public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
+ TextView opponent = (TextView) view.findViewById(R.id.opponent);
+ TextView score = (TextView) view.findViewById(R.id.score);
+ CheckBox attended = (CheckBox) view.findViewById(R.id.attended);
+
+ if (columnIndex == 7) {
+
+ return true;
+ }
+ else if (columnIndex == 4) {
+
+ }
+ else if (columnIndex == 5) {
+ return true;
+ }
+ else if (columnIndex == 3) {
+
+ return true;
+ }
+ return false;
+ }
+}

0 comments on commit 581c678

Please sign in to comment.