Class: PMNavigationActivity

Inherits:
PMActivity show all
Defined in:
lib/project/pro_motion/activities/pm_navigation_activity.rb

Overview

An Activity designed to host a stack of fragments/screens. RM-733 module ProMotion

Direct Known Subclasses

PMHomeActivity

Constant Summary

Constants inherited from PMActivity

PMActivity::EXTRA_FRAGMENT_ARGUMENTS, PMActivity::EXTRA_FRAGMENT_CLASS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from PMActivity

#clear_references, #close, #onActivityResult, #onBackPressed, #onCreate, #onCreateOptionsMenu, #onDestroy, #onOptionsItemSelected, #onPause, #onResume, #onStart, #on_resume, #open, #set_content

Instance Attribute Details

#fragment_containerObject

Returns the value of attribute fragment_container.



5
6
7
# File 'lib/project/pro_motion/activities/pm_navigation_activity.rb', line 5

def fragment_container
  @fragment_container
end

Returns the value of attribute menu.



5
6
7
# File 'lib/project/pro_motion/activities/pm_navigation_activity.rb', line 5

def menu
  @menu
end

#root_fragmentObject

Returns the value of attribute root_fragment.



5
6
7
# File 'lib/project/pro_motion/activities/pm_navigation_activity.rb', line 5

def root_fragment
  @root_fragment
end

Instance Method Details

#close_fragmentObject



31
32
33
# File 'lib/project/pro_motion/activities/pm_navigation_activity.rb', line 31

def close_fragment
  getFragmentManager.popBackStackImmediate
end

#fragmentObject



35
36
37
38
# File 'lib/project/pro_motion/activities/pm_navigation_activity.rb', line 35

def fragment
  # self.fragments.last
  getFragmentManager.findFragmentByTag("screen-#{fragmentManager.getBackStackEntryCount}")
end

#on_create(saved_instance_state) ⇒ Object



7
8
9
10
11
# File 'lib/project/pro_motion/activities/pm_navigation_activity.rb', line 7

def on_create(saved_instance_state)
  super
  # mp "PMNavigationActivity on_create", debugging_only: true
  activity_init
end

#on_create_menu(menu) ⇒ Object



13
14
15
16
# File 'lib/project/pro_motion/activities/pm_navigation_activity.rb', line 13

def on_create_menu(menu)
  @menu = menu
  self.fragment.on_create_menu(menu) if self.fragment
end

#on_fragment_attached(frag) ⇒ Object



40
41
42
# File 'lib/project/pro_motion/activities/pm_navigation_activity.rb', line 40

def on_fragment_attached(frag)
  # No-op for now.
end

#on_fragment_detached(frag) ⇒ Object



44
45
46
47
48
# File 'lib/project/pro_motion/activities/pm_navigation_activity.rb', line 44

def on_fragment_detached(frag)
  if new_frag = self.fragment
    new_frag.set_title if new_frag.respond_to?(:set_title)
  end
end

#on_options_item_selected(item) ⇒ Object



18
19
20
# File 'lib/project/pro_motion/activities/pm_navigation_activity.rb', line 18

def on_options_item_selected(item)
  self.fragment.on_options_item_selected(item) if self.fragment
end

#open_fragment(frag, options = {}) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/project/pro_motion/activities/pm_navigation_activity.rb', line 22

def open_fragment(frag, options={})
  mp "open fragment: #{frag.inspect}"
  mgr = fragmentManager.beginTransaction
  mgr.replace(@fragment_container.getId, frag, "screen-#{fragmentManager.getBackStackEntryCount + 1}")
  mgr.addToBackStack(nil)
  mgr.commit
  frag
end