Show custom/random colours in compose screen

This commit is contained in:
Moez Bhatti
2019-12-26 19:34:39 -05:00
parent 6842374254
commit d6dcc55a36
4 changed files with 61 additions and 5 deletions
@@ -0,0 +1,13 @@
package com.moez.QKSMS.extensions
inline fun <K, T> Iterable<T>.associateByNotNull(keySelector: (T) -> K?): Map<K, T> {
val map = hashMapOf<K, T>()
forEach { value ->
val key = keySelector(value)
if (key != null) {
map[key] = value
}
}
return map
}
@@ -206,6 +206,17 @@ class ConversationRepositoryImpl @Inject constructor(
.observeOn(Schedulers.io())
}
override fun getUnmanagedRecipients(): Observable<List<Recipient>> {
val realm = Realm.getDefaultInstance()
return realm.where(Recipient::class.java)
.isNotNull("contact")
.findAllAsync()
.asObservable()
.filter { it.isLoaded && it.isValid }
.map { realm.copyFromRealm(it) }
.subscribeOn(AndroidSchedulers.mainThread())
}
override fun getRecipient(recipientId: Long): Recipient? {
return Realm.getDefaultInstance()
.where(Recipient::class.java)