kopia lustrzana https://github.com/ryukoposting/Signal-Android
Don't trampoline in setOnlyPage.
rodzic
b56207d977
commit
90e6dd3d7d
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue