Class: AndroidMotionQuery::StylesheetElement

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

Constant Summary collapse

LAYOUT_SIZE_OPTIONS =
{
  mp: Android::View::ViewGroup::LayoutParams::MATCH_PARENT,
  wc: Android::View::ViewGroup::LayoutParams::WRAP_CONTENT,
}
ORIENTATION_OPTIONS =
{
  vertical: Android::Widget::LinearLayout::VERTICAL,
  horizontal: Android::Widget::LinearLayout::HORIZONTAL,
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view, layout_params) ⇒ StylesheetElement

Returns a new instance of StylesheetElement.



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

def initialize(view, layout_params)
  self.view = view
  self.params = layout_params.new(LAYOUT_SIZE_OPTIONS[:mp], LAYOUT_SIZE_OPTIONS[:wc])
  self
end

Instance Attribute Details

#paramsObject

Returns the value of attribute params.



60
61
62
# File 'lib/android_query/views.rb', line 60

def params
  @params
end

#viewObject

Returns the value of attribute view.



60
61
62
# File 'lib/android_query/views.rb', line 60

def view
  @view
end

Instance Method Details

#click=(method_name) ⇒ Object



112
113
114
# File 'lib/android_query/views.rb', line 112

def click=(method_name)
  self.view.get.onClickListener = AQClickListener.new(self.view.activity, method_name)
end

#height=(h) ⇒ Object



90
91
92
93
94
95
96
# File 'lib/android_query/views.rb', line 90

def height=(h)
  if h == :mp || h == :wc
    self.params.height = LAYOUT_SIZE_OPTIONS[h]
  else
    self.params.height = h
  end
end

#orientation=(o) ⇒ Object



98
99
100
101
102
# File 'lib/android_query/views.rb', line 98

def orientation=(o)
  if o == :vertical || o == :horizontal
    self.view.get.orientation = ORIENTATION_OPTIONS[o]
  end
end

#text=(t) ⇒ Object



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

def text=(t)
  self.view.get.text = t
end

#weight=(number) ⇒ Object



108
109
110
# File 'lib/android_query/views.rb', line 108

def weight=(number)
  self.params.weight = number
end

#weight_sum=(number) ⇒ Object



104
105
106
# File 'lib/android_query/views.rb', line 104

def weight_sum=(number)
  self.view.get.weightSum = number
end

#width=(w) ⇒ Object



82
83
84
85
86
87
88
# File 'lib/android_query/views.rb', line 82

def width=(w)
  if w == :mp || w == :wc
    self.params.width = LAYOUT_SIZE_OPTIONS[w]
  else
    self.params.width = w
  end
end