Преглед изворни кода

[skip ci] Revert "Update SharedJsScope.kt"

This reverts commit 732660469e09335bbd4b7ff60414181ce0735ba2.
Xwite пре 3 година
родитељ
комит
74b7b8fe17
1 измењених фајлова са 4 додато и 5 уклоњено
  1. 4 5
      app/src/main/java/io/legado/app/model/SharedJsScope.kt

+ 4 - 5
app/src/main/java/io/legado/app/model/SharedJsScope.kt

@@ -27,8 +27,7 @@ object SharedJsScope {
         if (scope == null) {
             val context = SCRIPT_ENGINE.getScriptContext(SimpleBindings())
             scope = SCRIPT_ENGINE.getRuntimeScope(context)
-            Context.use {
-                val context = Context.enter()
+            Context.enter().use {
                 if (jsLib.isJsonObject()) {
                     val jsMap: Map<String, String> = GSON.fromJson(
                         jsLib,
@@ -43,11 +42,11 @@ object SharedJsScope {
                             val js = okHttpClient.newCallStrResponse {
                                 url(value)
                             }.body
-                            context.evaluateString(scope, js, "jsLib", 1, null)
+                            it.evaluateString(scope, js, "jsLib", 1, null)
                         }
                     }
                 } else {
-                    context.evaluateString(scope, jsLib, "jsLib", 1, null)
+                    it.evaluateString(scope, jsLib, "jsLib", 1, null)
                 }
             }
             scopeMap[key] = WeakReference(scope)
@@ -55,4 +54,4 @@ object SharedJsScope {
         return scope
     }
 
-}
+}