Rinsing the Brush: Picasso 3.0

A presentation at Chicago Roboto in April 2018 in Chicago, IL, USA by Jake Wharton

Slide 1

Slide 1

Rinsing the Brush: Picasso 3.0 John Rodriguez Jake Wharton

Slide 2

Slide 2

Slide 3

Slide 3

Slide 4

Slide 4

Slide 5

Slide 5

Slide 6

Slide 6

Slide 7

Slide 7

3 years later

Slide 8

Slide 8

3.x Goals

Slide 9

Slide 9

• Android P 3.x Goals

Slide 10

Slide 10

• Android P • OkHttp 2.x => 3.x 3.x Goals

Slide 11

Slide 11

• Android P • OkHttp 2.x => 3.x 
 • Okio integration 3.x Goals

Slide 12

Slide 12

• Android P • OkHttp 2.x => 3.x 
 • Okio integration 
 • Improvements 3.x Goals

Slide 13

Slide 13

• Android P • OkHttp 2.x => 3.x 
 • Okio integration 
 • Improvements 3.x Goals

Slide 14

Slide 14

Slide 15

Slide 15

Slide 16

Slide 16

Bitmap decodeStreamPreP (Request r , BufferedSource bs) {

BitmapFactory.Options options = createBitmapOptions (request) ;

if ( requiresInSampleSize (options)) { InputStream stream = new SourceBufferingInputStream(bs) ;

BitmapFactory. decodeStream (stream , null, options) ;

calculateInSampleSize (r. targetWidth , r. targetHeight , options , r);

}

return BitmapFactory. decodeStream (bs.inputStream() , null, options) ;

}

Slide 17

Slide 17

Bitmap decodeStreamPreP (Request r , BufferedSource bs) {

BitmapFactory.Options options = createBitmapOptions (request) ;

if ( requiresInSampleSize (options)) { InputStream stream = new SourceBufferingInputStream(bs) ;

BitmapFactory. decodeStream (stream , null, options) ;

calculateInSampleSize (r. targetWidth , r. targetHeight , options , r);

}

return BitmapFactory. decodeStream (bs.inputStream() , null, options) ;

}

Slide 18

Slide 18

Slide 19

Slide 19

Bitmap decodeStreamP (Request r , BufferedSource bs) { ImageDecoder.Source imageSource =
ImageDecoder. createSource (ByteBuffer. wrap (bs.readByteArray())) ;

return ImageDecoder. decodeBitmap ( imageSource ,
new OnHeaderDecodedListener() {

void onHeaderDecoded (ImageDecoder d , ImageInfo info , Source src) {

if ( r .hasSize()) {

d.setTargetSize( r . targetWidth , r . targetHeight ) ;

} } }) ; }

Slide 20

Slide 20

Bitmap decodeStreamP (Request r , BufferedSource bs) { ImageDecoder.Source imageSource =
ImageDecoder. createSource (ByteBuffer. wrap (bs.readByteArray())) ;

return ImageDecoder. decodeBitmap ( imageSource ,
new OnHeaderDecodedListener() {

void onHeaderDecoded (ImageDecoder d , ImageInfo info , Source src) {

if ( r .hasSize()) {

d.setTargetSize( r . targetWidth , r . targetHeight ) ;

} } }) ; }

Slide 21

Slide 21

Bitmap decodeStreamP (Request r , BufferedSource bs) { ImageDecoder.Source imageSource =
ImageDecoder. createSource (ByteBuffer. wrap (bs.readByteArray())) ;

return ImageDecoder. decodeBitmap ( imageSource ,
new OnHeaderDecodedListener() {

void onHeaderDecoded (ImageDecoder d , ImageInfo info , Source src) {

if ( r .hasSize()) {

d.setTargetSize( r . targetWidth , r . targetHeight ) ;

} } }) ; }

Slide 22

Slide 22

• Android P • OkHttp 2.x => 3.x 
 • Okio integration 
 • Improvements 3.x Goals

Slide 23

Slide 23

Picasso

Slide 24

Slide 24

Picasso ResourceRequestHandler AssetsRequestHandler NetworkRequestHandler FileRequestHandler ...

Slide 25

Slide 25

Downloader Picasso NetworkRequestHandler ResourceRequestHandler AssetsRequestHandler FileRequestHandler ...

Slide 26

Slide 26

OkHttp 2.x HttpURLConnection Downloader Picasso NetworkRequestHandler ResourceRequestHandler AssetsRequestHandler FileRequestHandler ...

Slide 27

Slide 27

OkHttp 2.x HttpURLConnection OkHttp 3.x Downloader Picasso NetworkRequestHandler ResourceRequestHandler AssetsRequestHandler FileRequestHandler ...

Slide 28

Slide 28

OkHttp 3.x Downloader Picasso NetworkRequestHandler HttpURLConnection OkHttp 2.x ResourceRequestHandler AssetsRequestHandler FileRequestHandler ...

Slide 29

Slide 29

OkHttp 3.x Picasso NetworkRequestHandler ResourceRequestHandler AssetsRequestHandler FileRequestHandler ...

