|
|
@ -278,18 +278,20 @@ class AnalyzeTxtFile { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun getTocRules(): List<TxtTocRule> { |
|
|
|
private fun getTocRules(): List<TxtTocRule> { |
|
|
|
val rules = App.db.txtTocRule().all |
|
|
|
val rules = App.db.txtTocRule().enabled |
|
|
|
if (rules.isEmpty()) { |
|
|
|
if (rules.isEmpty()) { |
|
|
|
return getDefaultRules() |
|
|
|
return getDefaultEnabledRules() |
|
|
|
} |
|
|
|
} |
|
|
|
return rules |
|
|
|
return rules |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun getDefaultRules(): List<TxtTocRule> { |
|
|
|
fun getDefaultEnabledRules(): List<TxtTocRule> { |
|
|
|
App.INSTANCE.assets.open("txtTocRule.json").readBytes().let { byteArray -> |
|
|
|
App.INSTANCE.assets.open("txtTocRule.json").readBytes().let { byteArray -> |
|
|
|
GSON.fromJsonArray<TxtTocRule>(String(byteArray))?.let { |
|
|
|
GSON.fromJsonArray<TxtTocRule>(String(byteArray))?.let { txtTocRules -> |
|
|
|
App.db.txtTocRule().insert(*it.toTypedArray()) |
|
|
|
App.db.txtTocRule().insert(*txtTocRules.toTypedArray()) |
|
|
|
return it |
|
|
|
return txtTocRules.filter { |
|
|
|
|
|
|
|
it.enable |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return emptyList() |
|
|
|
return emptyList() |
|
|
|