mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-20 17:57:29 +00:00
Don't trampoline in setOnlyPage.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package org.thoughtcrime.securesms.keyboard
|
||||
|
||||
import androidx.annotation.MainThread
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import org.signal.core.util.ThreadUtil
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.stickers.StickerSearchRepository
|
||||
@@ -35,14 +37,19 @@ class KeyboardPagerViewModel : ViewModel() {
|
||||
fun page(): LiveData<KeyboardPage> = page
|
||||
fun pages(): LiveData<Set<KeyboardPage>> = pages
|
||||
|
||||
@MainThread
|
||||
fun setOnlyPage(page: KeyboardPage) {
|
||||
pages.postValue(setOf(page))
|
||||
pages.value = setOf(page)
|
||||
switchToPage(page)
|
||||
}
|
||||
|
||||
fun switchToPage(page: KeyboardPage) {
|
||||
if (this.pages.value.contains(page) && this.page.value != page) {
|
||||
this.page.postValue(page)
|
||||
if (ThreadUtil.isMainThread()) {
|
||||
this.page.value = page
|
||||
} else {
|
||||
this.page.postValue(page)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user