Slide 30

Slide 30

Picasso NetworkRequestHandler Call.Factory (OkHttp 3.x) ResourceRequestHandler AssetsRequestHandler FileRequestHandler ...

Slide 31

Slide 31

Picasso OkHttp

Slide 32

Slide 32

Okio Picasso OkHttp

Slide 33

Slide 33

Picasso OkHttp Retrofit Okio

Slide 34

Slide 34

Picasso OkHttp Okio Retrofit Moshi

Slide 35

Slide 35

Picasso OkHttp Okio Retrofit Moshi

Slide 36

Slide 36

Picasso OkHttp Okio Retrofit Moshi Wire

Slide 37

Slide 37

Okio

Picasso OkHttp Retrofit Moshi Wire

Slide 38

Slide 38

• Android P • OkHttp 2.x => 3.x 
 • Okio integration 
 • Improvements 3.x Goals

Slide 39

Slide 39

java.io.IOException: Cannot reset at com.squareup.picasso.MarkableInputStream.reset( MarkableInputStream.java : 99 ) at com.squareup.picasso.BitmapHunter.decodeStream( BitmapHunter.java : 140 ) at com.squareup.picasso.BitmapHunter.hunt( BitmapHunter.java : 217 ) at com.squareup.picasso.BitmapHunter.run( BitmapHunter.java : 159 ) at java.util.concurrent.Executors$RunnableAdapter.call( Executors.java : 457 ) at java.util.concurrent.FutureTask.run( FutureTask.java : 266 ) at java.util.concurrent.ThreadPoolExecutor.runWorker( ThreadPoolExecutor.java : 1162 ) at java.util.concurrent.ThreadPoolExecutor$Worker.run( ThreadPoolExecutor.java : 636 ) at java.lang.Thread.run( Thread.java : 764 ) at com.squareup.picasso.Utils$PicassoThread.run( Utils.java : 411 )

Slide 40

Slide 40

nightmare_shrek.png

Slide 41

Slide 41

MAGIC nightmare_shrek.png

Slide 42

Slide 42

METADATA METADATA METADATA MAGIC nightmare_shrek.png

Slide 43

Slide 43

PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA METADATA METADATA METADATA MAGIC nightmare_shrek.png

Slide 44

Slide 44

PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA METADATA METADATA METADATA MAGIC

Slide 45

Slide 45

PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA METADATA METADATA METADATA MAGIC

Slide 46

Slide 46

PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA METADATA METADATA METADATA MAGIC

Slide 47

Slide 47

PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA METADATA METADATA METADATA MAGIC

Slide 48

Slide 48

PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA METADATA METADATA METADATA MAGIC

Slide 49

Slide 49

PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA METADATA METADATA METADATA MAGIC

Slide 50

Slide 50

InputStream PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA METADATA METADATA METADATA MAGIC

Slide 51

Slide 51

InputStream BitmapFactory

inJustDecodeBounds=true MAGIC METADATA

Slide 52

Slide 52

InputStream BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA

Slide 53

Slide 53

InputStream BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA JPEG?

Slide 54

Slide 54

InputStream BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA JPEG?

Slide 55

Slide 55

InputStream BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA JPEG?

Slide 56

Slide 56

InputStream BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA

Slide 57

Slide 57

InputStream BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA

Slide 58

Slide 58

InputStream BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA

Slide 59

Slide 59

InputStream BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA

Slide 60

Slide 60

InputStream BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA METADATA PIXEL DATA PIXEL DATA

Slide 61

Slide 61

InputStream BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA METADATA PIXEL DATA PIXEL DATA JPEG?

Slide 62

Slide 62

InputStream BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA METADATA PIXEL DATA JPEG? PIXEL DATA

Slide 63

Slide 63

InputStream BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA METADATA PIXEL DATA JPEG? PIXEL DATA

Slide 64

Slide 64

InputStream BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA METADATA PIXEL DATA PIXEL DATA

Slide 65

Slide 65

InputStream BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA METADATA PIXEL DATA PNG? PIXEL DATA

Slide 66

Slide 66

InputStream BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA METADATA PIXEL DATA PNG? PIXEL DATA

Slide 67

Slide 67

InputStream BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA METADATA PIXEL DATA PNG! PIXEL DATA

Slide 68

Slide 68

InputStream BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA METADATA PIXEL DATA PNG PIXEL DATA

Slide 69

Slide 69

InputStream BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA METADATA PIXEL DATA PNG size? PIXEL DATA

Slide 70

Slide 70

InputStream BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA METADATA PIXEL DATA PNG size? PIXEL DATA

Slide 71

Slide 71

InputStream BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA METADATA PIXEL DATA PNG 1920x1080! PIXEL DATA

Slide 72

Slide 72

InputStream BitmapFactory inJustDecodeBounds=true MAGIC METADATA 2 METADATA 2 1 METADATA 1 PIXEL DATA PNG 1920x1080 PIXEL DATA

Slide 73

Slide 73

InputStream 1920x1080 PIXEL DATA BitmapFactory inJustDecodeBounds=true MAGIC METADATA 2 METADATA 2 1 METADATA 1 PIXEL DATA

