From bcac4576e25b82e54653d93fe6674cf9586fe737 Mon Sep 17 00:00:00 2001 From: MicaBytes Date: Tue, 20 Sep 2022 09:51:26 +0200 Subject: [PATCH] Ensure Android compatibility (#25) * Fixed a line of code using a construct that is not available in early Android SDK versions. This causes crashes in Android with SDK < 24. * Update gradle.properties Co-authored-by: Michael Akinde --- src/main/java/com/bladecoder/ink/runtime/Flow.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/bladecoder/ink/runtime/Flow.java b/src/main/java/com/bladecoder/ink/runtime/Flow.java index 484b357..74b8057 100644 --- a/src/main/java/com/bladecoder/ink/runtime/Flow.java +++ b/src/main/java/com/bladecoder/ink/runtime/Flow.java @@ -30,7 +30,13 @@ public Flow(String name, Story story, HashMap jObject) throws Ex // choiceThreads is optional Object jChoiceThreadsObj; - jChoiceThreadsObj = jObject.getOrDefault("choiceThreads", null); + // This does not work in Android with SDK < 24 + //jChoiceThreadsObj = jObject.getOrDefault("choiceThreads", null); + if (jObject.containsKey("choiceThreads")) { + jChoiceThreadsObj = jObject.get("choiceThreads"); + } else { + jChoiceThreadsObj = null; + } loadFlowChoiceThreads((HashMap) jChoiceThreadsObj, story); }