Skip to content

Commit

Permalink
Null Handling
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham1g5 committed Dec 5, 2024
1 parent 36bbe67 commit 10f3548
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app/src/org/commcare/tasks/EntityLoaderHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,15 @@ class EntityLoaderHelper(
/**
* Loads and prepares a list of entities derived from the given nodeset
*/
fun loadEntities(nodeset: TreeReference): Pair<List<Entity<TreeReference>>, List<TreeReference>> {
fun loadEntities(nodeset: TreeReference): Pair<List<Entity<TreeReference>>, List<TreeReference>>? {
val references = factory.expandReferenceList(nodeset)
val entities = loadEntitiesWithReferences(references)
factory.prepareEntities(entities)
factory.printAndClearTraces("build")
return Pair<List<Entity<TreeReference>>, List<TreeReference>>(entities, references)
entities?.let {
factory.prepareEntities(entities)
factory.printAndClearTraces("build")
return Pair<List<Entity<TreeReference>>, List<TreeReference>>(entities, references)
}
return null
}


Expand Down
4 changes: 4 additions & 0 deletions app/src/org/commcare/tasks/EntityLoaderTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ protected void onPostExecute(Pair<List<Entity<TreeReference>>, List<TreeReferenc
return;
}

if (result == null) {
return;
}

listener.deliverLoadResult(result.first, result.second, entityLoaderHelper.getFactory(),
entityLoaderHelper.getFocusTargetIndex());
return;
Expand Down

0 comments on commit 10f3548

Please sign in to comment.