~david-ergo/astrid/removed-attributes-sync-fix

« back to all changes in this revision

Viewing changes to src/com/timsu/astrid/data/tag/TagController.java

  • Committer: Tim Su
  • Date: 2010-01-22 07:29:12 UTC
  • mfrom: (225.4.6 provider)
  • Revision ID: tim@todoroo.com-20100122072912-50i9tvi7hx1pprlg
Merge with 1/16 updates to koxx3 provider branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
import com.timsu.astrid.data.tag.TagToTaskMapping.TagToTaskMappingDatabaseHelper;
35
35
import com.timsu.astrid.data.task.TaskIdentifier;
36
36
import com.timsu.astrid.data.task.AbstractTaskModel.TaskModelDatabaseHelper;
 
37
import com.timsu.astrid.provider.TasksProvider;
37
38
 
38
39
/** Controller for Tag-related operations */
39
40
public class TagController extends AbstractController {
247
248
                TagToTaskMapping.TAG + " = " + tagId.idAsString(), null) < 0)
248
249
            return false;
249
250
 
250
 
        return tagDatabase.delete(TAG_TABLE_NAME,
251
 
                KEY_ROWID + " = " + tagId.idAsString(), null) > 0;
 
251
        int res = tagDatabase.delete(TAG_TABLE_NAME,
 
252
                KEY_ROWID + " = " + tagId.idAsString(), null);
 
253
 
 
254
        // notify modification
 
255
        TasksProvider.notifyDatabaseModification();
 
256
 
 
257
        return res > 0;
252
258
    }
253
259
 
254
260
    // --- single tag to task operations
256
262
    /** Remove the given tag from the task */
257
263
    public boolean removeTag(TaskIdentifier taskId, TagIdentifier tagId)
258
264
            throws SQLException{
259
 
        return tagToTaskMapDatabase.delete(TAG_TASK_MAP_NAME,
 
265
 
 
266
        int res = tagToTaskMapDatabase.delete(TAG_TASK_MAP_NAME,
260
267
                String.format("%s = ? AND %s = ?",
261
268
                        TagToTaskMapping.TAG, TagToTaskMapping.TASK),
262
 
                new String[] { tagId.idAsString(), taskId.idAsString() }) > 0;
 
269
                new String[] { tagId.idAsString(), taskId.idAsString() });
 
270
 
 
271
        // notify modification
 
272
        TasksProvider.notifyDatabaseModification();
 
273
 
 
274
        return res > 0;
263
275
    }
264
276
 
265
277
    /** Add the given tag to the task */
268
280
        ContentValues values = new ContentValues();
269
281
        values.put(TagToTaskMapping.TAG, tagId.getId());
270
282
        values.put(TagToTaskMapping.TASK, taskId.getId());
271
 
        return tagToTaskMapDatabase.insert(TAG_TASK_MAP_NAME, TagToTaskMapping.TAG,
272
 
                values) >= 0;
 
283
 
 
284
        long res = tagToTaskMapDatabase.insert(TAG_TASK_MAP_NAME, TagToTaskMapping.TAG,
 
285
                values);
 
286
 
 
287
        // notify modification
 
288
        TasksProvider.notifyDatabaseModification();
 
289
 
 
290
        return res >= 0;
273
291
    }
274
292
 
275
293
    // --- boilerplate