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
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
}
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