Slide 74

Slide 74

InputStream BitmapFactory 1920x1080 PIXEL DATA BitmapFactory inJustDecodeBounds=true MAGIC METADATA 2 METADATA 2 1 METADATA 1 PIXEL DATA

Slide 75

Slide 75

InputStream BitmapFactory PIXEL DATA 1920x1080 BitmapFactory inJustDecodeBounds=true MAGIC METADATA 2 METADATA 2 1 METADATA 1 PIXEL DATA

Slide 76

Slide 76

PIXEL DATA PIXEL DATA InputStream BitmapFactory inJustDecodeBounds=true BitmapFactory MAGIC METADATA 2 METADATA 2 1 METADATA 1 1920x1080

Slide 77

Slide 77

PIXEL DATA MAGIC METADATA 2 METADATA 2 1 METADATA 1 PIXEL DATA InputStream BitmapFactory inJustDecodeBounds=true BitmapFactory 1920x1080

Slide 78

Slide 78

InputStream BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA

Slide 79

Slide 79

PIXEL DATA BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA METADATA PIXEL DATA MarkableInputStream InputStream

Slide 80

Slide 80

InputStream PIXEL DATA BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA METADATA PIXEL DATA MarkableInputStream MAGIC METADATA METADATA METADATA PIXEL DATA

Slide 81

Slide 81

InputStream PIXEL DATA BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA METADATA PIXEL DATA MarkableInputStream MAGIC METADATA METADATA METADATA PIXEL DATA 1920x1080

Slide 82

Slide 82

InputStream PIXEL DATA MAGIC METADATA METADATA METADATA PIXEL DATA MarkableInputStream 1920x1080 BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA METADATA PIXEL DATA

Slide 83

Slide 83

InputStream PIXEL DATA MAGIC METADATA METADATA METADATA PIXEL DATA MarkableInputStream 1920x1080 BitmapFactory MAGIC METADATA METADATA METADATA PIXEL DATA BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA METADATA PIXEL DATA

Slide 84

Slide 84

InputStream PIXEL DATA MAGIC METADATA METADATA METADATA PIXEL DATA MarkableInputStream 1920x1080 MAGIC METADATA METADATA METADATA PIXEL DATA BitmapFactory BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA METADATA PIXEL DATA

Slide 85

Slide 85

InputStream PIXEL DATA MarkableInputStream 1920x1080 BitmapFactory METADATA METADATA PIXEL DATA BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA METADATA PIXEL DATA

Slide 86

Slide 86

InputStream PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA MarkableInputStream 1920x1080 BitmapFactory METADATA METADATA PIXEL DATA BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA METADATA PIXEL DATA

Slide 87

Slide 87

InputStream PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA MarkableInputStream 1920x1080 BitmapFactory METADATA METADATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA METADATA PIXEL DATA

Slide 88

Slide 88

InputStream PIXEL DATA MAGIC METADATA METADATA METADATA PIXEL DATA MarkableInputStream MAGIC METADATA METADATA METADATA PIXEL DATA

Slide 89

Slide 89

InputStream PIXEL DATA BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA METADATA PIXEL DATA MarkableInputStream MAGIC METADATA METADATA METADATA PIXEL DATA

Slide 90

Slide 90

InputStream PIXEL DATA BitmapFactory inJustDecodeBounds=true MAGIC METADATA METADATA METADATA PIXEL DATA MarkableInputStream MAGIC METADATA METADATA METADATA PIXEL DATA

Slide 91

Slide 91

InputStream PIXEL DATA MarkableInputStream BitmapFactory inJustDecodeBounds=true METADATA METADATA PIXEL DATA

Slide 92

Slide 92

InputStream PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA MarkableInputStream BitmapFactory inJustDecodeBounds=true METADATA METADATA PIXEL DATA

Slide 93

Slide 93

InputStream PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA MarkableInputStream BitmapFactory inJustDecodeBounds=true METADATA METADATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA

Slide 94

Slide 94

InputStream PIXEL DATA MarkableInputStream BitmapFactory inJustDecodeBounds=true PIXEL DATA PIXEL DATA PIXEL DATA

Slide 95

Slide 95

InputStream MarkableInputStream BitmapFactory inJustDecodeBounds=true PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA

Slide 96

Slide 96

InputStream MarkableInputStream BitmapFactory inJustDecodeBounds=true PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA

Slide 97

Slide 97

InputStream MarkableInputStream BitmapFactory inJustDecodeBounds=true PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA

Slide 98

Slide 98

InputStream MarkableInputStream BitmapFactory inJustDecodeBounds=true PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA

Slide 99

Slide 99

InputStream MarkableInputStream BitmapFactory inJustDecodeBounds=true PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA

Slide 100

Slide 100

InputStream MarkableInputStream BitmapFactory inJustDecodeBounds=true PIXEL DATA PIXEL DATA PIXEL DATA PIXEL DATA

Slide 101

Slide 101

InputStream MarkableInputStream BitmapFactory inJustDecodeBounds=true PIXEL DATA PIXEL DATA ??? PIXEL DATA PIXEL DATA

