Class: AndroidMotionQuery
- Inherits:
-
Object
- Object
- AndroidMotionQuery
- Defined in:
- lib/android_motion_query/amq.rb
Instance Attribute Summary collapse
-
#activity ⇒ Object
Returns the value of attribute activity.
-
#root ⇒ Object
Returns the value of attribute root.
-
#stylesheet ⇒ Object
Returns the value of attribute stylesheet.
-
#view_ids ⇒ Object
Returns the value of attribute view_ids.
Instance Method Summary collapse
- #add(view_sym, style, &block) ⇒ Object
- #create_android_query_view(view, style_method, layout_params, options = {}, &block) ⇒ Object
- #create_standalone_amq_view(view, style_method, layout_params, options = {}, &block) ⇒ Object
- #find(id) ⇒ Object
- #frame_layout(style_method, &block) ⇒ Object
-
#initialize(activity) ⇒ AndroidMotionQuery
constructor
A new instance of AndroidMotionQuery.
- #linear_layout(style_method, &block) ⇒ Object
- #relative_layout(style_method, &block) ⇒ Object
- #text_view(style_method, &block) ⇒ Object
- #toast(text, options = {}) ⇒ Object
Constructor Details
#initialize(activity) ⇒ AndroidMotionQuery
Returns a new instance of AndroidMotionQuery.
5 6 7 8 |
# File 'lib/android_motion_query/amq.rb', line 5 def initialize(activity) self.activity = activity self end |
Instance Attribute Details
#activity ⇒ Object
Returns the value of attribute activity.
2 3 4 |
# File 'lib/android_motion_query/amq.rb', line 2 def activity @activity end |
#root ⇒ Object
Returns the value of attribute root.
2 3 4 |
# File 'lib/android_motion_query/amq.rb', line 2 def root @root end |
#stylesheet ⇒ Object
Returns the value of attribute stylesheet.
3 4 5 |
# File 'lib/android_motion_query/amq.rb', line 3 def stylesheet @stylesheet end |
#view_ids ⇒ Object
Returns the value of attribute view_ids.
2 3 4 |
# File 'lib/android_motion_query/amq.rb', line 2 def view_ids @view_ids end |
Instance Method Details
#add(view_sym, style, &block) ⇒ Object
33 34 35 |
# File 'lib/android_motion_query/amq.rb', line 33 def add(view_sym, style, &block) self.send(view_sym, style, &block) end |
#create_android_query_view(view, style_method, layout_params, options = {}, &block) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/android_motion_query/amq.rb', line 14 def create_android_query_view(view, style_method, layout_params, = {}, &block) self.root = AMQView.new(view, self.activity, self.stylesheet, style_method, layout_params, ) self.stylesheet.apply_style_for(self.root, style_method, layout_params) block.call(self.root) if block_given? self.activity.setContentView(self.root.get) self end |
#create_standalone_amq_view(view, style_method, layout_params, options = {}, &block) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/android_motion_query/amq.rb', line 22 def create_standalone_amq_view(view, style_method, layout_params, = {}, &block) amq_view = AMQView.new(view, self.activity, self.stylesheet, style_method, layout_params, ) self.stylesheet.apply_style_for(amq_view, style_method, layout_params) block.call(amq_view) if block_given? amq_view end |
#find(id) ⇒ Object
29 30 31 |
# File 'lib/android_motion_query/amq.rb', line 29 def find(id) self.root.get.findViewById(id).tag end |
#frame_layout(style_method, &block) ⇒ Object
49 50 51 52 53 |
# File 'lib/android_motion_query/amq.rb', line 49 def frame_layout(style_method, &block) view = Android::Widget::FrameLayout.new(self.activity) layout_params = Android::Widget::FrameLayout::LayoutParams create_android_query_view(view, style_method, layout_params, {}, &block) end |
#linear_layout(style_method, &block) ⇒ Object
37 38 39 40 41 |
# File 'lib/android_motion_query/amq.rb', line 37 def linear_layout(style_method, &block) view = Android::Widget::LinearLayout.new(self.activity) layout_params = Android::Widget::LinearLayout::LayoutParams create_android_query_view(view, style_method, layout_params, {}, &block) end |
#relative_layout(style_method, &block) ⇒ Object
43 44 45 46 47 |
# File 'lib/android_motion_query/amq.rb', line 43 def relative_layout(style_method, &block) view = Android::Widget::RelativeLayout.new(self.activity) layout_params = Android::Widget::RelativeLayout::LayoutParams create_android_query_view(view, style_method, layout_params, {}, &block) end |
#text_view(style_method, &block) ⇒ Object
55 56 57 58 59 |
# File 'lib/android_motion_query/amq.rb', line 55 def text_view(style_method, &block) view = Android::Widget::TextView.new(self.activity) layout_params = Android::Widget::LinearLayout::LayoutParams create_standalone_amq_view(view, style_method, layout_params, {}, &block) end |
#toast(text, options = {}) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/android_motion_query/amq.rb', line 61 def toast(text, = {}) = { gravity: :bottom, length: :short }.merge() = { top: Android::View::Gravity::TOP, left: Android::View::Gravity::LEFT, right: Android::View::Gravity::RIGHT, bottom: Android::View::Gravity::BOTTOM, center: Android::View::Gravity::CENTER, bottom_right: Android::View::Gravity::BOTTOM | Android::View::Gravity::RIGHT, bottom_left: Android::View::Gravity::BOTTOM | Android::View::Gravity::LEFT, center_right: Android::View::Gravity::CENTER | Android::View::Gravity::RIGHT, center_left: Android::View::Gravity::CENTER | Android::View::Gravity::LEFT, top_right: Android::View::Gravity::TOP | Android::View::Gravity::RIGHT, top_left: Android::View::Gravity::TOP | Android::View::Gravity::LEFT, } = { short: Android::Widget::Toast::LENGTH_SHORT, long: Android::Widget::Toast::LENGTH_LONG, } the_toast = Android::Widget::Toast.makeText(self.activity, text, [[:length]]) the_toast.setGravity([[:gravity]], 0, 0) the_toast.show end |