@@ -23,7 +23,6 @@ import java.util.LinkedList
2323import java.util.logging.Level
2424import java.util.logging.Logger
2525
26-
2726/* *
2827 * Represents a locally stored task list, containing [DmfsTask]s (tasks).
2928 * Communicates with tasks.org-compatible content providers (currently tasks.org and OpenTasks) to store the tasks.
@@ -36,80 +35,15 @@ abstract class DmfsTaskList<out T : DmfsTask>(
3635 val id : Long
3736) {
3837
39- companion object {
40-
41- private val logger
42- get() = Logger .getLogger(DmfsTaskList ::class .java.name)
43-
44- fun create (account : Account , provider : ContentProviderClient , providerName : TaskProvider .ProviderName , info : ContentValues ): Uri {
45- info.put(TaskContract .ACCOUNT_NAME , account.name)
46- info.put(TaskContract .ACCOUNT_TYPE , account.type)
47-
48- val url = TaskLists .getContentUri(providerName.authority).asSyncAdapter(account)
49- logger.log(Level .FINE , " Creating ${providerName.authority} task list" , info)
50- return provider.insert(url, info)
51- ? : throw CalendarStorageException (" Couldn't create task list (empty result from provider)" )
52- }
53-
54- fun <T : DmfsTaskList <DmfsTask >> findByID (
55- account : Account ,
56- provider : ContentProviderClient ,
57- providerName : TaskProvider .ProviderName ,
58- factory : DmfsTaskListFactory <T >,
59- id : Long
60- ): T {
61- provider.query(
62- ContentUris .withAppendedId(TaskLists .getContentUri(providerName.authority), id).asSyncAdapter(account),
63- null ,
64- null ,
65- null ,
66- null
67- )?.use { cursor ->
68- if (cursor.moveToNext()) {
69- val taskList = factory.newInstance(account, provider, providerName, id)
70- taskList.populate(cursor.toValues())
71- return taskList
72- }
73- }
74- throw FileNotFoundException ()
75- }
76-
77- fun <T : DmfsTaskList <DmfsTask >> find (
78- account : Account ,
79- factory : DmfsTaskListFactory <T >,
80- provider : ContentProviderClient ,
81- providerName : TaskProvider .ProviderName ,
82- where : String? ,
83- whereArgs : Array <String >?
84- ): List <T > {
85- val taskLists = LinkedList <T >()
86- provider.query(
87- TaskLists .getContentUri(providerName.authority).asSyncAdapter(account),
88- null ,
89- where,
90- whereArgs,
91- null
92- )?.use { cursor ->
93- while (cursor.moveToNext()) {
94- val values = cursor.toValues()
95- val taskList =
96- factory.newInstance(account, provider, providerName, values.getAsLong(TaskLists ._ID ))
97- taskList.populate(values)
98- taskLists + = taskList
99- }
100- }
101- return taskLists
102- }
103-
104- }
38+ private val logger
39+ get() = Logger .getLogger(DmfsTaskList ::class .java.name)
10540
10641 var syncId: String? = null
10742 var name: String? = null
10843 var color: Int? = null
10944 var isSynced = false
11045 var isVisible = false
11146
112-
11347 /* *
11448 * Sets the task list properties ([syncId], [name] etc.) from the passed argument,
11549 * which is usually directly taken from the tasks provider.
@@ -120,7 +54,7 @@ abstract class DmfsTaskList<out T : DmfsTask>(
12054 * @param values values from tasks provider
12155 */
12256 @CallSuper
123- protected open fun populate (values : ContentValues ) {
57+ internal open fun populate (values : ContentValues ) {
12458 syncId = values.getAsString(TaskLists ._SYNC_ID )
12559 name = values.getAsString(TaskLists .LIST_NAME )
12660 color = values.getAsInteger(TaskLists .LIST_COLOR )
0 commit comments