Slide 1

Slide 1 text

WHAT’S HOT IN GDG Malta Danny Preussler @PreusslerBerlin

Slide 2

Slide 2 text

WHO’S THAT GERMAN?

Slide 3

Slide 3 text

WHAT’S A DEVELOPER EXPERT?

Slide 4

Slide 4 text

WHAT’S A DEVELOPER EXPERT?

Slide 5

Slide 5 text

2009 ANDROID

Slide 6

Slide 6 text

SOOO 2016 • Material Design • Firebase • ConstraintLayout • Databinding • RxJava

Slide 7

Slide 7 text

SOOO 2016 • Material Design • Firebase • ConstraintLayout • Databinding • RxJava

Slide 8

Slide 8 text

SOOO 2016 • Material Design • Firebase • ConstraintLayout • Databinding • RxJava

Slide 9

Slide 9 text

SOOO 2016 • Material Design • Firebase • ConstraintLayout • Databinding • RxJava

Slide 10

Slide 10 text

SOOO 2016 • Material Design • Firebase • ConstraintLayout • Databinding • RxJava

Slide 11

Slide 11 text

SOOO 2016 • Material Design • Firebase • ConstraintLayout • Databinding • RxJava

Slide 12

Slide 12 text

SOOO 2016 • Material Design • Firebase • ConstraintLayout • Databinding • RxJava ViewModel View

Slide 13

Slide 13 text

DATA BINDING

Slide 14

Slide 14 text

SOOO 2016 • Material Design • Firebase • ConstraintLayout • Databinding • RxJava

Slide 15

Slide 15 text

RXJAVA tasksRepository.getTasks() .flatMap(Flowable::fromIterable) .filter(task -> { switch (currentFiltering) { case ACTIVE_TASKS: return task.isActive(); case COMPLETED_TASKS: return task.isCompleted(); case ALL_TASKS: default return true; } }) * https://github.com/googlesamples/android-architecture

Slide 16

Slide 16 text

WHAT WAS NEW IN 2017

Slide 17

Slide 17 text

NEW FEATURE IN ANDROID 8 • Picture in Picture • Resizable TextView • Fonts in xml and Downloadable fonts • Notification changes • Background changes • Instant Apps

Slide 18

Slide 18 text

• Picture in Picture • Resizable TextView • Fonts in xml and Downloadable fonts • Notification changes • Background changes • Instant Apps

Slide 19

Slide 19 text

NEW FEATURE IN ANDROID 8 • Picture in Picture • Resizable TextView • Fonts in xml and Downloadable fonts • Notification changes • Background changes • Instant Apps

Slide 20

Slide 20 text

NEW FEATURE IN ANDROID 8 • Picture in Picture • Resizable TextView • Fonts in xml and Downloadable fonts • Notification changes • Background changes • Instant Apps

Slide 21

Slide 21 text

NEW FEATURE IN ANDROID 8 • Picture in Picture • Resizable TextView • Fonts in xml and Downloadable fonts • Notification changes • Background changes • Instant Apps

Slide 22

Slide 22 text

NEW FEATURE IN ANDROID 8 • Picture in Picture • Resizable TextView • Fonts in xml and Downloadable fonts • Notification changes • Background changes • Instant Apps

Slide 23

Slide 23 text

BACKGROUND CHANGES • Doze and JobScheduler started with M (Android 6) • New background limitations

Slide 24

Slide 24 text

NEW FEATURE IN ANDROID 8 • Picture in Picture • Resizable TextView • Fonts in xml and Downloadable fonts • Notification changes • Background changes •Instant apps

Slide 25

Slide 25 text

INSTANT APPS • “say no to app downloads” • (partial) app starts directly from website • Split up your app into feature modules

Slide 26

Slide 26 text

NEWS IN ARCHITECTURE • Architecture blueprints • Architecture guidelines • Architecture components

Slide 27

Slide 27 text

