|
|
@@ -420,8 +420,22 @@ class KeyboardViewModel : ViewModel() {
|
|
|
mKeyboardRepository.getCurrentKeyboardInfo(onSuccess = {
|
|
|
if (it.id.isNullOrBlank()) {
|
|
|
mKeyboardRepository.getKeyboardList(onSuccess = {
|
|
|
- val defaultItem = it.keyboardInfos[0]
|
|
|
- onSuccess.invoke(defaultItem)
|
|
|
+ val infos = it.keyboardInfos
|
|
|
+ // 数据为空
|
|
|
+ if (infos.isEmpty()) {
|
|
|
+ onFail.invoke(-1, "暂无数据")
|
|
|
+ } else {
|
|
|
+ // 默认使用系统键盘
|
|
|
+ val systemKeyboard = infos.filter {
|
|
|
+ KeyboardType.isSystem(it.type ?: "")
|
|
|
+ }.toList()
|
|
|
+ if (systemKeyboard.isNotEmpty()) {
|
|
|
+ onSuccess.invoke(systemKeyboard.first())
|
|
|
+ } else {
|
|
|
+ // 连系统键盘都没有,则取第一个
|
|
|
+ onSuccess.invoke(infos[0])
|
|
|
+ }
|
|
|
+ }
|
|
|
}, onFail)
|
|
|
} else {
|
|
|
// 更新键盘
|