Improve management of NULL's on block inputs.
This commit is contained in:
parent
047a13120e
commit
ceee0db011
@ -70,16 +70,22 @@ public class DefaultAndroidBlocks {
|
|||||||
if (params.size() != 2) {
|
if (params.size() != 2) {
|
||||||
throw new Exception("Expected two (2) arguments, found " + params.size());
|
throw new Exception("Expected two (2) arguments, found " + params.size());
|
||||||
}
|
}
|
||||||
String title = params.get(0).toString();
|
String title = params.get(0) == null ? null : params.get(0).toString();
|
||||||
String description = params.get(1).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)
|
.Builder(ctx, ProgramakerBridgeService.BridgeUserNotificationChannel)
|
||||||
.setContentTitle(title)
|
|
||||||
.setContentText(description)
|
|
||||||
.setSmallIcon(R.drawable.ic_vector_icon_user_triggered)
|
.setSmallIcon(R.drawable.ic_vector_icon_user_triggered)
|
||||||
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
.setPriority(NotificationCompat.PRIORITY_DEFAULT);
|
||||||
.build();
|
|
||||||
|
if (title != null) {
|
||||||
|
notifBuilder.setContentTitle(title);
|
||||||
|
}
|
||||||
|
if (description != null) {
|
||||||
|
notifBuilder.setContentText(description);
|
||||||
|
}
|
||||||
|
|
||||||
|
Notification notif = notifBuilder.build();
|
||||||
|
|
||||||
int notificationId = notificationRandom.nextInt();
|
int notificationId = notificationRandom.nextInt();
|
||||||
notificationManager.notify(notificationId, notif);
|
notificationManager.notify(notificationId, notif);
|
||||||
|
@ -386,11 +386,16 @@ public class ProgramakerCustomBlockPart implements Part {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
arguments.add(lastValues[index].toString()); // TODO: Do proper type formatting
|
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);
|
ProgramakerFunctionCallResult result = api.callBlock(this._block, arguments);
|
||||||
Log.d(LogTag, "Execution result="+result.getResult());
|
Log.i(LogTag, "Execution result="+result.getResult());
|
||||||
|
|
||||||
onExecutionCompleted(result);
|
onExecutionCompleted(result);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user