NEWS IN ARCHITECTURE •Architecture blueprints github.com/googlesamples/android-architecture • Architecture guidelines • Architecture components

Slide 28

Slide 28 text

NEWS IN ARCHITECTURE • Architecture blueprints •Architecture guidelines developer.android.com/topic/libraries/architecture/guide.html • Architecture components

Slide 29

Slide 29 text

NEWS IN ARCHITECTURE • Architecture blueprints •Architecture guidelines • Architecture components

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

NEWS IN ARCHITECTURE • Architecture blueprints • Architecture guidelines •Architecture components developer.android.com/topic/libraries/architecture/index.html

Slide 32

Slide 32 text

ARCHITECTURE COMPONENTS • Viewmodel • LiveData • LifeCycleObserver • Room • Pagination

Slide 33

Slide 33 text

VIEWMODEL • provides the data for a specific UI • fits great into MVVM • survives configuration change

Slide 34

Slide 34 text

VIEWMODEL • provides the data for a specific UI • fits great into MVVM • survives configuration change

Slide 35

Slide 35 text

VIEWMODEL • provides the data for a specific UI • fits great into MVVM • survives configuration change Model ViewModel View

Slide 36

Slide 36 text

VIEWMODEL • provides the data for a specific UI • fits great into MVVM • survives configuration change

Slide 37

Slide 37 text

