Slide 1

Slide 1 text

#andevcon fragments dive into

Slide 2

Slide 2 text

#andevcon DONN FELKER [email protected] @donnfelker google.com/+DonnFelker

Slide 3

Slide 3 text

#andevcon Groupon MyFitnessPal GetHuman Fitness+3 Travel WODs QONQR ... and over 50 more Android apps

Slide 4

Slide 4 text

#andevcon https://github.com/donnfelker/fragments-demo

Slide 5

Slide 5 text

#andevcon FRAGMENTS fragments image: wallbase.cc

Slide 6

Slide 6 text

#andevcon REUSABLE CHUNKS OF CODE image from android developer blog

Slide 7

Slide 7 text

#andevcon code.google.com/p/iosched/

Slide 8

Slide 8 text

#andevcon fragment usage

Slide 9

Slide 9 text

#andevcon List Fragment Vehicle Damage Waiver Fragment

Slide 10

Slide 10 text

#andevcon TABLET VERSION - Single Screen

Slide 11

Slide 11 text

#andevcon PHONE VERSION - Two Screens

Slide 12

Slide 12 text

#andevcon Types of Fragments Fragment - Anything goes (for the most part) ListFragment - Lists. Yup. Thats it. Lists.

Slide 13

Slide 13 text

#andevcon Fragment Lifecycle

Slide 14

Slide 14 text

#andevcon You decide which layout the Fragment should return. ListFragment automatically returns a new list view for you! ... but, if you’re using a ListFragment

Slide 15

Slide 15 text

#andevcon Fragments App Demo

Slide 16

Slide 16 text

#andevcon Multipane Layouts with multiple Fragments fragment fragment fragment fragment

Slide 17

Slide 17 text

#andevcon fragments can be instantiated via java or xml

Slide 18

Slide 18 text

#andevcon XML

Slide 19

Slide 19 text

#andevcon Code

Slide 20

Slide 20 text

#andevcon XML & CODE INSTANTIATION DEMO

Slide 21

Slide 21 text

#andevcon FRAGMENT COMMUNICATION

Slide 22

Slide 22 text

#andevcon List Fragment Vehicle Damage Waiver Fragment

Slide 23

Slide 23 text

#andevcon How To Get Each Fragment to Talk to Each Other

Slide 24

Slide 24 text

#andevcon Activity Fragment communication between

Slide 25

Slide 25 text

#andevcon Communication Patterns Direct Activity Access Inversion of Control (interface) Event Bus

Slide 26

Slide 26 text

#andevcon Inversion of Control via Interface /** * Contract between caller and receiver for red buttons */ public interface RedButtonListener { void onRedButtonClick(); } @Override public void onRedButtonClick() { Toast.makeText(this, R.string.red_button_clicked, Toast.LENGTH_SHORT).show(); } in Activity redButtonListener.onRedButtonClick(); in Fragment RedButtonListener.java

Slide 27

Slide 27 text

#andevcon Otto An enhanced Guava-based event bus with emphasis on Android support.

Slide 28

Slide 28 text

#andevcon goal - decouple and eliminate code Otto is Pub/Sub

Slide 29

Slide 29 text

#andevcon Otto as an event bus . The activity is no longer the orchestrator. Activity ListFragment Waiver VehicleSelected manually Previous - Use Interface Now - No Interface Activity ListFragment Waiver Fragment fragments know of activity activity is simply a container Otto Otto moves messages to and from subscribers (observer pattern / event bus)

Slide 30

Slide 30 text

#andevcon Fragment Communication Demo

Slide 31

Slide 31 text

#andevcon Action Tabs

Slide 32

Slide 32 text

#andevcon Action Tabs Demo

Slide 33

Slide 33 text

#andevcon Responsive Layout

Slide 34

Slide 34 text

#andevcon Detect Size on App Init How?

Slide 35

Slide 35 text

#andevcon NavigationFragment in DrawerLayout Content fragment in the content area

Slide 36

Slide 36 text

#andevcon Navigation Fragment is fixed on the left content fragment on the right Tablet

Slide 37

Slide 37 text

#andevcon Simple Responsive Layout Demo

Slide 38

Slide 38 text

#andevcon Advanced Fragment Usage

Slide 39

Slide 39 text

#andevcon Wizards Guiding users through complex flows easily. Example: Registration Wizard

Slide 40

Slide 40 text

#andevcon Wizard Demo Step 2

Slide 41

Slide 41 text

#andevcon Wizard Demo

Slide 42

Slide 42 text

#andevcon ViewPager ViewPageIndicator viewpageindicator.com

Slide 43

Slide 43 text

#andevcon Fragments Managing other Fragments

Slide 44

Slide 44 text

#andevcon Activity Fragment A Fragment B Fragments Inside of Fragments Fragment Y Fragment X

Slide 45

Slide 45 text

#andevcon

Slide 46

Slide 46 text

#andevcon View Pager & ChildFragmentManager Demo

Slide 47

Slide 47 text

#andevcon DONN FELKER [email protected] @donnfelker google.com/+DonnFelker THANK YOU. CODE: github.com/donnfelker/fragments-demo