Last active
December 22, 2015 17:59
-
-
Save arturaz/6510264 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using UnityEngine; | |
class TestCallback { | |
public static AndroidJavaObject apply<T1, T2>(Action<T1, T2> action) { | |
var cb = new AndroidJavaObject("TestCallback"); | |
cb.Call("setRunnable", new AndroidJavaRunnable(() => { | |
var p1 = cb.Call<T1>("getParam1"); | |
var p2 = cb.Call<T2>("getParam2"); | |
action.Invoke(p1, p2); | |
})); | |
return cb; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestCallback<T1, T2> { | |
private Runnable runnable; | |
private T1 param1; | |
private T2 param2; | |
public void setRunnable(Runnable runnable) { | |
this.runnable = runnable; | |
} | |
public void call(T1 param1, T2 param2) { | |
this.param1 = param1; | |
this.param2 = param2; | |
runnable.run(); | |
} | |
public T1 getParam1() { | |
return param1; | |
} | |
public T2 getParam2() { | |
return param2; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment