# methods of the main thread to customize the response to a given event.
#
# This graph shows the path of a button click:
-# ~~~
+# ~~~raw
# UI Thread # Main thread
#
# User
import pthreads::concurrent_collections
in "Java" `{
- import android.app.NativeActivity;
+ import android.app.Activity;
import android.view.Gravity;
import android.view.MotionEvent;
redef extern class NativeActivity
- # Fill this entire `NativeActivity` with `popup`
- #
- # This is a workaround for the use on `takeSurface` in `NativeActivity.java`
- #
- # TODO replace NativeActivity by our own NitActivity
- private fun dedicate_to_popup(popup: NativePopupWindow, popup_layout: NativeViewGroup) in "Java" `{
- final LinearLayout final_main_layout = new LinearLayout(recv);
- final ViewGroup final_popup_layout = popup_layout;
- final PopupWindow final_popup = popup;
- final NativeActivity final_recv = recv;
-
- recv.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- MarginLayoutParams params = new MarginLayoutParams(
- LinearLayout.LayoutParams.MATCH_PARENT,
- LinearLayout.LayoutParams.MATCH_PARENT);
-
- final_recv.setContentView(final_main_layout, params);
-
- final_popup.showAtLocation(final_popup_layout, Gravity.TOP, 0, 40);
- }
- });
- `}
-
# Set the main layout of this activity
- fun content_view=(layout: NativeViewGroup)
- do
- var popup = new NativePopupWindow(self)
- popup.content_view = layout
- dedicate_to_popup(popup, layout)
- end
-
- # Set the real content view of this activity, without hack
- #
- # TODO bring use this instead of the hack with `dedicate_to_pupup`
- private fun real_content_view=(layout: NativeViewGroup) in "Java" `{
+ fun content_view=(layout: NativeViewGroup) in "Java" `{
final ViewGroup final_layout = layout;
- final NativeActivity final_recv = recv;
+ final Activity final_recv = recv;
recv.runOnUiThread(new Runnable() {
@Override
fun text=(value: JavaString) in "Java" `{
- android.util.Log.d("Nity", "1");
final TextView final_recv = recv;
final String final_value = value;
- android.util.Log.d("Nity", "4");
- ((NativeActivity)recv.getContext()).runOnUiThread(new Runnable() {
+ ((Activity)recv.getContext()).runOnUiThread(new Runnable() {
@Override
public void run() {
- android.util.Log.d("Nity", "-5");
- android.util.Log.d("Nity", final_value);
- android.util.Log.d("Nity", "-5.5");
final_recv.setText(final_value);
- android.util.Log.d("Nity", "-6");
}
});
- android.util.Log.d("Nity", "7");
`}
fun enabled: Bool in "Java" `{ return recv.isEnabled(); `}
final TextView final_recv = recv;
final boolean final_value = value;
- ((NativeActivity)recv.getContext()).runOnUiThread(new Runnable() {
+ ((Activity)recv.getContext()).runOnUiThread(new Runnable() {
@Override
public void run() {
final_recv.setEnabled(final_value);