Weitere Àhnliche Inhalte
Ăhnlich wie Mastering the Master Detail Pattern (20)
Mehr von CommonsWare (20)
KĂŒrzlich hochgeladen (20)
Mastering the Master Detail Pattern
- 2. Who Made You the Master?
â
Master/Detail Pattern
â
Master = a collection of content
â
â
â
â
Title/display name
Other metadata
Detail = specifics about one piece of content
Pattern
â
Show master or detail on smaller screens
â
Show master and detail on larger screens
Copyright © 2013 CommonsWare, LLC
- 3. Who Made You the Master?
Copyright © 2013 CommonsWare, LLC
Image courtesy of Google and AOSP
- 4. Stamping Out a Template
â
Master/Detail Flow App Template
â
Option in Eclipse when creating a new project
â
Results
â
Two activities (master/detail and detail-only)
â
Two fragments (master and detail)
â
Four layouts (plus a layout alias)
â
Always single-pane or dual-pane, based on screen
size
Copyright © 2013 CommonsWare, LLC
- 5. Nuking an Activity
â
One Activity/Two Fragments
â
In single-pane mode, Activity executes a
FragmentTransaction to replace list with detail
â
â
Adds to back stack to allow BACK to reverse the
transaction and return to master
In dual-pane mode, just shows both fragments
Copyright © 2013 CommonsWare, LLC
- 7. Nuking an Activity
â
Cons: Too Many Scenarios
â
Do we have a master fragment in the FragmentManager?
â
â
If yes, is it visible? Should it be?
Do we have a detail fragment in the FragmentManager?
â
If yes, is it visible? Should it be?
â
What happens when the user presses BACK?
â
What happens if we rotate the screen and change
strategies?
Copyright © 2013 CommonsWare, LLC
- 8. Slip Sliding Away
â
SlidingPaneLayout
â
Android Support package
â
Handles complexity for you
â
â
â
Single-pane vs. dual-pane
Swipe gesture to show, hide master in single-pane
mode
All the configuration change idiosyncrasies
Copyright © 2013 CommonsWare, LLC
- 9. Slip Sliding Away
â
SlidingPaneLayout Pros
â
â
Simplicity
SlidingPaneLayout Cons
â
Confusion over swipe gesture
â
Detail-first single-pane flow
â
Can be fixed, requires a bit of extra code
Copyright © 2013 CommonsWare, LLC
- 10. Yet More Horizontal Swiping
â
ViewPager
â
ViewGroup, attached to a PagerAdapter
â
FragmentPagerAdapter,
FragmentStatePagerAdapter, or custom
implementation
â
Horizontal swipes move between pages
â
Optional âindicatorsâ to show where the user is
in the sea of pages
Copyright © 2013 CommonsWare, LLC
- 11. Yet More Horizontal Swiping
â
ViewPager and Design
â
âOn a phone, since the master and detail are on
separate screens, this typically requires the user
to jump back and forth between the list and the
detail view, aka "pogo-sticking".â
â
âIn cases where users will want to view multiple
detail items in succession, avoid pogo-sticking
by using the swipe gesture to navigate to the
next/previous detail view.â
Copyright © 2013 CommonsWare, LLC
- 13. Yet More Horizontal Swiping
â
ViewPager in Master/Detail
â
Single-Pane: Consider ViewPager for Detail
â
â
BACK to return to master
â
â
Swipe between peer details
Ideal: context provided by content, so no tabs, etc.
Dual-Pane: Probably Not Necessary
â
Can randomly access any detail via master pane, so
swiping not necessary
Copyright © 2013 CommonsWare, LLC
- 14. Yet More Horizontal Swiping
â
ViewPager Challenges
â
Switching Between Single-Pane/Dual-Pane
â
â
â
Fragment*PagerAdapter is very âgrabbyâ, does not
like others messing with its contents
Net: need another PagerAdapter implementation
Yet More Collisions with Horizontal Swipe
Gestures
â
Probably need to skip SlidingPaneLayout
Copyright © 2013 CommonsWare, LLC
- 15. Lights Mode! Camera Mode! Action Mode!
â
Action Modes
â
A.k.a., contextual action bar
â
Replaces regular action bar for contextual
actions
â
â
â
When 1+ selected for such actions
Can perform actions upon group of selected items,
such as âdeleteâ or âmoveâ
Dismissed via Done or BACK
Copyright © 2013 CommonsWare, LLC
- 16. Lights Mode! Camera Mode! Action Mode!
â
Action Modes and Design
â
Replacement for old-style context menu
â
Trigger Options
â
â
Always-available checklist
Long-press to select first, moves into a multi-select
mode
Copyright © 2013 CommonsWare, LLC
- 17. Lights Mode! Camera Mode! Action Mode!
â
Action Modes and Master/Detail
â
Master should support action modes
â
â
Read-only vs. read-write actions
â
â
Exception: no relevant actions (unlikely)
Emphasis on multiple-selection scenario
Detail should support actions
â
Single-pane: action bar
â
Dual-pane: action bar and action mode
Copyright © 2013 CommonsWare, LLC
- 18. Lights Mode! Camera Mode! Action Mode!
â
Action Mode Challenges
â
Multiple Flavors of Master List Highlighting
â
â
â
Single-pane: regular or multiple-selection
Dual-pane: activated or multiple-selection
Detail in Multiple-Selection?
â
â
First detail? Last detail? Empty? Special content?
Retaining Action Mode and Selections
â
Configuration changes, etc.
Copyright © 2013 CommonsWare, LLC
- 19. But Wait! There's More!
â
Presentation
â
â
What do we do when there is a secondary
screen?
Splitter
â
Should we allow resizing of panes in dual-pane
mode?
Copyright © 2013 CommonsWare, LLC
- 20. But Wait! There's More!
â
Action Bar Items
â
Need to ensure change properly
â
â
â
Moving between master, detail in single-pane mode
Reasonable blend of both in dual-pane mode
Navigation Drawer
â
Yet more conflict with horizontal gestures
â
Fallacy of the âbezel swipeâ
Copyright © 2013 CommonsWare, LLC
- 24. CWAC-MasterDetail
â
Library Functionality, Today
â
Automatic handling of configuration changes
â
ViewPager in single-pane mode
â
Splitter support
â
Custom empty views (list, detail) and
multiple-choice view (detail)
â
Optional action mode support
â
Optional custom master contents
Copyright © 2013 CommonsWare, LLC