Slide 102

Slide 102

InputStream MarkableInputStream ??? PIXEL DATA PIXEL DATA BitmapFactory inJustDecodeBounds=true

Slide 103

Slide 103

InputStream MarkableInputStream ??? BitmapFactory PIXEL DATA PIXEL DATA BitmapFactory inJustDecodeBounds=true

Slide 104

Slide 104

InputStream MarkableInputStream ??? BitmapFactory java.io.IOException: Cannot reset at com.squareup.picasso.MarkableInputStream.reset( MarkableInputStream.java : 99 ) at com.squareup.picasso.BitmapHunter.decodeStream( BitmapHunter.java : 140 ) at com.squareup.picasso.BitmapHunter.hunt( BitmapHunter.java : 217 ) at com.squareup.picasso.BitmapHunter.run( BitmapHunter.java : 159 ) at java.util.concurrent.Executors$RunnableAdapter.call( Executors.java : 457 ) at java.util.concurrent.FutureTask.run( FutureTask.java : 266 ) at java.util.concurrent.ThreadPoolExecutor.runWorker( ThreadPoolExecutor.java : 1162 ) at java.util.concurrent.ThreadPoolExecutor$Worker.run( ThreadPoolExecutor.java : 636 ) at java.lang.Thread.run( Thread.java : 764 ) at com.squareup.picasso.Utils$PicassoThread.run( Utils.java : 411 ) BitmapFactory inJustDecodeBounds=true

Slide 105

Slide 105

BitmapFactory MarkableInputStream InputStream BitmapFactory

Slide 106

Slide 106

BitmapFactory MarkableInputStream InputStream Picasso 2.x BitmapFactory Picasso 3.x

Slide 107

Slide 107

BitmapFactory MarkableInputStream InputStream Picasso 2.x BitmapFactory BufferedSource Picasso 3.x

Slide 108

Slide 108

BitmapFactory MarkableInputStream InputStream Picasso 2.x BitmapFactory BufferedSource Picasso 3.x SourceBufferingInputStream

Slide 109

Slide 109

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream

Slide 110

Slide 110

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream offset: 0

Slide 111

Slide 111

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 0

Slide 112

Slide 112

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 0 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC 1024

Slide 113

Slide 113

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 1024 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC 0

Slide 114

Slide 114

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 1024 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC

Slide 115

Slide 115

BufferedSource 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC BitmapFactory inJustDecodeBounds=true SourceBufferingInputStream

offset: 1024 1PIXEL DATA 1 3METADATA 3 2METADATA 2 1METADATA 1 MAGIC

Slide 116

Slide 116

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 1024 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC

Slide 117

Slide 117

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 1024

Slide 118

Slide 118

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 1024

Slide 119

Slide 119

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 1024 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 2048

Slide 120

Slide 120

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 2048 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 1024

Slide 121

Slide 121

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 2048 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4

Slide 122

Slide 122

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 2048

Slide 123

Slide 123

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 5 PIXEL DATA 5 6 PIXEL DATA 6 7 PIXEL DATA 7 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 2048

Slide 124

Slide 124

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 5 PIXEL DATA 5 6 PIXEL DATA 6 7 PIXEL DATA 7 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 2048 5 PIXEL DATA 5 6 PIXEL DATA 6 7 PIXEL DATA 7 3072

Slide 125

Slide 125

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 5 PIXEL DATA 5 6 PIXEL DATA 6 7 PIXEL DATA 7 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 3072 5 PIXEL DATA 5 6 PIXEL DATA 6 7 PIXEL DATA 7 2048

Slide 126

Slide 126

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 5 PIXEL DATA 5 6 PIXEL DATA 6 7 PIXEL DATA 7 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 3072 5 PIXEL DATA 5 6 PIXEL DATA 6 7 PIXEL DATA 7

Slide 127

Slide 127

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 5 PIXEL DATA 5 6 PIXEL DATA 6 7 PIXEL DATA 7 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 3072

Slide 128

Slide 128

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 5 PIXEL DATA 5 6 PIXEL DATA 6 7 PIXEL DATA 7 8 PIXEL DATA 8 9 PIXEL DATA 9 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 3072

Slide 129

Slide 129

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 5 PIXEL DATA 5 6 PIXEL DATA 6 7 PIXEL DATA 7 8 PIXEL DATA 8 9 PIXEL DATA 9 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: x 3072 8 PIXEL DATA 8 9 PIXEL DATA 9 3754

Slide 130

Slide 130

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 5 PIXEL DATA 5 6 PIXEL DATA 6 7 PIXEL DATA 7 8 PIXEL DATA 8 9 PIXEL DATA 9 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 3754 8 PIXEL DATA 8 9 PIXEL DATA 9 x3072

Slide 131

Slide 131

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 5 PIXEL DATA 5 6 PIXEL DATA 6 7 PIXEL DATA 7 8 PIXEL DATA 8 9 PIXEL DATA 9 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 3754 8 PIXEL DATA 8 9 PIXEL DATA 9

Slide 132

