Skip to content

Commit

Permalink
Collections: unified delete() return value
Browse files Browse the repository at this point in the history
  • Loading branch information
rfc2822 committed Aug 1, 2024
1 parent a36ee48 commit 86af14d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,14 @@ abstract class AndroidCalendar<out T: AndroidEvent>(
return provider.update(calendarSyncURI(), info, null, null)
}

fun delete(): Int {
/**
* Deletes this calendar from the local calendar provider.
*
* @return `true` if the calendar was deleted, `false` otherwise (like it was not there before the call)
*/
fun delete(): Boolean {
logger.log(Level.FINE, "Deleting local calendar (#$id)")
return provider.delete(calendarSyncURI(), null, null)
return provider.delete(calendarSyncURI(), null, null) > 0
}


Expand Down
9 changes: 7 additions & 2 deletions lib/src/main/kotlin/at/bitfire/ical4android/DmfsTaskList.kt
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,14 @@ abstract class DmfsTaskList<out T : DmfsTask>(
return provider.client.update(taskListSyncUri(), info, null, null)
}

fun delete(): Int {
/**
* Deletes this calendar from the local calendar provider.
*
* @return `true` if the calendar was deleted, `false` otherwise (like it was not there before the call)
*/
fun delete(): Boolean {
logger.log(Level.FINE, "Deleting ${provider.name.authority} task list (#$id)")
return provider.client.delete(taskListSyncUri(), null, null)
return provider.client.delete(taskListSyncUri(), null, null) > 0
}

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/src/main/kotlin/at/bitfire/ical4android/JtxCollection.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ open class JtxCollection<out T: JtxICalObject>(val account: Account,
companion object {

private val logger
get() = Logger.getLogger(javaClass.name)
get() = Logger.getLogger(JtxCollection::class.java.name)

fun create(account: Account, client: ContentProviderClient, values: ContentValues): Uri {
logger.log(Level.FINE, "Creating jtx Board collection", values)
Expand Down Expand Up @@ -63,9 +63,9 @@ open class JtxCollection<out T: JtxICalObject>(val account: Account,
var context: Context? = null


fun delete() {
fun delete(): Boolean {
logger.log(Level.FINE, "Deleting jtx Board collection (#$id)")
client.delete(ContentUris.withAppendedId(JtxContract.JtxCollection.CONTENT_URI.asSyncAdapter(account), id), null, null)
return client.delete(ContentUris.withAppendedId(JtxContract.JtxCollection.CONTENT_URI.asSyncAdapter(account), id), null, null) > 0
}

fun update(values: ContentValues) {
Expand Down

0 comments on commit 86af14d

Please sign in to comment.