Module: PMScreenModule
- Included in:
- PMScreen
- Defined in:
- lib/project/pro_motion/pm_screen_module.rb
Overview
hipbyte.myjetbrains.com/youtrack/issue/RM-773 - can’t put this in a module yet :( module ProMotion
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #action_bar ⇒ Object
- #activity ⇒ Object
- #append_view(view_or_class, style = nil, opts = {}) ⇒ Object
- #append_view!(view_or_class, style = nil, opts = {}) ⇒ Object
- #color(*params) ⇒ Object
- #font ⇒ Object
- #hide_keyboard ⇒ Object
- #image ⇒ Object
- #on_load ⇒ Object
- #open(screen_class, options = {}) ⇒ Object
-
#r(resource_type, resource_name) ⇒ Object
temporary stand-in for Java’s R class.
- #rmq(*working_selectors) ⇒ Object
- #rmq_data ⇒ Object
- #root_view ⇒ Object
- #show_toast(message) ⇒ Object
- #soft_input_mode(mode) ⇒ Object
- #start_activity(activity_class) ⇒ Object
- #stylesheet ⇒ Object
- #stylesheet=(value) ⇒ Object
Class Method Details
.included(base) ⇒ Object
4 5 6 |
# File 'lib/project/pro_motion/pm_screen_module.rb', line 4 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#action_bar ⇒ Object
160 161 162 |
# File 'lib/project/pro_motion/pm_screen_module.rb', line 160 def activity.getActionBar() end |
#activity ⇒ Object
156 157 158 |
# File 'lib/project/pro_motion/pm_screen_module.rb', line 156 def activity getActivity() end |
#append_view(view_or_class, style = nil, opts = {}) ⇒ Object
92 93 94 |
# File 'lib/project/pro_motion/pm_screen_module.rb', line 92 def append_view(view_or_class, style=nil, opts={}) self.rmq.append_view(view_or_class, style, opts) end |
#append_view!(view_or_class, style = nil, opts = {}) ⇒ Object
96 97 98 |
# File 'lib/project/pro_motion/pm_screen_module.rb', line 96 def append_view!(view_or_class, style=nil, opts={}) self.rmq.append_view(view_or_class, style, opts).get end |
#color(*params) ⇒ Object
80 81 82 |
# File 'lib/project/pro_motion/pm_screen_module.rb', line 80 def color(*params) RMQ.color(*params) end |
#font ⇒ Object
84 85 86 |
# File 'lib/project/pro_motion/pm_screen_module.rb', line 84 def font rmq.font end |
#hide_keyboard ⇒ Object
150 151 152 153 |
# File 'lib/project/pro_motion/pm_screen_module.rb', line 150 def hide_keyboard input_manager = activity.getSystemService(Android::Content::Context::INPUT_METHOD_SERVICE) input_manager.hideSoftInputFromWindow(view.getWindowToken(), 0); end |
#image ⇒ Object
88 89 90 |
# File 'lib/project/pro_motion/pm_screen_module.rb', line 88 def image rmq.image end |
#on_load ⇒ Object
76 77 78 |
# File 'lib/project/pro_motion/pm_screen_module.rb', line 76 def on_load # abstract end |
#open(screen_class, options = {}) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/project/pro_motion/pm_screen_module.rb', line 113 def open(screen_class, ={}) mp "ScreenModule open", debugging_only: true activity_class = [:activity] || PMSingleFragmentActivity # TODO: replace the fragment in the activity when possible # replace the fragment if we can; otherwise launch a new activity # we're taking a conservative approach for now - eventually we'll want to allow # replacing fragments for any kind of activity, but I'm not sure of the best way # to implement that yet intent = Android::Content::Intent.new(self.activity, activity_class) intent.putExtra PMSingleFragmentActivity::EXTRA_FRAGMENT_CLASS, screen_class.to_s ## TODO: limited support for extras for now - should reimplement with fragment arguments if [:extras] [:extras].keys.each do |key| intent.putExtra key.to_s, [:extras][key].toString end end self.activity.startActivity intent end |
#r(resource_type, resource_name) ⇒ Object
temporary stand-in for Java’s R class
104 105 106 107 |
# File 'lib/project/pro_motion/pm_screen_module.rb', line 104 def r(resource_type, resource_name) resources.getIdentifier(resource_name.to_s, resource_type.to_s, activity.getApplicationInfo.packageName) end |
#rmq(*working_selectors) ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/project/pro_motion/pm_screen_module.rb', line 62 def rmq(*working_selectors) crmq = (rmq_data.cached_rmq ||= RMQ.create_with_selectors([], self)) if working_selectors.length == 0 crmq else RMQ.create_with_selectors(working_selectors, self, crmq) end end |
#rmq_data ⇒ Object
50 51 52 |
# File 'lib/project/pro_motion/pm_screen_module.rb', line 50 def rmq_data @_rmq_data ||= RMQScreenData.new end |
#root_view ⇒ Object
72 73 74 |
# File 'lib/project/pro_motion/pm_screen_module.rb', line 72 def root_view self.getView end |
#show_toast(message) ⇒ Object
109 110 111 |
# File 'lib/project/pro_motion/pm_screen_module.rb', line 109 def show_toast() Android::Widget::Toast.makeText(activity, , Android::Widget::Toast::LENGTH_SHORT).show end |
#soft_input_mode(mode) ⇒ Object
141 142 143 144 145 146 147 148 |
# File 'lib/project/pro_motion/pm_screen_module.rb', line 141 def soft_input_mode(mode) mode_const = case mode when :adjust_resize Android::View::WindowManager::LayoutParams::SOFT_INPUT_ADJUST_RESIZE end activity.getWindow().setSoftInputMode(mode_const) end |
#start_activity(activity_class) ⇒ Object
135 136 137 138 139 |
# File 'lib/project/pro_motion/pm_screen_module.rb', line 135 def start_activity(activity_class) intent = Android::Content::Intent.new(self.activity, activity_class) #intent.putExtra("key", value); # Optional parameters self.activity.startActivity(intent) end |
#stylesheet ⇒ Object
54 55 56 |
# File 'lib/project/pro_motion/pm_screen_module.rb', line 54 def stylesheet self.rmq.stylesheet end |
#stylesheet=(value) ⇒ Object
58 59 60 |
# File 'lib/project/pro_motion/pm_screen_module.rb', line 58 def stylesheet=(value) self.rmq.stylesheet = value end |