Slide 132

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 5 PIXEL DATA 5 6 PIXEL DATA 6 7 PIXEL DATA 7 8 PIXEL DATA 8 9 PIXEL DATA 9 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 3754

Slide 133

Slide 133

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 5 PIXEL DATA 5 6 PIXEL DATA 6 7 PIXEL DATA 7 8 PIXEL DATA 8 9 PIXEL DATA 9 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 3754 ???

Slide 134

Slide 134

BufferedSource 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 5 PIXEL DATA 5 6 PIXEL DATA 6 7 PIXEL DATA 7 8 PIXEL DATA 8 9 PIXEL DATA 9 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 3754 ???

BitmapFactory inJustDecodeBounds=true SourceBufferingInputStream

Slide 135

Slide 135

BitmapFactory InputStream BufferedSource 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 5 PIXEL DATA 5 6 PIXEL DATA 6 7 PIXEL DATA 7 8 PIXEL DATA 8 9 PIXEL DATA 9 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC

BitmapFactory inJustDecodeBounds=true SourceBufferingInputStream

Slide 136

Slide 136

BitmapFactory InputStream BufferedSource 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 5 PIXEL DATA 5 6 PIXEL DATA 6 7 PIXEL DATA 7 8 PIXEL DATA 8 9 PIXEL DATA 9 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC

BitmapFactory inJustDecodeBounds=true SourceBufferingInputStream

Slide 137

Slide 137

BitmapFactory InputStream BufferedSource 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 5 PIXEL DATA 5 6 PIXEL DATA 6 7 PIXEL DATA 7 8 PIXEL DATA 8 9 PIXEL DATA 9 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC

BitmapFactory inJustDecodeBounds=true SourceBufferingInputStream

Slide 138

Slide 138

BitmapFactory InputStream BufferedSource 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 5 PIXEL DATA 5 6 PIXEL DATA 6 7 PIXEL DATA 7 8 PIXEL DATA 8 9 PIXEL DATA 9

BitmapFactory inJustDecodeBounds=true SourceBufferingInputStream

Slide 139

Slide 139

BitmapFactory InputStream BufferedSource 5 PIXEL DATA 5 6 PIXEL DATA 6 7 PIXEL DATA 7 8 PIXEL DATA 8 9 PIXEL DATA 9

BitmapFactory inJustDecodeBounds=true SourceBufferingInputStream

Slide 140

Slide 140

BitmapFactory InputStream BufferedSource 8 PIXEL DATA 8 9 PIXEL DATA 9

BitmapFactory inJustDecodeBounds=true SourceBufferingInputStream

Slide 141

Slide 141

BitmapFactory InputStream BufferedSource

BitmapFactory inJustDecodeBounds=true SourceBufferingInputStream

Slide 142

Slide 142

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream offset: 0

Slide 143

Slide 143

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 1 METADATA 1 MAGIC offset: 0

Slide 144

Slide 144

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 1 METADATA 1 MAGIC offset: 341 1 METADATA 1 MAGIC

Slide 145

Slide 145

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 1 METADATA 1 MAGIC offset: 341 1 METADATA 1 MAGIC

Slide 146

Slide 146

BitmapFactory inJustDecodeBounds=true BufferedSource SourceBufferingInputStream 1 METADATA 1 MAGIC offset: 341 1 METADATA 1 MAGIC 1920x1080

Slide 147

Slide 147

BufferedSource 1 METADATA 1 MAGIC offset: 341 1920x1080 1METADATA 1 MAGIC

BitmapFactory inJustDecodeBounds=true SourceBufferingInputStream

Slide 148

Slide 148

ExifInterface BufferedSource SourceBufferingInputStream 1 METADATA 1 MAGIC offset: 341 1920x1080 offset: 0 1METADATA 1 MAGIC

BitmapFactory inJustDecodeBounds=true SourceBufferingInputStream

Slide 149

Slide 149

ExifInterface BufferedSource SourceBufferingInputStream 1 METADATA 1 MAGIC offset: 341 1920x1080 offset: 341 1 METADATA 1 MAGIC 1METADATA 1 MAGIC

BitmapFactory inJustDecodeBounds=true SourceBufferingInputStream

Slide 150

Slide 150

ExifInterface BufferedSource SourceBufferingInputStream 1 METADATA 1 MAGIC offset: 341 1920x1080 offset: 341 1 METADATA 1 MAGIC 1METADATA 1 MAGIC

BitmapFactory inJustDecodeBounds=true SourceBufferingInputStream

Slide 151

Slide 151

ExifInterface BufferedSource SourceBufferingInputStream 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 341 1920x1080 offset: 341 1METADATA 1 MAGIC

BitmapFactory inJustDecodeBounds=true SourceBufferingInputStream

Slide 152

Slide 152

ExifInterface BufferedSource SourceBufferingInputStream 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 341 1920x1080 offset: 1024 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 341 1METADATA 1 MAGIC

BitmapFactory inJustDecodeBounds=true SourceBufferingInputStream

Slide 153

Slide 153

ExifInterface BufferedSource SourceBufferingInputStream 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 341 1920x1080 offset: 1024 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 341 1METADATA 1 MAGIC

