class PMSingleFragmentActivity

Attributes

fragment[RW]
fragment_container[RW]
menu[RW]

Public Instance Methods

on_activity_result(request_code, result_code, data) click to toggle source
# File lib/project/pro_motion/activities/pm_single_fragment_activity.rb, line 57
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
on_create(saved_instance_state) click to toggle source
Calls superclass method PMActivity#on_create
# File lib/project/pro_motion/activities/pm_single_fragment_activity.rb, line 7
def on_create(saved_instance_state)
  super

  mp "PMSingleFragmentActivity on_create", debugging_only: true

  setup_fragment
end
on_create_menu(menu) click to toggle source
# File lib/project/pro_motion/activities/pm_single_fragment_activity.rb, line 48
def on_create_menu(menu)
  @menu = menu
  self.fragment.on_create_menu(menu) if self.fragment
end
on_options_item_selected(item) click to toggle source
# File lib/project/pro_motion/activities/pm_single_fragment_activity.rb, line 53
def on_options_item_selected(item)
  self.fragment.on_options_item_selected(item) if self.fragment
end
on_resume() click to toggle source
# File lib/project/pro_motion/activities/pm_single_fragment_activity.rb, line 15
def on_resume
  mp "PMSingleFragmentActivity on_resume", debugging_only: true

  setup_fragment unless @fragment_container
end
set_fragment(fragment) click to toggle source
# File lib/project/pro_motion/activities/pm_single_fragment_activity.rb, line 42
def set_fragment(fragment)
  mp "PMSingleFragmentActivity set_fragment", debugging_only: true
  @fragment = fragment # useful for the REPL
  fragmentManager.beginTransaction.add(@fragment_container.getId, fragment, fragment.class.to_s).commit
end
setup_fragment() click to toggle source
# File lib/project/pro_motion/activities/pm_single_fragment_activity.rb, line 21
def setup_fragment
  @fragment_container = Potion::FrameLayout.new(self)
  @fragment_container.setId Potion::ViewIdGenerator.generate
  self.contentView = @fragment_container

  if (fragment_class = intent.getStringExtra(EXTRA_FRAGMENT_CLASS))
    if fragment_instance = Kernel.const_get(fragment_class.to_s).new
      set_fragment fragment_instance

      # Grab the fragment arguments and call them on the class
      if fragment_arguments = intent.getBundleExtra(EXTRA_FRAGMENT_ARGUMENTS)
        fragment_arguments = PMHashBundle.from_bundle(fragment_arguments).to_h

        fragment_arguments.each do |key, value|
          fragment_instance.send "#{key}=", value
        end
      end
    end
  end
end