Skip to content

Commit

Permalink
Ensure Android compatibility (#25)
Browse files Browse the repository at this point in the history
* 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 <michael.work@akinde.dk>
  • Loading branch information
MicaBytes and michaeloa committed Sep 20, 2022
1 parent 759a681 commit bcac457
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/com/bladecoder/ink/runtime/Flow.java
Expand Up @@ -30,7 +30,13 @@ public Flow(String name, Story story, HashMap<String, Object> 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<String, Object>) jChoiceThreadsObj, story);
}
Expand Down

0 comments on commit bcac457

Please sign in to comment.