BitmapFactory inJustDecodeBounds=true SourceBufferingInputStream

Slide 154

Slide 154

ExifInterface BufferedSource SourceBufferingInputStream 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 341 1920x1080 offset: 1024 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 341 90 ° 1METADATA 1 MAGIC

BitmapFactory inJustDecodeBounds=true SourceBufferingInputStream

Slide 155

Slide 155

BufferedSource 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 341 1920x1080 341 90 °

1METADATA 1 MAGIC

BitmapFactory inJustDecodeBounds=true SourceBufferingInputStream offset: 1024 1PIXEL DATA 1 3METADATA 3 2METADATA 2 ExifInterface SourceBufferingInputStream

Slide 156

Slide 156

BitmapFactory InputStream BufferedSource 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 341 1920x1080 341 90 °

1METADATA 1 MAGIC

BitmapFactory inJustDecodeBounds=true SourceBufferingInputStream offset: 1024 1PIXEL DATA 1 3METADATA 3 2METADATA 2 ExifInterface SourceBufferingInputStream

Slide 157

Slide 157

BitmapFactory InputStream BufferedSource 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 341 1920x1080 341 90 °

1METADATA 1 MAGIC

BitmapFactory inJustDecodeBounds=true SourceBufferingInputStream offset: 1024 1PIXEL DATA 1 3METADATA 3 2METADATA 2 ExifInterface SourceBufferingInputStream

Slide 158

Slide 158

BitmapFactory InputStream BufferedSource 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 5 PIXEL DATA 5 6 PIXEL DATA 6 7 PIXEL DATA 7 1 PIXEL DATA 1 3 METADATA 3 2 METADATA 2 1 METADATA 1 MAGIC offset: 341 1920x1080 341 90 °

1METADATA 1 MAGIC

BitmapFactory inJustDecodeBounds=true SourceBufferingInputStream offset: 1024 1PIXEL DATA 1 3METADATA 3 2METADATA 2 ExifInterface SourceBufferingInputStream

Slide 159

Slide 159

BitmapFactory InputStream BufferedSource 2 PIXEL DATA 2 3 PIXEL DATA 3 4 PIXEL DATA 4 5 PIXEL DATA 5 6 PIXEL DATA 6 7 PIXEL DATA 7 8 PIXEL DATA 8 9 PIXEL DATA 9 offset: 341 1920x1080 341 90 °

1METADATA 1 MAGIC

BitmapFactory inJustDecodeBounds=true SourceBufferingInputStream offset: 1024 1PIXEL DATA 1 3METADATA 3 2METADATA 2 ExifInterface SourceBufferingInputStream

Slide 160

Slide 160

BitmapFactory InputStream BufferedSource 5 PIXEL DATA 5 6 PIXEL DATA 6 7 PIXEL DATA 7 8 PIXEL DATA 8 9 PIXEL DATA 9 offset: 341 1920x1080 341 90 °

1METADATA 1 MAGIC

BitmapFactory inJustDecodeBounds=true SourceBufferingInputStream offset: 1024 1PIXEL DATA 1 3METADATA 3 2METADATA 2 ExifInterface SourceBufferingInputStream

Slide 161

Slide 161

BitmapFactory InputStream BufferedSource 8 PIXEL DATA 8 9 PIXEL DATA 9 offset: 341 1920x1080 341 90 °

1METADATA 1 MAGIC

BitmapFactory inJustDecodeBounds=true SourceBufferingInputStream offset: 1024 1PIXEL DATA 1 3METADATA 3 2METADATA 2 ExifInterface SourceBufferingInputStream

Slide 162

Slide 162

BitmapFactory InputStream BufferedSource offset: 341 1920x1080 341 90 °

1METADATA 1 MAGIC

BitmapFactory inJustDecodeBounds=true SourceBufferingInputStream offset: 1024 1PIXEL DATA 1 3METADATA 3 2METADATA 2 ExifInterface SourceBufferingInputStream

Slide 163

Slide 163

BufferedSource offset: 341 SourceBufferingInputStream 341 SourceBufferingInputStream BitmapFactory InputStream

1METADATA 1 MAGIC

BitmapFactory inJustDecodeBounds=true 1920x1080 offset: 1024 1PIXEL DATA 1 3METADATA 3 2METADATA 2 90 ° ExifInterface

Slide 164

Slide 164

• Android P • OkHttp 2.x => 3.x 
 • Okio integration 
 • Improvements 3.x Goals

Slide 165

Slide 165

Picasso picasso .load(url)

.placeholder(R.drawable. placeholder )

.error(R.drawable. error )

.fit()

.into(view) ;

Slide 166

Slide 166

Picasso

Slide 167

Slide 167

Picasso fun loadImage ( remoteUri: Uri , @ColorInt tintColor: Int? = null ) {

val creator = picasso .load(remoteUri) .placeholder( avatarPlaceholder ) .fit()

if (transformTintColor != null ) { creator.transform(TintTransformation( tintColor )) } creator.into( this ) }

Slide 168

Slide 168

Picasso fun loadImage ( awsAssetUri: Uri ,

height: Int ,

width: Int

) {

val creator = picasso .load(awsAssetUri) .placeholder( avatarPlaceholder ) .fit() .into( this ) }

Slide 169

Slide 169

Picasso fun loadImage ( awsAssetUri: Uri ,

height: Int ,

width: Int

) {

val creator = picasso .load(awsAssetUri) .placeholder( avatarPlaceholder ) .fit() .into( this ) }

Slide 170

Slide 170

Slide 171

Slide 171

Picasso picasso .load( “http://shrek.jpg” )

.placeholder(R.drawable. placeholder )

.error(R.drawable. error )

.fit()

.into(view) ;

Slide 172

Slide 172

Picasso “http://shrek.jpg” Request

Slide 173

Slide 173

Picasso Request Transformer “http://shrek.jpg” Request Request

Slide 174

Slide 174

Picasso “http://shrek.jpg” Request Transformer “http://bar.com/20x20/shrek.jpg” Request Request

Slide 175

Slide 175

http://shrek.jpg

Slide 176

Slide 176

01010110101001101 http://shrek.jpg

Slide 177

Slide 177

01010110101001101 http://shrek.jpg

Slide 178

Slide 178

01010110101001101

Slide 179

Slide 179

01010110101001101

Slide 180

Slide 180

01010110101001101

Slide 181

Slide 181

01 01 0110 10100 1 1 0 1

Slide 182

Slide 182

01 01 0110 10100 1 1 0 1

Slide 183

Slide 183

Slide 184

Slide 184

Slide 185

Slide 185

http://bar.com/20x20/shrek.jpg

Slide 186

Slide 186

http://bar.com/20x20/shrek.jpg

Slide 187

Slide 187

http://bar.com/20x20/shrek.jpg

Slide 188

Slide 188

0101011

Slide 189

Slide 189

0101011

Slide 190

Slide 190

0101011

Slide 191

Slide 191

0101011

Slide 192

Slide 192

0101011

Slide 193

Slide 193

01 010 1 1

Slide 194

Slide 194

01 010 1 1

Slide 195

Slide 195

01 010 1 1

Slide 196

Slide 196

Slide 197

Slide 197

Slide 198

Slide 198

Slide 199

Slide 199

?

Slide 200

Slide 200

Slide 201

Slide 201

Picasso “http://shrek.jpg” Request Transformer “http://bar.com/20x20/shrek.jpg” Request Request ’

Slide 202

Slide 202

Picasso Request Transformer

Slide 203

Slide 203

ResourceRequestHandler NetworkRequestHandler FileRequestHandler Picasso Request Transformer AssetsRequestHandler

Slide 204

Slide 204

Picasso Request Transformer Handler Request

Slide 205

Slide 205

Picasso Request Transformer Request Handler Bitmap

Slide 206

Slide 206

Bitmap Drawable Result Picasso Request Transformer Request Handler

Slide 207

Slide 207

Picasso Request Transformer Result Request Handler

Slide 208

Slide 208

Picasso Request Transformer Result Request Handler Greyscale Circle Tint

Slide 209

Slide 209

Picasso Request Transformer Result Request Handler Transformation Greyscale Circle Tint

Slide 210

Slide 210

Picasso Request Transformer Result Request Handler Transformation

Slide 211

Slide 211

Picasso Request Transformer Result Target Request Handler Transformation

Slide 212

Slide 212

Request Transformer Result Request Handler Transformation

Slide 213

Slide 213

Transformer Result Transformer Transformer

Slide 214

Slide 214

Transformer Transformer Transformer

Slide 215

Slide 215

Transformer Transformer Transformer

Slide 216

Slide 216

Transformer Transformer Transformer

Slide 217

Slide 217

Transformer Transformer Transformer

Slide 218

Slide 218

Transformer Transformer Transformer

Slide 219

Slide 219

Slide 220

Slide 220

square/okhttp

Slide 221

Slide 221

custom interceptors Retry Bridge Cache Connect Call Server square/okhttp

Slide 222

Slide 222

custom interceptors Retry Bridge Cache Connect Call Server square/okhttp

Slide 223

Slide 223

custom interceptors Retry Bridge Cache Connect Call Server square/okhttp

Slide 224

Slide 224

Slide 225

Slide 225

Slide 226

Slide 226

@Override protected void onCreate (Bundle savedInstanceState) {

super .onCreate(savedInstanceState) ;

setContentView(R.layout. activity_main ) ;

Picasso. with ( this )
.load( "http://example.com/logo.png" ) .into( imageView ) ; }

Slide 227

Slide 227

@Override protected void onCreate (Bundle savedInstanceState) {

super .onCreate(savedInstanceState) ;

setContentView(R.layout. activity_main ) ;

Picasso. with ( this )
.load( "http://example.com/logo.png" ) .into( imageView ) ; }

Slide 228

Slide 228

public static Picasso with (Context context) {

if ( singleton

null ) {

synchronized (Picasso. class ) {

if ( singleton

null ) {

singleton

new Builder(context).build() ;

} } }

return singleton ; }

Slide 229

Slide 229

public static Picasso with (Context context) {

if ( singleton

null ) {

synchronized (Picasso. class ) {

if ( singleton

null ) {

singleton

new Builder(context).build() ;

} } }

return singleton ; }

Slide 230

Slide 230

public static void setSingletonInstance (Picasso picasso) {

synchronized (Picasso. class ) {

if ( singleton != null ) {

throw new IllegalStateException(

"Singleton instance already exists." ) ;

}

singleton = picasso ;

} }

Slide 231

Slide 231

public static void setSingletonInstance (Picasso picasso) {

synchronized (Picasso. class ) {

if ( singleton != null ) {

throw new IllegalStateException(

"Singleton instance already exists." ) ;

}

singleton = picasso ;

} }

Slide 232

Slide 232

@Module ( includes = ThumborModule. class ) final class ProductionPicassoModule {

@Provides @Singleton static Picasso providePicasso (

@App Context context ,

OkHttpClient client ,

Thumbor thumbor) {

Picasso.RequestTransformer transformer = 
    

new PollexorRequestTransformer(thumbor) ; return new Picasso.Builder(context)

.client(client) .requestTransformer(transformer) .listener((picasso , uri , e) -> Timber. d (e , uri.toString())) ;

} }

Slide 233

Slide 233

@Module ( includes = ThumborModule. class ) final class ProductionPicassoModule {

@Provides @Singleton static Picasso providePicasso (

@App Context context ,

OkHttpClient client ,

Thumbor thumbor) {

Picasso.RequestTransformer transformer = 
    

new PollexorRequestTransformer(thumbor) ; return new Picasso.Builder(context)

.client(client) .requestTransformer(transformer) .listener((picasso , uri , e) -> Timber. d (e , uri.toString())) ;

} }

Slide 234

Slide 234

Slide 235

Slide 235

Slide 236

Slide 236

public final class PicassoProvider {

private static volatile Picasso instance ; public static Picasso get () {

if ( instance

null ) {

synchronized (PicassoProvider. class ) {

if ( instance

null ) {

if (PicassoContentProvider. context

null ) {

throw new IllegalStateException( "context == null" ) ;

}

instance

new

Picasso.Builder(PicassoContentProvider. context ).build() ;

} } }

return instance ;

} }

Slide 237

Slide 237

public final class PicassoProvider {

private static volatile Picasso instance ; public static Picasso get () {

if ( instance

null ) {

synchronized (PicassoProvider. class ) {

if ( instance

null ) {

if (PicassoContentProvider. context

null ) {

throw new IllegalStateException( "context == null" ) ;

}

instance

new

Picasso.Builder(PicassoContentProvider. context ).build() ;

} } }

return instance ;

} }

Slide 238

Slide 238

public final class PicassoProvider {

private static volatile Picasso instance ; public static Picasso get () {

if ( instance

null ) {

synchronized (PicassoProvider. class ) {

if ( instance

null ) {

if (PicassoContentProvider. context

null ) {

throw new IllegalStateException( "context == null" ) ;

}

instance

new

Picasso.Builder(PicassoContentProvider. context ).build() ;

} } }

return instance ;

} }

Slide 239

Slide 239

public final class PicassoContentProvider extends ContentProvider {

static Context context ;

@Override public boolean onCreate () {

context = getContext() ; return true;

}

}

Slide 240

Slide 240

Slide 241

Slide 241

• Android P • OkHttp 2.x => 3.x 
 • Okio integration 
 • Improvements 3.x Goals

Slide 242

Slide 242

Picasso. with (context) X

.load(url)

.placeholder(R.drawable. placeholder )

.error(R.drawable. error )

.fit()

.into(view) ;

Slide 243

Slide 243

PicassoProvider. get () X

.load(url)

.placeholder(R.drawable. placeholder )

.error(R.drawable. error )

.fit()

.into(view) ;

with context

Slide 244

Slide 244

picasso .load(url)

.placeholder(R.drawable. placeholder )

.error(R.drawable. error )

.fit()

.into(view) ;

Slide 245

Slide 245

abstract class RequestHandler {

abstract boolean canHandleRequest (Request request) ;

abstract Result

load (Request request , int networkPolicy) ; } X

Slide 246

Slide 246

abstract class RequestHandler {

abstract boolean canHandleRequest (Request request) ;

abstract void load (Picasso

picasso ,

Request

request ,

Callback

callback) ; } X

Result int networkPolicy

Slide 247

Slide 247

Coming Soon

Slide 248

Slide 248

• Better separation of concerns: Source/Target/Load Coming Soon

Slide 249

Slide 249

• Better separation of concerns: Source/Target/Load • Propagating Drawables to Target (animated GIFs!) Coming Soon

Slide 250

Slide 250

• Better separation of concerns: Source/Target/Load • Propagating Drawables to Target (animated GIFs!) • More? Let us know! Coming Soon

Slide 251

Slide 251

PICASSO WILL RETURN 3.0

Slide 252

Slide 252

Rinsing the Brush: Picasso 3.0 @jrodbx @JakeWharton