mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-22 21:58:53 +01:00
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> {
|
fun getOrCreateConversation(addresses: List<String>): Maybe<Conversation> {
|
||||||
return Maybe.just(addresses)
|
return Maybe.just(addresses)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
.map { recipients ->
|
.map { recipients ->
|
||||||
recipients.map { address ->
|
recipients.map { address ->
|
||||||
when (MessageUtils.isEmailAddress(address)) {
|
when (MessageUtils.isEmailAddress(address)) {
|
||||||
@@ -96,9 +97,10 @@ class MessageRepository @Inject constructor(
|
|||||||
.map { cursor -> cursor.getLong(0) }
|
.map { cursor -> cursor.getLong(0) }
|
||||||
.filter { threadId -> threadId != 0L }
|
.filter { threadId -> threadId != 0L }
|
||||||
.map { threadId ->
|
.map { threadId ->
|
||||||
getConversation(threadId)
|
var conversation = getConversation(threadId)
|
||||||
?: getConversationFromCp(threadId)?.apply { insertOrUpdate() }
|
if (conversation != null) conversation = Realm.getDefaultInstance().copyFromRealm(conversation)
|
||||||
?: Conversation()
|
|
||||||
|
conversation ?: getConversationFromCp(threadId)?.apply { insertOrUpdate() } ?: Conversation()
|
||||||
}
|
}
|
||||||
.onErrorReturn { Conversation() }
|
.onErrorReturn { Conversation() }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ import com.google.android.flexbox.FlexboxLayoutManager
|
|||||||
import com.jakewharton.rxbinding2.view.keys
|
import com.jakewharton.rxbinding2.view.keys
|
||||||
import com.jakewharton.rxbinding2.widget.textChanges
|
import com.jakewharton.rxbinding2.widget.textChanges
|
||||||
import com.moez.QKSMS.R
|
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.dpToPx
|
||||||
|
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||||
import com.moez.QKSMS.common.util.extensions.showKeyboard
|
import com.moez.QKSMS.common.util.extensions.showKeyboard
|
||||||
import com.moez.QKSMS.data.model.Contact
|
import com.moez.QKSMS.data.model.Contact
|
||||||
import com.moez.QKSMS.presentation.common.base.QkAdapter
|
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 kotlinx.android.synthetic.main.contact_chip.view.*
|
||||||
import javax.inject.Inject
|
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 {
|
companion object {
|
||||||
private val TYPE_EDIT_TEXT = 0
|
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) {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = when (viewType) {
|
||||||
TYPE_EDIT_TEXT -> QkViewHolder(editText)
|
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) {
|
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
|
||||||
|
|||||||
@@ -122,6 +122,9 @@ class ComposeActivity : QkActivity<ComposeViewModel>(), ComposeView {
|
|||||||
disposables += colors.bubble
|
disposables += colors.bubble
|
||||||
.subscribe { color -> messageBackground.setBackgroundTint(color) }
|
.subscribe { color -> messageBackground.setBackgroundTint(color) }
|
||||||
|
|
||||||
|
disposables += colors.background
|
||||||
|
.subscribe { color -> contacts.setBackgroundTint(color) }
|
||||||
|
|
||||||
disposables += colors.composeBackground
|
disposables += colors.composeBackground
|
||||||
.doOnNext { color -> composeBar.setBackgroundTint(color) }
|
.doOnNext { color -> composeBar.setBackgroundTint(color) }
|
||||||
.doOnNext { color -> window.decorView.setBackgroundColor(color) }
|
.doOnNext { color -> window.decorView.setBackgroundColor(color) }
|
||||||
|
|||||||
@@ -1,16 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:color="?android:attr/colorControlHighlight">
|
android:color="?android:attr/colorControlHighlight">
|
||||||
<item>
|
|
||||||
<shape android:shape="rectangle">
|
|
||||||
<solid android:color="@color/white" />
|
|
||||||
<corners android:radius="18dp" />
|
|
||||||
</shape>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<shape
|
<shape
|
||||||
android:shape="rectangle">
|
android:shape="rectangle">
|
||||||
<solid android:color="@color/separatorLight"/>
|
<solid android:color="@color/bubbleLight"/>
|
||||||
<corners android:radius="18dp"/>
|
<corners android:radius="18dp"/>
|
||||||
</shape>
|
</shape>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -32,7 +32,6 @@
|
|||||||
android:id="@+id/contacts"
|
android:id="@+id/contacts"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/white"
|
|
||||||
android:clipChildren="false"
|
android:clipChildren="false"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:paddingBottom="8dp"
|
android:paddingBottom="8dp"
|
||||||
|
|||||||
Reference in New Issue
Block a user