mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-05 06:10:14 +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)
|
params.mPopupKeyTypes.add(POPUP_KEYS_LAYOUT)
|
||||||
addLocaleKeyTextsToParams(context, params, POPUP_KEYS_NORMAL)
|
addLocaleKeyTextsToParams(context, params, POPUP_KEYS_NORMAL)
|
||||||
try {
|
try {
|
||||||
val keys = LayoutParser.parseJsonString(layoutContent).map { row -> row.mapNotNull { it.compute(params)?.toKeyParams(params) } }
|
if (layoutContent.trimStart().startsWith("[") || layoutContent.trimStart().startsWith("//")) {
|
||||||
return checkKeys(keys)
|
val keys = LayoutParser.parseJsonString(layoutContent).map { row -> row.mapNotNull { it.compute(params)?.toKeyParams(params) } }
|
||||||
|
return checkKeys(keys)
|
||||||
|
}
|
||||||
} catch (e: SerializationException) {
|
} catch (e: SerializationException) {
|
||||||
Log.w(TAG, "json parsing error", e)
|
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
|
return false // we're sure enough it's a json
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.w(TAG, "json layout parsed, but considered invalid", e)
|
Log.w(TAG, "json layout parsed, but considered invalid", e)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue