Commit acd0fa98 authored by Ricki Hirner's avatar Ricki Hirner

Minor refactoring; deprecate CalendarStorageException

parent aa253567
......@@ -157,7 +157,7 @@ abstract class AndroidCalendar<out T: AndroidEvent>(
}
open protected fun populate(info: ContentValues) {
protected open fun populate(info: ContentValues) {
name = info.getAsString(Calendars.NAME)
displayName = info.getAsString(Calendars.CALENDAR_DISPLAY_NAME)
......@@ -171,7 +171,7 @@ abstract class AndroidCalendar<out T: AndroidEvent>(
@Throws(CalendarStorageException::class)
fun update(info: ContentValues) {
try {
provider.update(syncAdapterURI(calendarSyncURI()), info, null, null)
provider.update(calendarSyncURI(), info, null, null)
} catch (e: RemoteException) {
throw CalendarStorageException("Couldn't update calendar", e)
}
......@@ -193,7 +193,7 @@ abstract class AndroidCalendar<out T: AndroidEvent>(
val events = LinkedList<T>()
try {
provider.query(
syncAdapterURI(Events.CONTENT_URI),
eventsSyncURI(),
eventBaseInfoColumns(),
where, whereArgs, null)?.use { cursor ->
while (cursor.moveToNext()) {
......@@ -210,11 +210,12 @@ abstract class AndroidCalendar<out T: AndroidEvent>(
fun syncAdapterURI(uri: Uri) = uri.buildUpon()
.appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true")
.appendQueryParameter(Calendars.ACCOUNT_NAME, account.name)
.appendQueryParameter(Calendars.ACCOUNT_TYPE, account.type)
.appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true")
.build()!!
fun calendarSyncURI() = syncAdapterURI(ContentUris.withAppendedId(Calendars.CONTENT_URI, id))
fun eventsSyncURI() = syncAdapterURI(Events.CONTENT_URI)
}
......@@ -167,10 +167,7 @@ abstract class AndroidTaskList<out T: AndroidTask>(
return tasks
}
fun taskListSyncUri() =
TaskProvider.syncAdapterUri(ContentUris.withAppendedId(provider.taskListsUri(), id), account)
fun tasksSyncUri() =
TaskProvider.syncAdapterUri(provider.tasksUri(), account)
fun taskListSyncUri() = TaskProvider.syncAdapterUri(ContentUris.withAppendedId(provider.taskListsUri(), id), account)
fun tasksSyncUri() = TaskProvider.syncAdapterUri(provider.tasksUri(), account)
}
......@@ -8,6 +8,7 @@
package at.bitfire.ical4android
@Deprecated("Do not wrap calendar IPC exceptions if you don't need to.")
class CalendarStorageException: Exception {
constructor(message: String): super(message)
......
......@@ -102,6 +102,7 @@ class TaskProvider private constructor(
fun taskListsUri() = TaskContract.TaskLists.getContentUri(name.authority)!!
fun tasksUri() = TaskContract.Tasks.getContentUri(name.authority)!!
//fun alarmsUri() = TaskContract.Alarms.getContentUri(name.authority)!!
fun syncStateUri() = TaskContract.SyncState.getContentUri(name.authority)!!
override fun close() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment