Class: AMQAdapter

Inherits:
Android::Widget::BaseAdapter
  • Object
show all
Defined in:
lib/android_motion_query/adapters.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, list, &block) ⇒ AMQAdapter

Returns a new instance of AMQAdapter.



4
5
6
7
8
9
# File 'lib/android_motion_query/adapters.rb', line 4

def initialize(context, list, &block)
  self.context = context
  self.items = list
  self.view_block = block if block_given?
  self
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.



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

def context
  @context
end

#itemsObject

Returns the value of attribute items.



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

def items
  @items
end

#view_blockObject

Returns the value of attribute view_block.



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

def view_block
  @view_block
end

Instance Method Details

#custom_view(position, convert_view, parent, &block) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/android_motion_query/adapters.rb', line 27

def custom_view(position, convert_view, parent, &block)
  if block_given?
    block.call(self.items[position], position)
  else
    text_view = Android::Widget::TextView.new(self.context)
    text_view.text = self.items[position]
    text_view
  end
end

#getCountObject



11
12
13
# File 'lib/android_motion_query/adapters.rb', line 11

def getCount
  self.items.count
end

#getItem(position) ⇒ Object



19
20
21
# File 'lib/android_motion_query/adapters.rb', line 19

def getItem(position)
  self.items[position]
end

#getItemId(position) ⇒ Object



15
16
17
# File 'lib/android_motion_query/adapters.rb', line 15

def getItemId(position)
  0
end

#getView(position, convert_view, parent) ⇒ Object



23
24
25
# File 'lib/android_motion_query/adapters.rb', line 23

def getView(position, convert_view, parent)
  self.custom_view(position, convert_view, parent, &self.view_block)
end