Improve management of NULL's on block inputs.

This commit is contained in:
Sergio Martínez Portela 2020-05-28 17:59:26 +02:00
parent 047a13120e
commit ceee0db011
2 changed files with 20 additions and 9 deletions

View File

@ -70,16 +70,22 @@ public class DefaultAndroidBlocks {
if (params.size() != 2) {
throw new Exception("Expected two (2) arguments, found " + params.size());
}
String title = params.get(0).toString();
String description = params.get(1).toString();
String title = params.get(0) == null ? null : params.get(0).toString();
String description = params.get(1) == null ? null : params.get(1).toString();
Notification notif = new NotificationCompat
NotificationCompat.Builder notifBuilder = new NotificationCompat
.Builder(ctx, ProgramakerBridgeService.BridgeUserNotificationChannel)
.setContentTitle(title)
.setContentText(description)
.setSmallIcon(R.drawable.ic_vector_icon_user_triggered)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.build();
.setPriority(NotificationCompat.PRIORITY_DEFAULT);
if (title != null) {
notifBuilder.setContentTitle(title);
}
if (description != null) {
notifBuilder.setContentText(description);
}
Notification notif = notifBuilder.build();
int notificationId = notificationRandom.nextInt();
notificationManager.notify(notificationId, notif);

View File

@ -386,11 +386,16 @@ public class ProgramakerCustomBlockPart implements Part {
continue;
}
if (lastValues[index] == null) {
arguments.add(null); // TODO: Get default value from block definition
}
else {
arguments.add(lastValues[index].toString()); // TODO: Do proper type formatting
}
}
ProgramakerFunctionCallResult result = api.callBlock(this._block, arguments);
Log.d(LogTag, "Execution result="+result.getResult());
Log.i(LogTag, "Execution result="+result.getResult());
onExecutionCompleted(result);
}