Class: PMListScreen

Inherits:
Android::App::ListFragment
  • Object
show all
Includes:
PMScreenModule
Defined in:
lib/project/pro_motion/fragments/pm_list_screen.rb

Overview

hipbyte.myjetbrains.com/youtrack/issue/RM-773 - can’t put this in a module yet :( module ProMotion

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PMScreenModule

#action_bar, #add_action_bar_button, #append, #append!, #build, #build!, #build_and_tag_xml_views, #cleanup, #close, #color, #create, #create!, #dummy_workaround_for_kind_of, #find, #font, #hide_keyboard, #image, included, #log_tree, #menu, #on_options_item_selected, #on_return, #open, #open_modal, #r, #rmq, #rmq_data, #root_view, #set_title, #set_up_action_bar, #show_keyboard, #show_toast, #soft_input_mode, #start_activity, #stylesheet, #stylesheet=, #title, #title=

Instance Attribute Details

#viewObject

Returns the value of attribute view.



7
8
9
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 7

def view
  @view
end

Instance Method Details

#adapterObject



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 48

def adapter
  @adapter ||= begin
    td = table_data
    if td.is_a?(Array)
      cells = td.first[:cells]
      PMBaseAdapter.new(data: cells)
    elsif td.is_a?(Hash)
      mp "Please supply a cursor in #{self.inspect}#table_data." unless td[:cursor]
      PMCursorAdapter.new(td)
    end
  end
end

#add_adapterObject



44
45
46
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 44

def add_adapter
  self.view.setAdapter(adapter)
end

#add_empty_viewObject



35
36
37
38
39
40
41
42
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 35

def add_empty_view
  # append(Potion::TextView, :empty).style do |st|
  #   st.layout_width = :match_parent
  #   st.layout_height = :match_parent
  #   st.background = "#FFFFFF"
  #   st.text = "No data"
  # end
end

#add_table_viewObject



26
27
28
29
30
31
32
33
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 26

def add_table_view
  # create(Potion::ListView, :list).style do |st|
  #   st.layout_width = :match_parent
  #   st.layout_height = :match_parent
  #   st.layout_weight = 1
  #   st.view.drawSelectorOnTop = false
  # end
end

#load_viewObject



14
15
16
17
18
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 14

def load_view
  v = Potion::View.new(app.context) # TODO, fix this horrible hack
  lv = rmq(v).create(Potion::ListView).tag(:list)
  self.view = lv.get
end

#on_activity_createdObject



131
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 131

def on_activity_created; end

#on_attach(activity) ⇒ Object



79
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 79

def on_attach(activity); end

#on_create(bundle) ⇒ Object



82
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 82

def on_create(bundle); end

#on_create_menu(menu) ⇒ Object



140
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 140

def on_create_menu(menu); end

#on_create_view(inflater, parent, saved_instance_state) ⇒ Object



102
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 102

def on_create_view(inflater, parent, saved_instance_state); end

#on_destroyObject



152
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 152

def on_destroy; end

#on_destroy_viewObject



149
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 149

def on_destroy_view; end

#on_detachObject



159
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 159

def on_detach; end

#on_loadObject



130
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 130

def on_load; end

#on_pauseObject



143
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 143

def on_pause; end

#on_resumeObject



138
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 138

def on_resume; end

#on_startObject Also known as: on_appear



134
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 134

def on_start; end

#on_stopObject



146
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 146

def on_stop; end

#onActivityCreated(saved_instance_state) ⇒ Object

def load_view

Potion::FrameLayout.new(self.activity)

end



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 108

def onActivityCreated(saved_instance_state)
  mp "PMScreen onActivityCreated" if RMQ.debugging?

  super

  @view.rmq_data.is_screen_root_view = true

  self.rmq.build(@view)

  screen_setup

  if self.class.rmq_style_sheet_class
    self.rmq.stylesheet = self.class.rmq_style_sheet_class
    @view.rmq.apply_style(:root_view) #if @view.rmq.stylesheet.respond_to?(:root_view)
  end

  build_and_tag_xml_views

  set_title
  on_load
  on_activity_created
end

#onAttach(activity) ⇒ Object

Boilerplate from PMScreen ###



74
75
76
77
78
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 74

def onAttach(activity)
  super
  activity.on_fragment_attached(self) if activity.respond_to?(:on_fragment_attached)
  on_attach(activity)
end

#onCreate(bundle) ⇒ Object



81
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 81

def onCreate(bundle); super; on_create(bundle); end

#onCreateView(inflater, parent, saved_instance_state) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 84

def onCreateView(inflater, parent, saved_instance_state)
  super

  if @xml_resource = self.class.xml_resource
    @view = inflater.inflate(r(:layout, @xml_resource), parent, false)
  else
    v = load_view
    mp v
    @view ||= v
    @view.id = Potion::ViewIdGenerator.generate
  end

  set_up_action_bar(self.class.action_bar_options)

  on_create_view(inflater, parent, saved_instance_state)

  @view
end

#onDestroyObject



151
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 151

def onDestroy; super; on_destroy; end

#onDestroyViewObject



148
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 148

def onDestroyView; super; on_destroy_view; end

#onDetachObject



154
155
156
157
158
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 154

def onDetach
  super
  on_detach
  self.activity.on_fragment_detached(self) if self.activity.respond_to?(:on_fragment_detached)
end

#onPauseObject



142
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 142

def onPause; super; on_pause; end

#onResumeObject



137
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 137

def onResume; super; on_resume; end

#onStartObject



133
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 133

def onStart; super; on_start; end

#onStopObject



145
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 145

def onStop; super; on_stop; end

#screen_setupObject



20
21
22
23
24
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 20

def screen_setup
  add_table_view
  add_empty_view
  add_adapter
end

#table_dataObject



9
10
11
12
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 9

def table_data
  mp "Implement a table_data method in #{self.inspect}."
  []
end

#update_table_dataObject



61
62
63
64
65
66
67
68
69
70
# File 'lib/project/pro_motion/fragments/pm_list_screen.rb', line 61

def update_table_data
  # base adapters must reacquire their data from the PMListScreen "delegate"
  if adapter.instance_of?(PMCursorAdapter)
    # TODO:  Reload for PMCursorAdapter
  elsif adapter.is_a?(PMBaseAdapter)
    td = table_data
    adapter.data = td && td.first && td.first[:cells]
  end
  adapter.notifyDataSetChanged
end