Class: RMQTextViewStyler

Inherits:
RMQViewStyler show all
Defined in:
lib/project/ruby_motion_query/stylers/rmq_text_view_styler.rb

Direct Known Subclasses

RMQButtonStyler

Instance Attribute Summary

Attributes inherited from RMQViewStyler

#bg_color, #context, #corner_radius, #view

Instance Method Summary collapse

Methods inherited from RMQViewStyler

#background_color=, #background_resource=, #cleanup, #convert_color, #convert_gravity, #create_drawable, #density, #dp2px, #initialize, #layout=, #layout_align_parent_left=, #layout_align_parent_right=, #layout_center_horizontal=, #layout_center_in_parent=, #layout_center_vertical=, #layout_gravity=, #layout_height=, #layout_params, #layout_weight=, #layout_width=, #margin=, #margin_bottom=, #margin_left=, #margin_right=, #margin_top=, #padding=, #padding_bottom=, #padding_left=, #padding_right=, #padding_top=, #visibility=

Constructor Details

This class inherits a constructor from RMQViewStyler

Instance Method Details

#color=(text_color) ⇒ Object

[View source]

29
30
31
# File 'lib/project/ruby_motion_query/stylers/rmq_text_view_styler.rb', line 29

def color=(text_color)
  @view.textColor = convert_color(text_color)
end

#enabled=(enabled) ⇒ Object

[View source]

46
47
48
# File 'lib/project/ruby_motion_query/stylers/rmq_text_view_styler.rb', line 46

def enabled=(enabled)
  @view.setEnabled(enabled)
end

#finalizeObject

[View source]

50
51
52
53
54
55
56
57
# File 'lib/project/ruby_motion_query/stylers/rmq_text_view_styler.rb', line 50

def finalize
  super
  if @lazy_typeface
    @text_style ||= Android::Graphics::Typeface::NORMAL
    typeface = Android::Graphics::Typeface.create(@font_family, @text_style) if @font_family
    @view.setTypeface(typeface, @text_style) # ok for typeface to be nil
  end
end

#font=(rmq_font) ⇒ Object

[View source]

37
38
39
40
# File 'lib/project/ruby_motion_query/stylers/rmq_text_view_styler.rb', line 37

def font=(rmq_font)
  @view.setTypeface(rmq_font.to_typeface, rmq_font.sdk_text_style)
  @view.textSize = rmq_font.size
end

#font_family=(font_family) ⇒ Object

[View source]

6
7
8
9
# File 'lib/project/ruby_motion_query/stylers/rmq_text_view_styler.rb', line 6

def font_family=(font_family)
  @font_family = font_family
  @lazy_typeface = true
end

#gravity=(gravity) ⇒ Object

[View source]

42
43
44
# File 'lib/project/ruby_motion_query/stylers/rmq_text_view_styler.rb', line 42

def gravity=(gravity)
  @view.gravity = convert_gravity(gravity)
end

#text=(text) ⇒ Object

[View source]

33
34
35
# File 'lib/project/ruby_motion_query/stylers/rmq_text_view_styler.rb', line 33

def text=(text)
  @view.text = text
end

#text_color=(text_color) ⇒ Object

[View source]

26
27
28
# File 'lib/project/ruby_motion_query/stylers/rmq_text_view_styler.rb', line 26

def text_color=(text_color)
  @view.textColor = convert_color(text_color)
end

#text_size=(text_size) ⇒ Object

[View source]

2
3
4
# File 'lib/project/ruby_motion_query/stylers/rmq_text_view_styler.rb', line 2

def text_size=(text_size)
  @view.textSize = text_size
end

#text_style=(text_style) ⇒ Object

[View source]

11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/project/ruby_motion_query/stylers/rmq_text_view_styler.rb', line 11

def text_style=(text_style)
  @text_style =
    case text_style.to_s.downcase
    when "bold"
      Android::Graphics::Typeface::BOLD
    when "italic"
      Android::Graphics::Typeface::ITALIC
    when "bold italic"
      Android::Graphics::Typeface::BOLD_ITALIC
    when "normal"
      Android::Graphics::Typeface::NORMAL
    end
  @lazy_typeface = true
end