Skip to content

Commit

Permalink
Closes #113 Fix hierarchy of CommonDataEntity
Browse files Browse the repository at this point in the history
  • Loading branch information
vestrel00 committed Nov 29, 2021
1 parent f5dcb0e commit b9e48a2
Show file tree
Hide file tree
Showing 98 changed files with 683 additions and 678 deletions.
4 changes: 2 additions & 2 deletions DEV_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ The Contacts Provider may consolidate multiple contacts belonging to different a
them into a single entry in the Contacts table whilst maintaining the separate entries in the
RawContacts table.

A more common scenario that causes multiple RawContacts per Contact is when two or more Contacts are
A more likely scenario that causes multiple RawContacts per Contact is when two or more Contacts are
"linked" (or "merged" for API 23 and below, or "joined" for API 22 and below).

### Behavior of linking/merging/joining contacts (AggregationExceptions)
Expand Down Expand Up @@ -1149,7 +1149,7 @@ last!

I left comments all over the code on when an androidx dependency may be useful. The most glaring
example of this is @WorkerThread. Even with that, I'll hold off on adding the androidx annotation
lib. I think we can all be consenting adults and apply some common sense.
lib. I think we can all be consenting adults =)

If the community strongly desires the addition of these support libs, then the community will win =)

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ val emails = Contacts(context)
.find()
```

It's not just for emails. It's for all common data kinds (including custom data).
It's not just for emails. It's for all data kinds (including custom data).

> For more info, read [How do I get a list of specific data kinds?](/howto/howto-query-data-sets.md)
Expand Down Expand Up @@ -416,7 +416,7 @@ The find function optionally takes in a function that, if it returns true, will
processing as soon as possible. The function is called numerous times during query processing to
check if processing should stop or continue. This gives you the option to cancel the query.

This is useful when used in multi-threaded environments. One scenario where this would be commonly
This is useful when used in multi-threaded environments. One scenario where this would be frequently
used is when performing queries as the user types a search text. You are able to cancel the current
query when the user enters new text.

Expand Down
14 changes: 7 additions & 7 deletions async/src/main/java/contacts/async/data/DataQueryAsync.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package contacts.async.data

import contacts.async.ASYNC_DISPATCHER
import contacts.core.CommonDataField
import contacts.core.data.CommonDataQuery
import contacts.core.entities.CommonDataEntity
import contacts.core.DataField
import contacts.core.data.DataQuery
import contacts.core.entities.ImmutableData
import kotlinx.coroutines.*
import kotlin.coroutines.CoroutineContext

Expand All @@ -13,9 +13,9 @@ import kotlin.coroutines.CoroutineContext
*
* Computations automatically stops if the parent coroutine scope / job is cancelled.
*
* See [CommonDataQuery.find].
* See [DataQuery.find].
*/
suspend fun <F : CommonDataField, E : CommonDataEntity> CommonDataQuery<F, E>.findWithContext(
suspend fun <F : DataField, E : ImmutableData> DataQuery<F, E>.findWithContext(
context: CoroutineContext = ASYNC_DISPATCHER
): List<E> = withContext(context) { find { !isActive } }

Expand All @@ -26,8 +26,8 @@ suspend fun <F : CommonDataField, E : CommonDataEntity> CommonDataQuery<F, E>.fi
*
* Computations automatically stops if the parent coroutine scope / job is cancelled.
*
* See [CommonDataQuery.find].
* See [DataQuery.find].
*/
fun <F : CommonDataField, E : CommonDataEntity> CommonDataQuery<F, E>.findAsync(
fun <F : DataField, E : ImmutableData> DataQuery<F, E>.findAsync(
context: CoroutineContext = ASYNC_DISPATCHER
): Deferred<List<E>> = CoroutineScope(context).async { find { !isActive } }
10 changes: 5 additions & 5 deletions async/src/main/java/contacts/async/util/DataContactAsync.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package contacts.async.util

import contacts.async.ASYNC_DISPATCHER
import contacts.core.Contacts
import contacts.core.entities.CommonDataEntity
import contacts.core.entities.DataEntity
import contacts.core.entities.Contact
import contacts.core.util.contact
import kotlinx.coroutines.*
Expand All @@ -14,9 +14,9 @@ import kotlin.coroutines.CoroutineContext
*
* Computations automatically stops if the parent coroutine scope / job is cancelled.
*
* See [CommonDataEntity.contact].
* See [DataEntity.contact].
*/
suspend fun CommonDataEntity.contactWithContext(
suspend fun DataEntity.contactWithContext(
contacts: Contacts,
coroutineContext: CoroutineContext = ASYNC_DISPATCHER
): Contact? = withContext(coroutineContext) { contact(contacts) { !isActive } }
Expand All @@ -27,9 +27,9 @@ suspend fun CommonDataEntity.contactWithContext(
*
* Computations automatically stops if the parent coroutine scope / job is cancelled.
*
* See [CommonDataEntity.contact].
* See [DataEntity.contact].
*/
fun CommonDataEntity.contactAsync(
fun DataEntity.contactAsync(
contacts: Contacts,
coroutineContext: CoroutineContext = ASYNC_DISPATCHER
): Deferred<Contact?> = CoroutineScope(coroutineContext).async { contact(contacts) { !isActive } }
10 changes: 5 additions & 5 deletions async/src/main/java/contacts/async/util/DataRawContactAsync.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package contacts.async.util

import contacts.async.ASYNC_DISPATCHER
import contacts.core.Contacts
import contacts.core.entities.CommonDataEntity
import contacts.core.entities.DataEntity
import contacts.core.entities.RawContact
import contacts.core.util.rawContact
import kotlinx.coroutines.*
Expand All @@ -14,9 +14,9 @@ import kotlin.coroutines.CoroutineContext
*
* Computations automatically stops if the parent coroutine scope / job is cancelled.
*
* See [CommonDataEntity.rawContact].
* See [DataEntity.rawContact].
*/
suspend fun CommonDataEntity.rawContactWithContext(
suspend fun DataEntity.rawContactWithContext(
contacts: Contacts,
coroutineContext: CoroutineContext = ASYNC_DISPATCHER
): RawContact? = withContext(coroutineContext) {
Expand All @@ -29,9 +29,9 @@ suspend fun CommonDataEntity.rawContactWithContext(
*
* Computations automatically stops if the parent coroutine scope / job is cancelled.
*
* See [CommonDataEntity.rawContact].
* See [DataEntity.rawContact].
*/
fun CommonDataEntity.rawContactAsync(
fun DataEntity.rawContactAsync(
contacts: Contacts,
coroutineContext: CoroutineContext = ASYNC_DISPATCHER
): Deferred<RawContact?> = CoroutineScope(coroutineContext).async {
Expand Down
11 changes: 6 additions & 5 deletions async/src/main/java/contacts/async/util/DataRefreshAsync.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package contacts.async.util

import contacts.async.ASYNC_DISPATCHER
import contacts.core.Contacts
import contacts.core.entities.CommonDataEntity
import contacts.core.entities.DataEntity
import contacts.core.entities.ImmutableData
import contacts.core.util.refresh
import kotlinx.coroutines.*
import kotlin.coroutines.CoroutineContext
Expand All @@ -13,9 +14,9 @@ import kotlin.coroutines.CoroutineContext
*
* Computations automatically stops if the parent coroutine scope / job is cancelled.
*
* See [CommonDataEntity.refresh].
* See [ImmutableData.refresh].
*/
suspend fun <T : CommonDataEntity> T.refreshWithContext(
suspend fun <T : ImmutableData> T.refreshWithContext(
contacts: Contacts,
coroutineContext: CoroutineContext = ASYNC_DISPATCHER
): T? = withContext(coroutineContext) {
Expand All @@ -28,9 +29,9 @@ suspend fun <T : CommonDataEntity> T.refreshWithContext(
*
* Computations automatically stops if the parent coroutine scope / job is cancelled.
*
* See [CommonDataEntity.refresh].
* See [ImmutableData.refresh].
*/
fun <T : CommonDataEntity> T.refreshAsync(
fun <T : ImmutableData> T.refreshAsync(
contacts: Contacts,
coroutineContext: CoroutineContext = ASYNC_DISPATCHER
): Deferred<T?> = CoroutineScope(coroutineContext).async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package contacts.async.util

import contacts.async.ASYNC_DISPATCHER
import contacts.core.Contacts
import contacts.core.entities.CommonDataEntity
import contacts.core.entities.DataEntity
import contacts.core.util.clearDefault
import contacts.core.util.setAsDefault
import kotlinx.coroutines.CoroutineScope
Expand All @@ -15,9 +15,9 @@ import kotlin.coroutines.CoroutineContext
* Suspends the current coroutine, performs the operation in the given [coroutineContext], then
* returns the result.
*
* See [CommonDataEntity.setAsDefault].
* See [DataEntity.setAsDefault].
*/
suspend fun CommonDataEntity.setAsDefaultWithContext(
suspend fun DataEntity.setAsDefaultWithContext(
contacts: Contacts,
coroutineContext: CoroutineContext = ASYNC_DISPATCHER
): Boolean = withContext(coroutineContext) { setAsDefault(contacts) }
Expand All @@ -26,9 +26,9 @@ suspend fun CommonDataEntity.setAsDefaultWithContext(
* Suspends the current coroutine, performs the operation in the given [coroutineContext], then
* returns the result.
*
* See [CommonDataEntity.clearDefault].
* See [DataEntity.clearDefault].
*/
suspend fun CommonDataEntity.clearDefaultWithContext(
suspend fun DataEntity.clearDefaultWithContext(
contacts: Contacts,
coroutineContext: CoroutineContext = ASYNC_DISPATCHER
): Boolean = withContext(coroutineContext) { clearDefault(contacts) }
Expand All @@ -37,9 +37,9 @@ suspend fun CommonDataEntity.clearDefaultWithContext(
* Creates a [CoroutineScope] with the given [coroutineContext], performs the operation in that
* scope, then returns the [Deferred] result.
*
* See [CommonDataEntity.setAsDefault].
* See [DataEntity.setAsDefault].
*/
fun CommonDataEntity.setAsDefaultAsync(
fun DataEntity.setAsDefaultAsync(
contacts: Contacts,
coroutineContext: CoroutineContext = ASYNC_DISPATCHER
): Deferred<Boolean> = CoroutineScope(coroutineContext).async { setAsDefault(contacts) }
Expand All @@ -48,9 +48,9 @@ fun CommonDataEntity.setAsDefaultAsync(
* Creates a [CoroutineScope] with the given [coroutineContext], performs the operation in that
* scope, then returns the [Deferred] result.
*
* See [CommonDataEntity.clearDefault].
* See [DataEntity.clearDefault].
*/
fun CommonDataEntity.clearDefaultAsync(
fun DataEntity.clearDefaultAsync(
contacts: Contacts,
coroutineContext: CoroutineContext = ASYNC_DISPATCHER
): Deferred<Boolean> = CoroutineScope(coroutineContext).async { clearDefault(contacts) }
2 changes: 1 addition & 1 deletion core/src/main/java/contacts/core/Contacts.kt
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ interface Contacts {
val applicationContext: Context

/**
* Provides functions required to support custom common data, which have [MimeType.Custom].
* Provides functions required to support custom data, which have [MimeType.Custom].
*/
val customDataRegistry: CustomDataRegistry
}
Expand Down
Loading

0 comments on commit b9e48a2

Please sign in to comment.