diff --git a/app/Locabean/src/com/locaudio/api/Locaudio.java b/app/Locabean/src/com/locaudio/api/Locaudio.java index 825f2e9..3c286f9 100644 --- a/app/Locabean/src/com/locaudio/api/Locaudio.java +++ b/app/Locabean/src/com/locaudio/api/Locaudio.java @@ -13,7 +13,7 @@ public Locaudio(String ipAddress, int port) { } public AsyncGetRequest getSoundLocations( - final String soundName, final Function callback) { + final String soundName, final Function callback) { AsyncGetRequest agr = new AsyncGetRequest( SoundLocation[].class, LOCATIONS_ROUTE, soundName) { @@ -45,7 +45,7 @@ public void runOnceReceivedResponse(SoundLocation[] response) { return agr.getResponse(this); } - public AsyncGetRequest getNames(final Function callback) { + public AsyncGetRequest getNames(final Function callback) { AsyncGetRequest agr = new AsyncGetRequest( String[].class, NAMES_ROUTE) { @@ -76,7 +76,7 @@ public void runOnceReceivedResponse(String[] response) { } public AsyncPostRequest notifyEvent(final NotifyForm event, - final Function callback) { + final Function callback) { AsyncPostRequest apr = new AsyncPostRequest( NotifyResponse.class, event.toMap(), NOTIFY_ROUTE) { diff --git a/app/Locabean/src/com/locaudio/functional/Function.java b/app/Locabean/src/com/locaudio/functional/Function.java index 3e42c38..0be97ab 100644 --- a/app/Locabean/src/com/locaudio/functional/Function.java +++ b/app/Locabean/src/com/locaudio/functional/Function.java @@ -1,19 +1,9 @@ package com.locaudio.functional; -public abstract class Function { - public abstract void body(T input); +public abstract class Function { + public abstract R body(T input); - public void call(T input) { - body(input); - } - @SuppressWarnings("rawtypes") - public static Function getEmptyFunction() { - return new Function() { - - @Override - public void body(Object input) { - } - - }; + public R call(T input) { + return body(input); } } diff --git a/app/Locabean/src/com/locaudio/functional/UIFunction.java b/app/Locabean/src/com/locaudio/functional/UIFunction.java index 503de9b..5f3a152 100644 --- a/app/Locabean/src/com/locaudio/functional/UIFunction.java +++ b/app/Locabean/src/com/locaudio/functional/UIFunction.java @@ -2,7 +2,7 @@ import android.app.Activity; -public abstract class UIFunction extends Function { +public abstract class UIFunction extends Function { private Activity activity; @@ -10,15 +10,17 @@ public UIFunction(Activity activity) { this.activity = activity; } - public abstract void body(T input); + public abstract R body(T input); - public void call(final T input) { + public R call(final T input) { this.activity.runOnUiThread(new Runnable() { @Override public void run() { body(input); } }); + + return null; } } diff --git a/app/Locabean/src/com/locaudio/locabean/NodeActivity.java b/app/Locabean/src/com/locaudio/locabean/NodeActivity.java index 292e0a1..5416a5f 100644 --- a/app/Locabean/src/com/locaudio/locabean/NodeActivity.java +++ b/app/Locabean/src/com/locaudio/locabean/NodeActivity.java @@ -136,12 +136,14 @@ public void onClick(View v) { postForm.setY(0); locaudio.notifyEvent(postForm, - new UIFunction(self) { + new UIFunction(self) { @Override - public void body(NotifyResponse nr) { + public Void body(NotifyResponse nr) { nameTextView.setText(nr.name); confidenceTextView.setText("" + nr.confidence); + + return null; } });