core :: union_find
union–find algorithm using an efficient disjoint-set data structure
# Services to display a _toast_, a small popup on Android
module toast
import dalvik
in "Java" `{
import android.widget.Toast;
`}
redef class App
# Display a _toast_ with `message`, for longer if `is_long`
fun toast(message: String, is_long: Bool)
do
var jstr = message.to_java_string
native_toast(jstr, is_long, native_activity)
jstr.delete_local_ref
end
private fun native_toast(message: JavaString, is_long: Bool, native_activity: NativeActivity) in "Java" `{
final android.app.Activity context = native_activity;
final CharSequence final_message = message;
final int duration = is_long? Toast.LENGTH_LONG: Toast.LENGTH_SHORT;
context.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast toast = Toast.makeText(context, final_message, duration);
toast.show();
}
});
`}
end
lib/android/toast.nit:17,1--48,3