class PMNavigationActivity
Attributes
fragment_container[RW]
root_fragment[RW]
Public Instance Methods
close_fragment()
click to toggle source
# File lib/project/pro_motion/activities/pm_navigation_activity.rb, line 31 def close_fragment getFragmentManager.popBackStackImmediate end
fragment()
click to toggle source
# 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)
click to toggle source
Calls superclass method
PMActivity#on_create
# 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_fragment_attached(frag)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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={})
click to toggle source
# 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
Private Instance Methods
activity_init()
click to toggle source
# File lib/project/pro_motion/activities/pm_navigation_activity.rb, line 52 def activity_init setup_root_fragment_container @root_fragment ||= intent_fragment_class && Kernel.const_get(intent_fragment_class.to_s).new return unless @root_fragment setup_root_fragment @root_fragment open_fragment @root_fragment @root_fragment = nil # Don't hang onto this reference. end
intent_fragment_arguments()
click to toggle source
# File lib/project/pro_motion/activities/pm_navigation_activity.rb, line 68 def intent_fragment_arguments intent.getBundleExtra(EXTRA_FRAGMENT_ARGUMENTS) end
intent_fragment_class()
click to toggle source
# File lib/project/pro_motion/activities/pm_navigation_activity.rb, line 72 def intent_fragment_class intent.getStringExtra(EXTRA_FRAGMENT_CLASS) end
on_activity_result(request_code, result_code, data)
click to toggle source
Pass Acitivity result on to the Fragment/Screen
# File lib/project/pro_motion/activities/pm_navigation_activity.rb, line 83 def on_activity_result(request_code, result_code, data) if fragment && fragment.respond_to?(:activity_result) fragment.activity_result(request_code, result_code, data) end end
setup_root_fragment(frag)
click to toggle source
# File lib/project/pro_motion/activities/pm_navigation_activity.rb, line 61 def setup_root_fragment(frag) return unless intent_fragment_arguments PMHashBundle.from_bundle(intent_fragment_arguments).to_h.each do |key, value| frag.send "#{key}=", value end end
setup_root_fragment_container()
click to toggle source
# File lib/project/pro_motion/activities/pm_navigation_activity.rb, line 76 def setup_root_fragment_container @fragment_container = Potion::FrameLayout.new(self) @fragment_container.setId Potion::ViewIdGenerator.generate self.contentView = @fragment_container end