优化
This commit is contained in:
@@ -97,6 +97,7 @@ interface BaseSource : JsExtensions {
|
|||||||
* 解析header规则
|
* 解析header规则
|
||||||
*/
|
*/
|
||||||
fun getHeaderMap(hasLoginHeader: Boolean = false) = HashMap<String, String>().apply {
|
fun getHeaderMap(hasLoginHeader: Boolean = false) = HashMap<String, String>().apply {
|
||||||
|
if (checkRhinoRecursiveCall()) return@apply
|
||||||
header?.let {
|
header?.let {
|
||||||
GSON.fromJsonObject<Map<String, String>>(
|
GSON.fromJsonObject<Map<String, String>>(
|
||||||
when {
|
when {
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package io.legado.app.utils
|
||||||
|
|
||||||
|
import org.mozilla.javascript.Context
|
||||||
|
|
||||||
|
private val enterCountField by lazy {
|
||||||
|
Context::class.java.getDeclaredField("enterCount").apply {
|
||||||
|
isAccessible = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Context?.getEnterCount(): Int {
|
||||||
|
this ?: return 0
|
||||||
|
return enterCountField.get(this) as Int
|
||||||
|
}
|
||||||
|
|
||||||
|
fun checkRhinoRecursiveCall(): Boolean {
|
||||||
|
return Context.getCurrentContext().getEnterCount() > 1
|
||||||
|
}
|
||||||
|
|
||||||
|
fun checkRhinoCall(): Boolean {
|
||||||
|
return Context.getCurrentContext() != null
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user