@Override protected void onFinishInflate() { super.onFinishInflate(); mNameView = (TextView) findViewById(R.id.group_name); mTaskCountView = (TextView) findViewById(R.id.group_task_count); mNameView.setText(mGroup.getName()); mNameView.setTypeface(TaskTimerApplication.Typefaces.ROBOTO_LIGHT); Log.v(TAG, "Inflated"); }
@Override public View getView(int position, View convertView, ViewGroup parent) { TaskListItem v; if (convertView != null && convertView instanceof TaskListItem) { Log.v(TAG, "Converting old view"); v = (TaskListItem) convertView; v.setTask((Task) getItem(position)); v.setChecked(isItemChecked(position)); v.invalidate(); v.buildTimer(); } else { Log.v(TAG, "Getting new view"); v = new TaskListItem(mContext, null, (Task) getItem(position)); v.setChecked(isItemChecked(position)); } v.setTag(R.id.tag_task, position); v.setTag(R.id.tag_group, mGroupPosition); return v; }
/** * Insert a group * * @param values The values of the row * @return The URI for the new insertion */ public Uri groupInsert(ContentValues values) { SQLiteDatabase db = getWritableDatabase(); db.beginTransaction(); long rowID = -1; // Insert the row try { // Make sure the ID is unique Object value = values.get(Group.Columns._ID); if (value != null) { int id = (Integer) value; if (id > -1) { final Cursor cursor = db.query( "groups", new String[] {Group.Columns._ID}, "_id = ?", new String[] {Integer.toString(id)}, null, null, null); if (cursor.moveToFirst()) { // It exists! Remove the ID so SQLite fills in a new one values.putNull(Group.Columns._ID); } } } // Perform the insertion rowID = db.insert("groups", Task.Columns.NAME, values); db.setTransactionSuccessful(); } finally { db.endTransaction(); } // Insertion failure if (rowID < 0) throw new SQLException("Failed to insert row"); Log.v(TAG, "Added new group with ID " + rowID); return ContentUris.withAppendedId(Task.Columns.CONTENT_URI, rowID); }
@Override public Object getItem(int position) { Log.v(TAG, "Getting item #" + position); return mTasks.get(position); }