forked from upstream-mirrors/quik
Fix threading issues with selecting conversation
This commit is contained in:
@@ -77,6 +77,7 @@ class MessageRepository @Inject constructor(
|
||||
|
||||
fun getOrCreateConversation(addresses: List<String>): Maybe<Conversation> {
|
||||
return Maybe.just(addresses)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.map { recipients ->
|
||||
recipients.map { address ->
|
||||
when (MessageUtils.isEmailAddress(address)) {
|
||||
@@ -96,9 +97,10 @@ class MessageRepository @Inject constructor(
|
||||
.map { cursor -> cursor.getLong(0) }
|
||||
.filter { threadId -> threadId != 0L }
|
||||
.map { threadId ->
|
||||
getConversation(threadId)
|
||||
?: getConversationFromCp(threadId)?.apply { insertOrUpdate() }
|
||||
?: Conversation()
|
||||
var conversation = getConversation(threadId)
|
||||
if (conversation != null) conversation = Realm.getDefaultInstance().copyFromRealm(conversation)
|
||||
|
||||
conversation ?: getConversationFromCp(threadId)?.apply { insertOrUpdate() } ?: Conversation()
|
||||
}
|
||||
.onErrorReturn { Conversation() }
|
||||
}
|
||||
|
||||
@@ -12,7 +12,9 @@ import com.google.android.flexbox.FlexboxLayoutManager
|
||||
import com.jakewharton.rxbinding2.view.keys
|
||||
import com.jakewharton.rxbinding2.widget.textChanges
|
||||
import com.moez.QKSMS.R
|
||||
import com.moez.QKSMS.common.util.Colors
|
||||
import com.moez.QKSMS.common.util.extensions.dpToPx
|
||||
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||
import com.moez.QKSMS.common.util.extensions.showKeyboard
|
||||
import com.moez.QKSMS.data.model.Contact
|
||||
import com.moez.QKSMS.presentation.common.base.QkAdapter
|
||||
@@ -21,7 +23,7 @@ import io.reactivex.subjects.PublishSubject
|
||||
import kotlinx.android.synthetic.main.contact_chip.view.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class ChipsAdapter @Inject constructor(private val context: Context) : QkAdapter<Contact>() {
|
||||
class ChipsAdapter @Inject constructor(private val context: Context, private val colors: Colors) : QkAdapter<Contact>() {
|
||||
|
||||
companion object {
|
||||
private val TYPE_EDIT_TEXT = 0
|
||||
@@ -64,7 +66,13 @@ class ChipsAdapter @Inject constructor(private val context: Context) : QkAdapter
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = when (viewType) {
|
||||
TYPE_EDIT_TEXT -> QkViewHolder(editText)
|
||||
else -> QkViewHolder(LayoutInflater.from(context).inflate(R.layout.contact_chip, parent, false))
|
||||
|
||||
else -> {
|
||||
val view = LayoutInflater.from(context).inflate(R.layout.contact_chip, parent, false)
|
||||
colors.composeBackground.subscribe { color -> view.content.setBackgroundTint(color) }
|
||||
|
||||
QkViewHolder(view)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
|
||||
|
||||
@@ -122,6 +122,9 @@ class ComposeActivity : QkActivity<ComposeViewModel>(), ComposeView {
|
||||
disposables += colors.bubble
|
||||
.subscribe { color -> messageBackground.setBackgroundTint(color) }
|
||||
|
||||
disposables += colors.background
|
||||
.subscribe { color -> contacts.setBackgroundTint(color) }
|
||||
|
||||
disposables += colors.composeBackground
|
||||
.doOnNext { color -> composeBar.setBackgroundTint(color) }
|
||||
.doOnNext { color -> window.decorView.setBackgroundColor(color) }
|
||||
|
||||
Reference in New Issue
Block a user