From c8c812275e9cdce6654f67daee0a2a4ef4896be4 Mon Sep 17 00:00:00 2001 From: Lin Date: Sun, 4 Feb 2024 23:00:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Ddialogs.build=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autojs/src/main/assets/modules/__dialogs__.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/autojs/src/main/assets/modules/__dialogs__.js b/autojs/src/main/assets/modules/__dialogs__.js index 90cd2415f..f3e3e9d63 100644 --- a/autojs/src/main/assets/modules/__dialogs__.js +++ b/autojs/src/main/assets/modules/__dialogs__.js @@ -154,10 +154,11 @@ module.exports = function(__runtime__, scope){ if(properties.inputHint != undefined || properties.inputPrefill != undefined){ builder.input(wrapNonNullString(properties.inputHint), wrapNonNullString(properties.inputPrefill), function(dialog, input){ + if (!builder.dialog) { return; } input = input.toString(); builder.dialog.emit("input_change", builder.dialog, input); }) -// .alwaysCallInputCallback(); + .alwaysCallInputCallback(); } if(properties.items != undefined){ var itemsSelectMode = properties.itemsSelectMode; @@ -168,15 +169,14 @@ module.exports = function(__runtime__, scope){ }else if(itemsSelectMode == 'single'){ builder.itemsCallbackSingleChoice(properties.itemsSelectedIndex == undefined ? -1 : properties.itemsSelectedIndex, function(dialog, view, which, text){ - builder.dialog.emit("single_choice", which, text.toString(), builder.dialog); + builder.dialog.emit("single_choice", which, text && text.toString(), builder.dialog); return true; }); }else if(itemsSelectMode == 'multi'){ builder.itemsCallbackMultiChoice(properties.itemsSelectedIndex == undefined ? null : properties.itemsSelectedIndex, function(dialog, view, indices, texts){ - builder.dialog.emit("multi_choice", toJsArray(indices, (l, i)=> parseInt(l.get(i)), - toJsArray(texts, (l, i)=> l.get(i).toString())), builder.dialog); - return true; + builder.dialog.emit("multi_choice", toJsArray(view, (l, i) => parseInt(l[i])), toJsArray(indices, (l, i) => l[i]), builder.dialog); + return true; }); }else{ throw new Error("unknown itemsSelectMode " + itemsSelectMode); @@ -222,9 +222,11 @@ module.exports = function(__runtime__, scope){ function toJsArray(object, adapter){ var jsArray = []; - var len = javaArray.length; - for (var i = 0;i < len;i++){ - jsArray.push(adapter(object, i)); + if (object != undefined) { + var len = object.length; + for (var i = 0; i < len; i++) { + jsArray.push(adapter(object, i)); + } } return jsArray; }