VIEWMODEL public void onCreate(...) { model = ViewModelProviders .of(this) .get(MyViewModel.class); } class MyViewModel extends ViewModel { …

Slide 38

Slide 38 text

VIEWMODEL LIVES LONGER! Activity Activity ViewModel

Slide 39

Slide 39 text

INTRODUCING LIVE DATA Activity Activity LiveData LiveData ViewModel

Slide 40

Slide 40 text

LIVE DATA • Observable similar to RxJava • Life cycle aware • Doesn’t emit when not needed • Memory leak save

Slide 41

Slide 41 text

LIVE DATA • Observable similar to RxJava • Life cycle aware • Doesn’t emit when not needed • Memory leak save

Slide 42

Slide 42 text

LIVE DATA • Observable similar to RxJava • Life cycle aware • Doesn’t emit when not needed • Memory leak save

Slide 43

Slide 43 text

LIVE DATA • Observable similar to RxJava • Life cycle aware • Doesn’t emit when not needed • Memory leak save

Slide 44

Slide 44 text

LIVE DATA • Observable similar to RxJava • Life cycle aware • Doesn’t emit when not needed • Memory leak save

Slide 45

Slide 45 text

LIVE DATA class MyViewModel extends ViewModel { MutableLiveData message = new MutableLiveData(); myModel.message.observe(this, new Observer() { @Override public void onChanged(String newValue) {..} }

Slide 46

Slide 46 text

LIFECYCLEOBSERVER • Helps building your own life cycle aware components • Watch Activity, Fragment or Application life cycle • Avoid memory leaks • Avoid forwarding events from activities/fragments • Introduces ProcessLifeCycle!

Slide 47

Slide 47 text

ROOM • SQLite Object Mapper • Compile time check • Works with RxJava

Slide 48

Slide 48 text

ROOM @Dao abstract class ConferenceStore { @Insert abstract void insert(List sessions); @Query("SELECT * FROM tracks") abstract List allTracks(); ... https://commonsware.com/presos/2017-11-Room

Slide 49

Slide 49 text

ROOM @Entity(tableName = "tracks") class Track { @PrimaryKey(autoGenerate = true) final Long id; @NonNull final String title; @NonNull final String location; ... https://commonsware.com/presos/2017-11-Room

Slide 50

Slide 50 text

ROOM @Database(version=1, entities = {Track.class, Session.class}) abstract public class ConferenceDatabase extends RoomDatabase { https://commonsware.com/presos/2017-11-Room

Slide 51

Slide 51 text

A NEW PROGRAMMING LANGUAGE * Java still fully supported on Android

Slide 52

Slide 52 text

KOTLIN • Modern language • Reduce boilerplate • null safe • New possibilies • Communication with swift devs • Works great with Java • Multiplatform with web and backend

Slide 53

Slide 53 text

KOTLIN • Modern language • Works great with Java • Reduce boilerplate • null safe • New possibilies • Communication with swift devs • Multiplatform with web and backend

Slide 54

Slide 54 text

KOTLIN • Modern language • Works great with Java • Reduce boilerplate • null safe • New possibilies • Communication with swift devs • Multiplatform with web and backend

Slide 55

Slide 55 text

fun isEligibleToVote(): Boolean { return age >= 18 }

Slide 56

Slide 56 text

fun isEligibleToVote = age >= 18

Slide 57

Slide 57 text

data class MyModel(val lastName: String, val name: String = “”)

Slide 58

Slide 58 text

... Map signalStrength = new HashMap<>(); signalStrength.put(EDGE, 80); signalStrength.put(WIFI to 90); ...

Slide 59

Slide 59 text

... val signalStrength = hashMapOf(EDGE to 80, WIFI to 90) ...

Slide 60

Slide 60 text

class MyViewModel extends ViewModel { MutableLiveData message = new MutableLiveData(); myModel.message.observe(this, new Observer() { @Override public void onChanged(String newName) {..} }

Slide 61

Slide 61 text

class MyViewModel(): ViewModel(){ val message = MutableLiveData() myModel.message.observe(this, Observer{ .. })}

Slide 62

Slide 62 text

KOTLIN • Modern language • Works great with Java • Reduce boilerplate • null safe • New possibilies • Communication with swift devs • Multiplatform with web and backend

Slide 63

Slide 63 text

NULL SAFETY var canNeverBeNull: String var canBeNull: String?

Slide 64

Slide 64 text

if (subscription != null) { subscription.dispose() }

Slide 65

Slide 65 text

subscription?.dispose()

Slide 66

Slide 66 text

KOTLIN • Modern language • Works great with Java • Reduce boilerplate • null safe • New possibilities • Communication with swift devs • Multiplatform with web and backend

Slide 67

Slide 67 text

val typeOfPerson = when(age){ 0 -> "New born" in 1..12 -> "Child" in 13..19 -> "Teenager" else -> "Adult" }

Slide 68

Slide 68 text

fun String.toAspectRatio(): AspectRatio? = when (this) { "1:1" -> ONE_BY_ONE "2:3" -> TWO_BY_THREE else -> null }

Slide 69

Slide 69 text

fun Int.clamp(lower: Int, upper: Int) = Math.max(lower, Math.min(this, upper)) progress.clamp(0, 100)

Slide 70

Slide 70 text

greeting shouldEqual "hello"

Slide 71

Slide 71 text

greeting.shouldEqual("hello”)

Slide 72

Slide 72 text

greeting shouldEqual "hello"

Slide 73

Slide 73 text

greeting `should equal` "hello"

Slide 74

Slide 74 text

KOTLIN • Modern language • Works great with Java • Reduce boilerplate • null safe • New possibilities • Communication with swift devs • Multiplatform with web and backend

Slide 75

Slide 75 text

KOTLIN • Modern language • Works great with Java • Reduce boilerplate • null safe • New possibilities • Communication with swift devs • Multiplatform with web and backend support for JVM, JS, native

Slide 76

Slide 76 text

KOTLIN = fun

Slide 77

Slide 77 text

No content

Slide 78

Slide 78 text

SUMMARIZE It was never so easy to start with Android

Slide 79

Slide 79 text

WRITE ANDROID IN

Slide 80

Slide 80 text

ANDROID IS MORE THAN PHONE

Slide 81

Slide 81 text

No content

Slide 82

Slide 82 text

WHAT’S HOT IN GDG Malta Danny Preussler @PreusslerBerlin