Skip to content

Commit c1cf0a7

Browse files
authored
fix: fix dynamic keyboard outdated data
fix: fix dynamic keyboard outdated data
1 parent f3dca25 commit c1cf0a7

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

app/src/main/java/com/osfans/trime/ime/symbol/LiquidKeyboard.kt

+11-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ import com.osfans.trime.ime.enums.KeyCommandType
2323
import com.osfans.trime.ime.enums.SymbolKeyboardType
2424
import com.osfans.trime.ime.text.TextInputManager
2525
import com.osfans.trime.util.dp2px
26+
import kotlinx.coroutines.Dispatchers
2627
import kotlinx.coroutines.launch
28+
import kotlinx.coroutines.withContext
2729
import timber.log.Timber
2830

2931
class LiquidKeyboard(private val context: Context) {
@@ -223,17 +225,23 @@ class LiquidKeyboard(private val context: Context) {
223225
when (type) {
224226
SymbolKeyboardType.CLIPBOARD -> {
225227
service.lifecycleScope.launch {
226-
dbAdapter.updateBeans(ClipboardHelper.getAll())
228+
withContext(Dispatchers.IO) {
229+
dbAdapter.updateBeans(ClipboardHelper.getAll())
230+
}
227231
}
228232
}
229233
SymbolKeyboardType.COLLECTION -> {
230234
service.lifecycleScope.launch {
231-
dbAdapter.updateBeans(CollectionHelper.getAll())
235+
withContext(Dispatchers.IO) {
236+
dbAdapter.updateBeans(CollectionHelper.getAll())
237+
}
232238
}
233239
}
234240
SymbolKeyboardType.DRAFT -> {
235241
service.lifecycleScope.launch {
236-
dbAdapter.updateBeans(DraftHelper.getAll())
242+
withContext(Dispatchers.IO) {
243+
dbAdapter.updateBeans(DraftHelper.getAll())
244+
}
237245
}
238246
}
239247
else -> return

0 commit comments

Comments
 (0)