Class: PMSingleFragmentActivity
- Inherits:
-
PMActivity
show all
- Defined in:
- lib/project/pro_motion/activities/pm_single_fragment_activity.rb
Overview
An abstract Activity designed to host a single fragment. RM-733 module ProMotion
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, #open, #set_content
Instance Attribute Details
Returns the value of attribute fragment.
5
6
7
|
# File 'lib/project/pro_motion/activities/pm_single_fragment_activity.rb', line 5
def fragment
@fragment
end
|
#fragment_container ⇒ Object
Returns the value of attribute fragment_container.
5
6
7
|
# File 'lib/project/pro_motion/activities/pm_single_fragment_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_single_fragment_activity.rb', line 5
def
@menu
end
|
Instance Method Details
#on_activity_result(request_code, result_code, data) ⇒ Object
57
58
59
60
61
|
# 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) ⇒ Object
7
8
9
10
11
12
13
|
# 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
|
48
49
50
51
|
# File 'lib/project/pro_motion/activities/pm_single_fragment_activity.rb', line 48
def ()
@menu =
self.fragment.() if self.fragment
end
|
#on_options_item_selected(item) ⇒ Object
53
54
55
|
# 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 ⇒ Object
15
16
17
18
19
|
# 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) ⇒ Object
42
43
44
45
46
|
# 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 fragmentManager.beginTransaction.add(@fragment_container.getId, fragment, fragment.class.to_s).commit
end
|
#setup_fragment ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# 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.(EXTRA_FRAGMENT_CLASS))
if fragment_instance = Kernel.const_get(fragment_class.to_s).new
set_fragment fragment_instance
if fragment_arguments = intent.(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
|