Slide 1

Slide 1 text

DEVELOPING FOR ANDROID TV Effie Barak (@CodingChick)

Slide 2

Slide 2 text

Outline 1. What is familiar in developing for the TV 2. What is different (Leanback)

Slide 3

Slide 3 text

So what is the same?

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

Basic structure

Slide 6

Slide 6 text

Code written for mobile

Slide 7

Slide 7 text

Support libraries required Either Glide or Picasso can work, there are implementation differences

Slide 8

Slide 8 text

Libraries libraries - All support libraries versions need to be the same. - SQLCipher needs to be 3.3.1-1or higher. Android means all of our favorite libraries just work!

Slide 9

Slide 9 text

Application Manifest Changes

Slide 10

Slide 10 text

UI differences and Leanback

Slide 11

Slide 11 text

Leanback main UI elements: Presenter - Leanback's version of a Recycler Adapter, has onBindViewHolder method and a ViewHolder. Not position-based. PresenterSelector - If there's more then one or more types of Presenters displayed in the same view ArrayObjectAdapter- A generic array that contains everything else.

Slide 12

Slide 12 text

Browse page

Slide 13

Slide 13 text

The UI elements in Browse ArrayObjectAdapter ListRowPresenter ImageCardView

Slide 14

Slide 14 text

MainActivity MainFragment CourseCardPresenter Presenter BrowseFragment Contains Extends Uses Classes Involved in Browse

Slide 15

Slide 15 text

UI structure with Udemy Courses

Slide 16

Slide 16 text

Hooking up Listeners

Slide 17

Slide 17 text

CourseCardPresenter extends Presenter (Is just your everyday adapter)

Slide 18

Slide 18 text

The ViewHolder contains ImageCardView

Slide 19

Slide 19 text

Course Details

Slide 20

Slide 20 text

The UI elements in Course Details DetailsOverviewRowPresenter ClassPresenterSelector ListRowPresenter ImageCardView

Slide 21

Slide 21 text

LectureCardPresenter DetailsActivity CourseDetailsFragment DetailsFragment CourseDetailsDescription Presenter AbstractDetailsDescription Presenter Presenter Contains Extends Uses Classes in Details View

Slide 22

Slide 22 text

DetailsOverviewRowPresenter is deprecated New class- FullWidthDetailsOverviewRowPresenter with different UI :(

Slide 23

Slide 23 text

Details row gets its own Presenter

Slide 24

Slide 24 text

Adding Actions to the CourseDetailsRow

Slide 25

Slide 25 text

LecturePresenter is similar to CoursePresenter

Slide 26

Slide 26 text

Hooking it all up to the ClassPresenterSelector

Slide 27

Slide 27 text

Playing a video

Slide 28

Slide 28 text

The UI elements in Playback VideoVideo

Slide 29

Slide 29 text

The UI elements in Playback ClassPresenterSelector PlaybackControlsRow ListRowPresenter

Slide 30

Slide 30 text

Interaction between the Fragment and the Activity Remote control actions PlaybackOverlayActivity PlaybackOverlayFragment Actions on controls Row VideoView Callbacks:

Slide 31

Slide 31 text

Setting up VideoView

Slide 32

Slide 32 text

The VideoView plays things

Slide 33

Slide 33 text

Implementation of MediaSession

Slide 34

Slide 34 text

And the callbacks class

Slide 35

Slide 35 text

playPause method

Slide 36

Slide 36 text

The Actions in the Fragment

Slide 37

Slide 37 text

Hooking up the actions listeners

Slide 38

Slide 38 text

The actions click listeners invoke the MediaController’s methods

Slide 39

Slide 39 text

The controls in the PlaybackControlsRow need to know.

Slide 40

Slide 40 text

Voice search

Slide 41

Slide 41 text

Voice search

Slide 42

Slide 42 text

Searching

Slide 43

Slide 43 text

Getting the search query

Slide 44

Slide 44 text

Loading the results

Slide 45

Slide 45 text

Useful resources: https://github.com/googlesamples/androidtv-Leanback Default auto-generated template https://developer.android.com/training/tv/index.html (Sorta, kinda, maybe)

Slide 46

Slide 46 text

Thank you!

Slide 47

Slide 47 text

UI Testing