Class: AMQView

Inherits:
Object
  • Object
show all
Defined in:
lib/android_motion_query/views.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view, activity, stylesheet, style_name, layout_params, options = {}) ⇒ AMQView

Returns a new instance of AMQView.



4
5
6
7
8
9
10
11
12
13
# File 'lib/android_motion_query/views.rb', line 4

def initialize(view, activity, stylesheet, style_name, layout_params, options = {})
  self.view = view
  self.activity = activity
  self.stylesheet = stylesheet
  self.style_name = style_name
  self.layout_params = layout_params
  self.options = {
    parent: nil,
  }.merge(options)
end

Instance Attribute Details

#activityObject

Returns the value of attribute activity.



2
3
4
# File 'lib/android_motion_query/views.rb', line 2

def activity
  @activity
end

#extraObject

Returns the value of attribute extra.



2
3
4
# File 'lib/android_motion_query/views.rb', line 2

def extra
  @extra
end

#layout_paramsObject

Returns the value of attribute layout_params.



2
3
4
# File 'lib/android_motion_query/views.rb', line 2

def layout_params
  @layout_params
end

#optionsObject

Returns the value of attribute options.



2
3
4
# File 'lib/android_motion_query/views.rb', line 2

def options
  @options
end

#style_nameObject

Returns the value of attribute style_name.



2
3
4
# File 'lib/android_motion_query/views.rb', line 2

def style_name
  @style_name
end

#stylesheetObject

Returns the value of attribute stylesheet.



2
3
4
# File 'lib/android_motion_query/views.rb', line 2

def stylesheet
  @stylesheet
end

#viewObject

Returns the value of attribute view.



2
3
4
# File 'lib/android_motion_query/views.rb', line 2

def view
  @view
end

Instance Method Details

#adapter(list, &block) ⇒ Object



93
94
95
96
97
# File 'lib/android_motion_query/views.rb', line 93

def adapter(list, &block)
  # this method has to be called from a grid_view or similar views (which accept adapters)
  self.get.adapter = AMQAdapter.new(self.activity, list, &block)
  self
end

#add(view_sym, style, &block) ⇒ Object



41
42
43
# File 'lib/android_motion_query/views.rb', line 41

def add(view_sym, style, &block)
  self.send(view_sym, style, &block)
end

#bottomObject



21
# File 'lib/android_motion_query/views.rb', line 21

def bottom; get.getBottom end

#button(style_method, &block) ⇒ Object



73
74
75
76
# File 'lib/android_motion_query/views.rb', line 73

def button(style_method, &block)
  view = Android::Widget::Button.new(self.activity)
  new_view(view, style_method, &block)
end

#create_android_query_view(view, style_method, layout_params, options = {}, &block) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/android_motion_query/views.rb', line 33

def create_android_query_view(view, style_method, layout_params, options = {}, &block)
  aqv = AMQView.new(view, self.activity, self.stylesheet, style_method, layout_params, options)
  self.stylesheet.apply_style_for(aqv, style_method, layout_params)
  self.get.addView(aqv.get)
  block.call(aqv) if block_given?
  aqv
end

#data(t) ⇒ Object



27
# File 'lib/android_motion_query/views.rb', line 27

def data(t); get.text = t; self end

#edit_text(style_method, &block) ⇒ Object



68
69
70
71
# File 'lib/android_motion_query/views.rb', line 68

def edit_text(style_method, &block)
  view = Android::Widget::EditText.new(self.activity)
  new_view(view, style_method, &block)
end

#frame_layout(style_method, &block) ⇒ Object



57
58
59
60
61
# File 'lib/android_motion_query/views.rb', line 57

def frame_layout(style_method, &block)
  view = Android::Widget::FrameLayout.new(self.activity)
  lp = Android::Widget::FrameLayout::LayoutParams
  create_android_query_view(view, style_method, lp, {}, &block)
end

#getObject



18
# File 'lib/android_motion_query/views.rb', line 18

def get; self.view end

#grid_view(style_method, &block) ⇒ Object



88
89
90
91
# File 'lib/android_motion_query/views.rb', line 88

def grid_view(style_method, &block)
  view = Android::Widget::GridView.new(self.activity)
  new_view(view, style_method, &block)
end

#heightObject



24
# File 'lib/android_motion_query/views.rb', line 24

def height; get.getHeight end

#idObject

convenience methods



16
# File 'lib/android_motion_query/views.rb', line 16

def id; get.id end

#id=(vid) ⇒ Object



17
# File 'lib/android_motion_query/views.rb', line 17

def id=(vid); get.id = vid; self end

#image_button(style_method, &block) ⇒ Object



83
84
85
86
# File 'lib/android_motion_query/views.rb', line 83

def image_button(style_method, &block)
  view = Android::Widget::ImageButton.new(self.activity)
  new_view(view, style_method, &block)
end

#image_view(style_method, &block) ⇒ Object



78
79
80
81
# File 'lib/android_motion_query/views.rb', line 78

def image_view(style_method, &block)
  view = Android::Widget::ImageView.new(self.activity)
  new_view(view, style_method, &block)
end

#leftObject



19
# File 'lib/android_motion_query/views.rb', line 19

def left; get.getLeft end

#linear_layout(style_method, &block) ⇒ Object



45
46
47
48
49
# File 'lib/android_motion_query/views.rb', line 45

def linear_layout(style_method, &block)
  view = Android::Widget::LinearLayout.new(self.activity)
  lp = Android::Widget::LinearLayout::LayoutParams
  create_android_query_view(view, style_method, lp, {}, &block)
end

#new_view(view, style_method, &block) ⇒ Object



99
100
101
# File 'lib/android_motion_query/views.rb', line 99

def new_view(view, style_method, &block)
  create_android_query_view(view, style_method, self.layout_params, {}, &block)
end

#relative_layout(style_method, &block) ⇒ Object



51
52
53
54
55
# File 'lib/android_motion_query/views.rb', line 51

def relative_layout(style_method, &block)
  view = Android::Widget::RelativeLayout.new(self.activity)
  lp = Android::Widget::RelativeLayout::LayoutParams
  create_android_query_view(view, style_method, lp, {}, &block)
end

#rightObject



20
# File 'lib/android_motion_query/views.rb', line 20

def right; get.getRight end

#tap(&block) ⇒ Object



28
29
30
31
# File 'lib/android_motion_query/views.rb', line 28

def tap(&block)
  self.get.onClickListener = AMQTapListener.new(self.activity, self, &block)
  self
end

#textObject



25
# File 'lib/android_motion_query/views.rb', line 25

def text; get.text end

#text=(t) ⇒ Object



26
# File 'lib/android_motion_query/views.rb', line 26

def text=(t); get.text = t end

#text_view(style_method, &block) ⇒ Object



63
64
65
66
# File 'lib/android_motion_query/views.rb', line 63

def text_view(style_method, &block)
  view = Android::Widget::TextView.new(self.activity)
  new_view(view, style_method, &block)
end

#topObject



22
# File 'lib/android_motion_query/views.rb', line 22

def top; get.getTop end

#widthObject



23
# File 'lib/android_motion_query/views.rb', line 23

def width; get.getWidth end