Commit 04587007 authored by tasn's avatar tasn

Support sortOrder in query functions.

parent baf0c3a1
......@@ -171,12 +171,12 @@ abstract class AndroidCalendar<out T: AndroidEvent>(
* @param _whereArgs arguments for selection
* @return events from this calendar which match the selection
*/
fun queryEvents(_where: String? = null, _whereArgs: Array<String>? = null): List<T> {
fun queryEvents(_where: String? = null, _whereArgs: Array<String>? = null, sortOrder: String? = null): List<T> {
val where = "(${_where ?: "1"}) AND " + Events.CALENDAR_ID + "=?"
val whereArgs = (_whereArgs ?: arrayOf()) + id.toString()
val events = LinkedList<T>()
provider.query(eventsSyncURI(), null, where, whereArgs, null)?.use { cursor ->
provider.query(eventsSyncURI(), null, where, whereArgs, sortOrder)?.use { cursor ->
while (cursor.moveToNext())
events += eventFactory.fromProvider(this, cursor.toValues())
}
......
......@@ -116,7 +116,7 @@ abstract class AndroidTaskList<out T: AndroidTask>(
* @param _whereArgs arguments for selection
* @return events from this task list which match the selection
*/
fun queryTasks(_where: String? = null, _whereArgs: Array<String>? = null): List<T> {
fun queryTasks(_where: String? = null, _whereArgs: Array<String>? = null, sortOrder: String? = null): List<T> {
val where = "(${_where ?: "1"}) AND ${Tasks.LIST_ID}=?"
val whereArgs = (_whereArgs ?: arrayOf()) + id.toString()
......@@ -124,7 +124,7 @@ abstract class AndroidTaskList<out T: AndroidTask>(
provider.client.query(
tasksSyncUri(),
null,
where, whereArgs, null)?.use { cursor ->
where, whereArgs, sortOrder)?.use { cursor ->
while (cursor.moveToNext())
tasks += taskFactory.fromProvider(this, cursor.toValues())
}
......
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