mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-03 13:20:31 +00:00
reduce unnecessary json parse attempts when editing layouts
This commit is contained in:
parent
e154001d44
commit
e7ccf72fc5
1 changed files with 5 additions and 3 deletions
|
@ -36,11 +36,13 @@ object LayoutUtilsCustom {
|
|||
params.mPopupKeyTypes.add(POPUP_KEYS_LAYOUT)
|
||||
addLocaleKeyTextsToParams(context, params, POPUP_KEYS_NORMAL)
|
||||
try {
|
||||
val keys = LayoutParser.parseJsonString(layoutContent).map { row -> row.mapNotNull { it.compute(params)?.toKeyParams(params) } }
|
||||
return checkKeys(keys)
|
||||
if (layoutContent.trimStart().startsWith("[") || layoutContent.trimStart().startsWith("//")) {
|
||||
val keys = LayoutParser.parseJsonString(layoutContent).map { row -> row.mapNotNull { it.compute(params)?.toKeyParams(params) } }
|
||||
return checkKeys(keys)
|
||||
}
|
||||
} catch (e: SerializationException) {
|
||||
Log.w(TAG, "json parsing error", e)
|
||||
if (layoutContent.trimStart().startsWith("[") && layoutContent.trimEnd().endsWith("]") && layoutContent.contains("},"))
|
||||
if (layoutContent.trimEnd().endsWith("]") && layoutContent.contains("},"))
|
||||
return false // we're sure enough it's a json
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "json layout parsed, but considered invalid", e)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue