Class: Activity
Constant Summary collapse
- @@before_content_blocks =
[]
Class Method Summary collapse
- .add_before_content_render_task(&block) ⇒ Object
- .before_render(*symbols) ⇒ Object
- .landscape_mode_only ⇒ Object
- .no_action_bar ⇒ Object
- .on_click(name, &block) ⇒ Object
- .portrait_mode_only ⇒ Object
- .set_theme(theme, namespace = nil) ⇒ Object
Instance Method Summary collapse
- #before_content_render ⇒ Object
-
#initialize ⇒ Activity
constructor
A new instance of Activity.
- #me ⇒ Object
- #on_activity_reload ⇒ Object
- #on_activity_result(request_code, result_code, intent) ⇒ Object
Constructor Details
#initialize ⇒ Activity
Returns a new instance of Activity.
5 6 |
# File 'lib/droiuby/wrappers/activity.rb', line 5 def initialize end |
Class Method Details
.add_before_content_render_task(&block) ⇒ Object
43 44 45 46 |
# File 'lib/droiuby/wrappers/activity.rb', line 43 def add_before_content_render_task(&block) @@before_content_blocks = @@before_content_blocks || [] @@before_content_blocks << block end |
.before_render(*symbols) ⇒ Object
48 49 50 51 52 |
# File 'lib/droiuby/wrappers/activity.rb', line 48 def before_render(*symbols) add_before_content_render_task do |instance| symbols.each { |sym| instance.send(sym.to_sym) } end end |
.landscape_mode_only ⇒ Object
27 28 29 |
# File 'lib/droiuby/wrappers/activity.rb', line 27 def landscape_mode_only add_before_content_render_task { |instance| _current_activity.setRequestedOrientation(ActivityInfo::SCREEN_ORIENTATION_LANDSCAPE) } end |
.no_action_bar ⇒ Object
31 32 33 |
# File 'lib/droiuby/wrappers/activity.rb', line 31 def add_before_content_render_task { |instance| _current_activity.requestWindowFeature(Java::android.view.Window::FEATURE_NO_TITLE) } end |
.on_click(name, &block) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/droiuby/wrappers/activity.rb', line 14 def on_click(name, &block) view = V(name).tap { |v| v.native.setOnClickListener(Java::com.droiuby.client.core.OnClickListenerBridge.new(_execution_bundle, v.id)) } define_method("on_click_listener_for_#{view.id.to_s}".to_sym) do |n_view| _current_activity.instance_exec(wrap_native_view(n_view),&block) end end |
.portrait_mode_only ⇒ Object
23 24 25 |
# File 'lib/droiuby/wrappers/activity.rb', line 23 def portrait_mode_only add_before_content_render_task { |instance| _current_activity.setRequestedOrientation(ActivityInfo::SCREEN_ORIENTATION_PORTRAIT) } end |
.set_theme(theme, namespace = nil) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/droiuby/wrappers/activity.rb', line 35 def set_theme(theme, namespace = nil) namespace = "#{namespace}." unless namespace.nil? add_before_content_render_task do |instance| _current_activity.setTheme(_R("#{namespace}R.style.#{theme}")) end end |
Instance Method Details
#before_content_render ⇒ Object
60 61 62 63 |
# File 'lib/droiuby/wrappers/activity.rb', line 60 def before_content_render @@before_content_blocks.each { |block| block.call(self) } _current_activity.setContentView(_R('R.layout.canvas')) end |
#me ⇒ Object
8 9 10 |
# File 'lib/droiuby/wrappers/activity.rb', line 8 def me _current_activity end |
#on_activity_reload ⇒ Object
65 66 |
# File 'lib/droiuby/wrappers/activity.rb', line 65 def on_activity_reload end |
#on_activity_result(request_code, result_code, intent) ⇒ Object
56 57 58 |
# File 'lib/droiuby/wrappers/activity.rb', line 56 def on_activity_result(request_code, result_code, intent) end |