assets/src/ruboto/activity.rb in ruboto-0.10.2 vs assets/src/ruboto/activity.rb in ruboto-0.11.0.rc.0
- old
+ new
@@ -13,11 +13,11 @@
# Context
#
module Ruboto
module Context
def start_ruboto_dialog(remote_variable, theme=Java::android.R.style::Theme_Dialog, &block)
- java_import "org.ruboto.RubotoDialog"
+ java_import 'org.ruboto.RubotoDialog'
start_ruboto_activity(remote_variable, RubotoDialog, theme, &block)
end
def start_ruboto_activity(global_variable_name = '$block_based_activity', klass=RubotoActivity, theme=nil, options = nil, &block)
# FIXME(uwe): Translate old positional signature to new options-based signature.
@@ -26,26 +26,25 @@
if global_variable_name.is_a?(Hash)
options = global_variable_name
else
options = {}
end
- global_variable_name = nil
end
- class_name = options[:class_name] || "#{klass.name.split('::').last}_#{source_descriptor(block)[0].split("/").last.gsub(/[.-]+/, '_')}_#{source_descriptor(block)[1]}"
- if !Object.const_defined?(class_name)
- Object.const_set(class_name, Class.new(&block))
- else
+ class_name = options[:class_name] || "#{klass.name.split('::').last}_#{source_descriptor(block)[0].split('/').last.gsub(/[.-]+/, '_')}_#{source_descriptor(block)[1]}"
+ if Object.const_defined?(class_name)
Object.const_get(class_name).class_eval(&block) if block_given?
+ else
+ Object.const_set(class_name, Class.new(&block))
end
b = Java::android.os.Bundle.new
- b.putInt("Theme", theme) if theme
- b.putString("ClassName", class_name)
- b.putString("Script", options[:script]) if options[:script]
+ b.putInt('Theme', theme) if theme
+ b.putString('ClassName', class_name)
+ b.putString('Script', options[:script]) if options[:script]
i = android.content.Intent.new
i.setClass self, klass.java_class
- i.putExtra("Ruboto Config", b)
+ i.putExtra('Ruboto Config', b)
startActivity i
self
end
private
@@ -59,11 +58,11 @@
end
end
-java_import "android.content.Context"
+java_import 'android.content.Context'
Context.class_eval do
include Ruboto::Context
end
#
@@ -83,9 +82,9 @@
klass.class_eval do
include Ruboto::Activity
end
end
-java_import "android.app.Activity"
-java_import "org.ruboto.RubotoActivity"
+java_import 'android.app.Activity'
+java_import 'org.ruboto.RubotoActivity'
ruboto_configure_activity(RubotoActivity)