Class: PMSingleFragmentActivity

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

Overview

An abstract Activity designed to host a single fragment. RM-733 module ProMotion

Direct Known Subclasses

PMHomeActivity

Constant Summary collapse

EXTRA_FRAGMENT_CLASS =
"fragment_class"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from PMActivity

#clear_references, #onCreate, #onDestroy, #onPause, #onResume

Instance Attribute Details

#fragmentObject

Returns the value of attribute fragment.



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

def fragment
  @fragment
end

#fragment_containerObject

Returns the value of attribute fragment_container.



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

def fragment_container
  @fragment_container
end

Instance Method Details

#on_create(saved_instance_state) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/project/pro_motion/pm_single_fragment_activity.rb', line 9

def on_create(saved_instance_state)
  super

  mp "PMSingleFragmentActivity on_create", debugging_only: true

  @fragment_container = Potion::FrameLayout.new(self)
  @fragment_container.setId Potion::ViewIdGenerator.generate
  self.contentView = @fragment_container

  if (fragment_class = intent.getStringExtra(EXTRA_FRAGMENT_CLASS))
    # TODO weird way to create this intance, look at this later
    set_fragment Kernel.const_get(fragment_class.to_s).new
  end
end

#set_fragment(fragment) ⇒ Object



24
25
26
27
28
# File 'lib/project/pro_motion/pm_single_fragment_activity.rb', line 24

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