# Called by `Bundle::[]=` to dynamically choose the appropriate method according
# to the value type to store
# Non-primitive Object (`String` excluded) will be stored as a serialized json `String`
# Refine your class to customize this method behaviour
protected fun add_to_bundle(bundle: NativeBundle, key: JavaString)
do
sys.jni_env.push_local_frame(1)
var serialized_string = new StringWriter
var serializer = new JsonSerializer(serialized_string)
serializer.serialize(self)
bundle.put_string(key, serialized_string.to_s.to_java_string)
end
lib/android/bundle/bundle.nit:671,2--683,4
redef fun add_to_bundle(bundle, key)
do
bundle.put_boolean(key, self)
end
lib/android/bundle/bundle.nit:708,2--711,4
redef fun add_to_bundle(bundle, key)
do
bundle.put_char(key, self)
end
lib/android/bundle/bundle.nit:694,2--697,4
redef fun add_to_bundle(bundle, key)
do
bundle.put_double(key, self)
end
lib/android/bundle/bundle.nit:701,2--704,4
redef fun add_to_bundle(bundle, key)
do
bundle.put_long(key, self)
end
lib/android/bundle/bundle.nit:687,2--690,4
redef fun add_to_bundle(bundle, key)
do
if self isa Array[Bool] then
bundle.put_boolean_array(key, self)
else if self isa Array[Int] then
bundle.put_long_array(key, self)
else if self isa Array[Float] then
bundle.put_double_array(key, self)
else if self isa Array[Char] then
bundle.put_char_array(key, self)
else if self isa Array[String] then
sys.jni_env.push_local_frame(self.length)
var java_string_array = new Array[JavaString]
for element in self do
java_string_array.push(element.to_s.to_java_string)
end
bundle.put_string_array(key, java_string_array)
else if self isa Array[Serializable] then
sys.jni_env.push_local_frame(self.length)
var java_string_array = new Array[JavaString]
for element in self do
var serialized_string = new StringWriter
var serializer = new JsonSerializer(serialized_string)
serializer.serialize(element)
java_string_array.add(serialized_string.to_s.to_java_string)
end
bundle.put_string_array(key, java_string_array)
end
end
lib/android/bundle/bundle.nit:722,2--754,4
redef fun add_to_bundle(bundle, key)
do
bundle.put_string(key, self.to_java_string)
end
lib/android/bundle/bundle.nit:715,2--718,4