nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
test_parser: add option `-x` to output XML
[nit.git]
/
examples
/
mnit_simple
/
src
/
simple_android.nit
diff --git
a/examples/mnit_simple/src/simple_android.nit
b/examples/mnit_simple/src/simple_android.nit
index
fe05f36
..
8d5a296
100644
(file)
--- a/
examples/mnit_simple/src/simple_android.nit
+++ b/
examples/mnit_simple/src/simple_android.nit
@@
-15,33
+15,35
@@
# limitations under the License.
module simple_android is
# limitations under the License.
module simple_android is
- java_package("org.nitlanguage.simple")
android_manifest("""<uses-permission android:name="android.permission.VIBRATE" />""")
end
android_manifest("""<uses-permission android:name="android.permission.VIBRATE" />""")
end
-import simple
import mnit_android
import mnit_android
+import android::portrait
+import serialization
+
+import simple
in "Java" `{
import android.content.Context;
import android.widget.Toast;
`}
in "Java" `{
import android.content.Context;
import android.widget.Toast;
`}
-redef class MyApp
+redef class App
redef fun input( ie )
do
redef fun input( ie )
do
- if ie isa PointerEvent and ie.depressed then do_java_stuff
-
+ if ie isa PointerEvent and ie.depressed then
+ test_java_ffi
+ end
return super
end
return super
end
- fun do_java_stuff import native_activity in "Java" `{
+ fun test_java_ffi import native_activity in "Java" `{
// + Log (no context needed)
android.util.Log.d("mnit_simple", "Java within NIT!!!");
// - Context needed from now on
// + Log (no context needed)
android.util.Log.d("mnit_simple", "Java within NIT!!!");
// - Context needed from now on
- // NativeActivity is a Java sub-class of Context
- final android.app.NativeActivity context = MyApp_native_activity(recv);
+ final android.app.Activity context = App_native_activity(recv);
// Vibration
android.os.Vibrator v = (android.os.Vibrator)
// Vibration
android.os.Vibrator v = (android.os.Vibrator)
@@
-61,3
+63,18
@@
redef class MyApp
});
`}
end
});
`}
end
+
+class Point
+ auto_serializable
+
+ var x: Int
+ var y: Int
+
+ init(x, y: Int)
+ do
+ self.x = x
+ self.y = y
+ end
+
+ redef fun to_s do return "({x}, {y})"
+end