Slide 1

Slide 1 text

A Few “OK” Libraries Jake Wharton

Slide 2

Slide 2 text

okio

Slide 3

Slide 3 text

okio

Slide 4

Slide 4 text

okio

Slide 5

Slide 5 text

okio okhttp moshi retrofit

Slide 6

Slide 6 text

okio?

Slide 7

Slide 7 text

HTTP

Slide 8

Slide 8 text

HTTP GET  /a-­‐few-­‐ok-­‐libraries.html  HTTP/1.1   Host:  droidcon.ca

Slide 9

Slide 9 text

HTTP GET  /a-­‐few-­‐ok-­‐libraries.html  HTTP/1.1   Host:  droidcon.ca HTTP/1.1  200  OK   Date:  Thu,  9  Apr  2015  15:14:34  GMT   Server:  JakeWharton/2.3.7  (Human)   Content-­‐Type:  application/presentation;  charset=UTF-­‐8   Content-­‐Length:  3000   ! ...

Slide 10

Slide 10 text

HTTP HTTP/1.1  200  OK   Date:  Thu,  9  Apr  2015  15:14:34  GMT   Server:  JakeWharton/2.3.7  (Human)   Content-­‐Type:  application/presentation;  charset=UTF-­‐8   Content-­‐Length:  3000   ! ...

Slide 11

Slide 11 text

HTTP HTTP/1.1  200  OK   Date:  Thu,  9  Apr  2015  15:14:34  GMT   Server:  JakeWharton/2.3.7  (Human)   Content-­‐Type:  application/presentation;  charset=UTF-­‐8   Content-­‐Length:  3000   ! ...                ·∙      ·∙    \r\n            ·∙        ·∙  ·∙      ·∙        ·∙                ·∙      \r\n                ·∙                                  ·∙              \r\n                            ·∙                                                  ·∙                          \r\n                                ·∙        \r\n   \r\n

Slide 12

Slide 12 text

HTTP HTTP/1.1·∙200·∙OK\r\n   Date:·∙Thu,·∙9·∙Apr·∙2015·∙15:14:34·∙GMT\r\n   Server:·∙JakeWharton/2.3.7·∙(Human)\r\n   Content-­‐Type:·∙application/presentation;·∙charset=UTF-­‐8\r\n   Content-­‐Length:·∙3000\r\n   \r\n   ...

Slide 13

Slide 13 text

HTTP HTTP/1.1·∙200·∙OK\r\nDate:·∙T   hu,·∙9·∙Apr·∙2015·∙15:14:34·∙GMT\r\nServer:·∙JakeWharto   n/2.3.7·∙(Huma   n)\r\nContent-­‐Type:·∙application/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n...

Slide 14

Slide 14 text

HTTP HTTP/1.1·∙200·∙OK\r\nDate:·∙T   hu,·∙9·∙Apr·∙2015·∙15:14:34·∙GMT\r\nServer:·∙JakeWharto   n/2.3.7·∙(Huma   n)\r\nContent-­‐Type:·∙application/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n...

Slide 15

Slide 15 text

HTTP HTTP/1.1·∙200·∙OK\r\nDate:·∙T   hu,·∙9·∙Apr·∙2015·∙15:14:34·∙GMT\r\nServer:·∙JakeWharto   n/2.3.7·∙(Huma   n)\r\nContent-­‐Type:·∙application/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n...

Slide 16

Slide 16 text

HTTP                                      Date:·∙T   hu,·∙9·∙Apr·∙2015·∙15:14:34·∙GMT\r\nServer:·∙JakeWharto   n/2.3.7·∙(Huma   n)\r\nContent-­‐Type:·∙application/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n... HTTP/1.1      200      OK

Slide 17

Slide 17 text

HTTP                                      Date:·∙T   hu,·∙9·∙Apr·∙2015·∙15:14:34·∙GMT\r\nServer:·∙JakeWharto   n/2.3.7·∙(Huma   n)\r\nContent-­‐Type:·∙application/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n... HTTP/1.1      200      OK

Slide 18

Slide 18 text

HTTP                                      Date:·∙T   hu,·∙9·∙Apr·∙2015·∙15:14:34·∙GMT\r\nServer:·∙JakeWharto   n/2.3.7·∙(Huma   n)\r\nContent-­‐Type:·∙application/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n... HTTP/1.1      200      OK

Slide 19

Slide 19 text

HTTP !                                                              Server:·∙JakeWharto   n/2.3.7·∙(Huma   n)\r\nContent-­‐Type:·∙application/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n... HTTP/1.1      200      OK Date      Thu,  9  Apr  2015  15:14:34  GMT

Slide 20

Slide 20 text

java.io.*

Slide 21

Slide 21 text

java.io.* abstract class InputStream {
 }X

Slide 22

Slide 22 text

java.io.* abstract class InputStream {
 void close();
 }X

Slide 23

Slide 23 text

java.io.* abstract class InputStream {
 void close();
 long skip(long byteCount);
 }X

Slide 24

Slide 24 text

java.io.* abstract class InputStream {
 void close();
 long skip(long byteCount);
 }X

Slide 25

Slide 25 text

java.io.* abstract class InputStream {
 void close();
 long skip(long byteCount);
 }X 
 while (byteCount > 0) {
 byteCount -= is.skip(byteCount);
 }X


Slide 26

Slide 26 text

java.io.* abstract class InputStream {
 void close();
 long skip(long byteCount);
 }X public static void reallySkip(InputStream is, long byteCount) {
 while (byteCount > 0) {
 byteCount -= is.skip(byteCount);
 }X
 }

Slide 27

Slide 27 text

java.io.* abstract class InputStream {
 void close();
 int read(byte[] buffer);
 int read(byte[] buffer, int offset, int count);
 long skip(long byteCount);
 }X

Slide 28

Slide 28 text

java.io.* abstract class InputStream {
 void close(); int read();
 int read(byte[] buffer);
 int read(byte[] buffer, int offset, int count);
 long skip(long byteCount);
 }X

Slide 29

Slide 29 text

java.io.* abstract class InputStream {
 int available();
 void close();
 void mark(int readLimit);
 boolean markSupported(); int read();
 int read(byte[] buffer);
 int read(byte[] buffer, int offset, int count);
 synchronized void reset();
 long skip(long byteCount);
 }X

Slide 30

Slide 30 text

java.io.* • API is conflated with multiple concepts and inconsistent behavior

Slide 31

Slide 31 text

HTTP !                                                              Server:·∙JakeWharto   n/2.3.7·∙(Huma   n)\r\nContent-­‐Type:·∙application/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n... HTTP/1.1      200      OK Date      Thu,  9  Apr  2015  15:14:34  GMT

Slide 32

Slide 32 text

HTTP !                                                              Server:·∙JakeWharto   n/2.3.7·∙(Huma   n)\r\nContent-­‐Type:·∙application/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n... HTTP/1.1·∙200·∙OKrnDate:·∙Thu,·∙9·∙Apr·∙2015·∙15:14:34·∙GMTrn

Slide 33

Slide 33 text

HTTP !                                                              Server:·∙JakeWharto   n/2.3.7·∙(Huma   n)\r\nContent-­‐Type:·∙application/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n... HTTP/1.1·∙200·∙OKrnDate:·∙Thu,·∙9·∙Apr·∙2015·∙15:14:34·∙GMTrn

Slide 34

Slide 34 text

HTTP !                                                              Server:·∙JakeWharto   n/2.3.7·∙(Huma   n)\r\nContent-­‐Type:·∙application/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n...

Slide 35

Slide 35 text

HTTP ! ! n/2.3.7·∙(Huma   n)\r\nContent-­‐Type:·∙application/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n... Server:·∙JakeWharto

Slide 36

Slide 36 text

HTTP ! ! ! n)\r\nContent-­‐Type:·∙application/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n... Server:·∙JakeWharton/2.3.7·∙(Huma

Slide 37

Slide 37 text

HTTP ! ! !                                              lication/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n... Server:·∙JakeWharton/2.3.7·∙(Human)rnContent-­‐Type:·∙app

Slide 38

Slide 38 text

HTTP ! ! !                                              lication/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n... Server:·∙JakeWharton/2.3.7·∙(Human)rnContent-­‐Type:·∙app

Slide 39

Slide 39 text

HTTP ! ! !                                              lication/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n...                                                                      Content-­‐Type:·∙app Server      JakeWharton/2.3.7  (Human)

Slide 40

Slide 40 text

HTTP ! ! !                                              lication/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n...                                                                      Content-­‐Type:·∙app

Slide 41

Slide 41 text

HTTP ! ! !                                              lication/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n...                                                                      Content-­‐Type:·∙app                                                                      Content-­‐Type:·∙app

Slide 42

Slide 42 text

HTTP ! ! !                                              lication/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n...                                                                      Content-­‐Type:·∙app Content-­‐Type:·∙app

Slide 43

Slide 43 text

HTTP ! ! !                                              lication/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n... Content-­‐Type:·∙app

Slide 44

Slide 44 text

HTTP ! ! !                                              lication/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n... Content-­‐Type:·∙app

Slide 45

Slide 45 text

HTTP ! ! !                                              lication/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n...

Slide 46

Slide 46 text

HTTP ! ! !                                              lication/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n...                                                                      Content-­‐Type:·∙app

Slide 47

Slide 47 text

HTTP ! ! !                                              lication/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n...                                                                      Content-­‐Type:·∙app

Slide 48

Slide 48 text

HTTP ! ! !                                              lication/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n...                                                                      Content-­‐Type:·∙app

Slide 49

Slide 49 text

HTTP ! ! ! ! =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n... lication/presentation;·∙charset          Content-­‐Type:·∙app

Slide 50

Slide 50 text

HTTP ! ! ! !          8\r\nContent-­‐Length:·∙3000\r   \n\r\n... lication/presentation;·∙charset=UTF-­‐Content-­‐Type:·∙app

Slide 51

Slide 51 text

java.io.* • API is conflated with multiple concepts and inconsistent behavior

Slide 52

Slide 52 text

java.io.* • API is conflated with multiple concepts and inconsistent behavior ! • Burden of figuring out storage is on the consumer

Slide 53

Slide 53 text

java.io.* class BufferedInputStream extends InputStream {
 BufferedInputStream(InputStream is) {
 // ...
 }
 
 BufferedInputStream(InputStream is, int size) {
 // ...
 }
 }

Slide 54

Slide 54 text

java.io.* ! ! ! n)\r\nContent-­‐Type:·∙application/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n... Server:·∙JakeWharton/2.3.7·∙(Huma

Slide 55

Slide 55 text

java.io.* ! ! ! n)\r\nContent-­‐Type:·∙application/presentation;·∙charset   =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n... Server:·∙JakeWharton/2.3.7·∙(Huma Server:·∙JakeWharton/2.3.7·∙(Huma

Slide 56

Slide 56 text

java.io.* ! ! ! ! =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n... Server:·∙JakeWharton/2.3.7·∙(Human)rnContent-­‐Type:·∙application/presentation;·∙charset Server:·∙JakeWharton/2.3.7·∙(Huma

Slide 57

Slide 57 text

java.io.* ! ! ! ! =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n... Server:·∙JakeWharton/2.3.7·∙(Human)rnContent-­‐Type:·∙application/presentation;·∙charset Server:·∙JakeWharton/2.3.7·∙(Huma                                                              n)rnContent-­‐Type:·∙app

Slide 58

Slide 58 text

java.io.* ! ! ! ! =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n... Server:·∙JakeWharton/2.3.7·∙(Human)rnContent-­‐Type:·∙application/presentation;·∙charset Server:·∙JakeWharton/2.3.7·∙(Human)rnContent-­‐Type:·∙app

Slide 59

Slide 59 text

java.io.* ! ! ! ! =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n... Server:·∙JakeWharton/2.3.7·∙(Human)rnContent-­‐Type:·∙application/presentation;·∙charset Server:·∙JakeWharton/2.3.7·∙(Human)rnContent-­‐Type:·∙app

Slide 60

Slide 60 text

java.io.* ! ! ! ! =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n... Server:·∙JakeWharton/2.3.7·∙(Human)rnContent-­‐Type:·∙application/presentation;·∙charset                                                                      Content-­‐Type:·∙app

Slide 61

Slide 61 text

java.io.* ! ! ! ! =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n... Server:·∙JakeWharton/2.3.7·∙(Human)rnContent-­‐Type:·∙application/presentation;·∙charset                                                                      Content-­‐Type:·∙app                                                                                                        lication/presentation;·∙charset

Slide 62

Slide 62 text

java.io.* ! ! ! ! =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n... Server:·∙JakeWharton/2.3.7·∙(Human)rnContent-­‐Type:·∙application/presentation;·∙charset lication/presentation;·∙charset          Content-­‐Type:·∙app

Slide 63

Slide 63 text

java.io.* ! ! ! ! =UTF-­‐8\r\nContent-­‐Length:·∙3000\r   \n\r\n... Server:·∙JakeWharton/2.3.7·∙(Human)rnContent-­‐Type:·∙application/presentation;·∙charset lication/presentation;·∙charset          Content-­‐Type:·∙app

Slide 64

Slide 64 text

java.io.* • API is conflated with multiple concepts and inconsistent behavior • Burden of figuring out storage is on the consumer

Slide 65

Slide 65 text

java.io.* • API is conflated with multiple concepts and inconsistent behavior • Burden of figuring out storage is on the consumer ! ! • Decorators add performance, functionality

Slide 66

Slide 66 text

java.io.* class DataInputStream extends InputStream {
 DataInputStream(InputStream in) {}
 
 void readFully(byte[] b) {}
 void readFully(byte b[], int off, int len) {}
 boolean readBoolean() {}
 byte readByte() {}
 int readUnsignedByte() {}
 short readShort() {}
 int readUnsignedShort() {}
 char readChar() {}
 int readInt() {}
 long readLong() {}
 float readFloat() {}
 double readDouble() {}
 String readLine() {}
 String readUTF() {}
 }

Slide 67

Slide 67 text

java.io.* class DataInputStream extends InputStream {
 DataInputStream(InputStream in) {}
 
 void readFully(byte[] b) {}
 void readFully(byte b[], int off, int len) {}
 boolean readBoolean() {}
 byte readByte() {}
 int readUnsignedByte() {}
 short readShort() {}
 int readUnsignedShort() {}
 char readChar() {}
 int readInt() {}
 long readLong() {}
 float readFloat() {}
 double readDouble() {}
 String readLine() {}
 String readUTF() {}
 } class InputStreamReader extends Reader {
 InputStreamReader(InputStream is) {}
 InputStreamReader(InputStream is, String charsetName) {}
 InputStreamReader(InputStream is, CharsetDecoder dec) {}
 InputStreamReader(InputStream is, Charset charset) {}
 
 int read() {}
 int read(char[] buffer) {}
 int read(char[] buffer, int offset, int count) {}
 int read(CharBuffer buffer) {}
 }

Slide 68

Slide 68 text

java.io.* • API is conflated with multiple concepts and inconsistent behavior • Burden of figuring out storage is on the consumer • Decorators add performance, functionality

Slide 69

Slide 69 text

java.io.* • API is conflated with multiple concepts and inconsistent behavior • Burden of figuring out storage is on the consumer • Decorators add performance, functionality ! ! ! • High-level abstractions exist, but do not compose

Slide 70

Slide 70 text

Okio

Slide 71

Slide 71 text

Okio • Complements java.io.* and java.nio.*

Slide 72

Slide 72 text

Okio • Complements java.io.* and java.nio.* • Source and Sink move data

Slide 73

Slide 73 text

Okio interface Source { }X

Slide 74

Slide 74 text

Okio interface Source {
 void close(); }X

Slide 75

Slide 75 text

Okio interface Source {
 Timeout timeout();
 void close(); }X

Slide 76

Slide 76 text

Okio interface Source {
 long read(Buffer sink, long byteCount);
 Timeout timeout();
 void close(); }X

Slide 77

Slide 77 text

Okio interface Source {
 long read(Buffer sink, long byteCount);
 Timeout timeout();
 void close(); }X

Slide 78

Slide 78 text

Okio interface Sink { }X

Slide 79

Slide 79 text

Okio interface Sink {
 void write(Buffer sink, long byteCount);
 Timeout timeout();
 void close(); }X

Slide 80

Slide 80 text

Okio interface Sink {
 void write(Buffer sink, long byteCount);
 Timeout timeout();
 void close(); void flush(); }X

Slide 81

Slide 81 text

Okio interface Sink {
 void write(Buffer sink, long byteCount);
 Timeout timeout();
 void close(); void flush(); }X

Slide 82

Slide 82 text

Okio • Complements java.io.* and java.nio.*   • Source and Sink move data

Slide 83

Slide 83 text

Okio • Complements java.io.* and java.nio.*   • Source and Sink move data • Complements java.io.* and java.nio  * • Source and Sink move data • Buffer and ByteString hold data

Slide 84

Slide 84 text

Okio Buffer buffer = new Buffer();

Slide 85

Slide 85 text

Okio Buffer buffer = new Buffer(); Buffer

Slide 86

Slide 86 text

Okio Buffer buffer = new Buffer(); Segment Pool byte[] ! pos=0 limit=0 byte[] ! pos=0 limit=0 byte[] ! pos=0 limit=0 byte[] ! pos=0 limit=0 Buffer

Slide 87

Slide 87 text

Okio Buffer buffer = new Buffer(); buffer.writeUtf8("Hello, Droidcon"); Segment Pool byte[] ! pos=0 limit=0 byte[] ! pos=0 limit=0 byte[] ! pos=0 limit=0 byte[] ! pos=0 limit=0 Buffer

Slide 88

Slide 88 text

Buffer Okio Buffer buffer = new Buffer(); buffer.writeUtf8("Hello, Droidcon"); byte[] ! pos=0 limit=0 Segment Pool byte[] ! pos=0 limit=0 byte[] ! pos=0 limit=0 byte[] ! pos=0 limit=0

Slide 89

Slide 89 text

Buffer Okio Buffer buffer = new Buffer(); buffer.writeUtf8("Hello, Droidcon"); byte[] ! pos=0 limit=15 Segment Pool byte[] ! pos=0 limit=0 byte[] ! pos=0 limit=0 byte[] ! pos=0 limit=0

Slide 90

Slide 90 text

Buffer Okio Buffer buffer = new Buffer(); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon"); byte[] ! pos=0 limit=15 Segment Pool byte[] ! pos=0 limit=0 byte[] ! pos=0 limit=0 byte[] ! pos=0 limit=0

Slide 91

Slide 91 text

Buffer Okio Buffer buffer = new Buffer(); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon"); byte[] ! pos=0 limit=30 Segment Pool byte[] ! pos=0 limit=0 byte[] ! pos=0 limit=0 byte[] ! pos=0 limit=0

Slide 92

Slide 92 text

Buffer Okio Buffer buffer = new Buffer(); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon"); byte[] ! pos=0 limit=30 Segment Pool byte[] ! pos=0 limit=0 byte[] ! pos=0 limit=0 byte[] ! pos=0 limit=0

Slide 93

Slide 93 text

Buffer Okio Buffer buffer = new Buffer(); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon"); byte[] ! pos=0 limit=30 byte[] ! pos=0 limit=0 Segment Pool byte[] ! pos=0 limit=0 byte[] ! pos=0 limit=0

Slide 94

Slide 94 text

Buffer Okio Buffer buffer = new Buffer(); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon"); byte[] ! pos=0 limit=30 Segment Pool byte[] ! pos=0 limit=15 byte[] ! pos=0 limit=0 byte[] ! pos=0 limit=0

Slide 95

Slide 95 text

Buffer Okio Buffer buffer = new Buffer(); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon"); byte[] ! pos=0 limit=30 Segment Pool byte[] ! pos=0 limit=15 byte[] ! pos=0 limit=0 byte[] ! pos=0 limit=0

Slide 96

Slide 96 text

Buffer Okio Buffer buffer = new Buffer(); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon"); byte[] ! pos=0 limit=30 byte[] ! pos=0 limit=15 Segment Pool

Slide 97

Slide 97 text

Okio Buffer buffer = new Buffer(); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon”); ! buffer.readUtf8(5); Buffer byte[] ! pos=0 limit=30 byte[] ! pos=0 limit=15 Segment Pool

Slide 98

Slide 98 text

Okio Buffer buffer = new Buffer(); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon”); ! buffer.readUtf8(5); // "Hello" Buffer byte[] ! pos=5 limit=30 byte[] ! pos=0 limit=15 Segment Pool

Slide 99

Slide 99 text

Okio Buffer buffer = new Buffer(); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon”); ! buffer.readUtf8(5); // "Hello" buffer.readUtf8(25); Buffer byte[] ! pos=5 limit=30 byte[] ! pos=0 limit=15 Segment Pool

Slide 100

Slide 100 text

Okio Buffer buffer = new Buffer(); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon”); ! buffer.readUtf8(5); // "Hello" buffer.readUtf8(25); // ", DroidconHello, Droidcon" Buffer byte[] ! pos=30 limit=30 byte[] ! pos=0 limit=15 Segment Pool

Slide 101

Slide 101 text

Okio Buffer buffer = new Buffer(); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon”); ! buffer.readUtf8(5); // "Hello" buffer.readUtf8(25); // ", DroidconHello, Droidcon" Buffer byte[] ! pos=0 limit=15 Segment Pool

Slide 102

Slide 102 text

Okio Buffer buffer = new Buffer(); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon”); ! buffer.readUtf8(5); // "Hello" buffer.readUtf8(25); // ", DroidconHello, Droidcon" ! Buffer otherBuffer = new Buffer(); Buffer byte[] ! pos=0 limit=15

Slide 103

Slide 103 text

Okio Buffer buffer = new Buffer(); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon”); ! buffer.readUtf8(5); // "Hello" buffer.readUtf8(25); // ", DroidconHello, Droidcon" ! Buffer otherBuffer = new Buffer(); Buffer byte[] ! pos=0 limit=15 Buffer

Slide 104

Slide 104 text

Okio Buffer buffer = new Buffer(); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon”); ! buffer.readUtf8(5); // "Hello" buffer.readUtf8(25); // ", DroidconHello, Droidcon" ! Buffer otherBuffer = new Buffer(); otherBuffer.writeAll(buffer); Buffer byte[] ! pos=0 limit=15 Buffer

Slide 105

Slide 105 text

Okio Buffer buffer = new Buffer(); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon"); buffer.writeUtf8("Hello, Droidcon”); ! buffer.readUtf8(5); // "Hello" buffer.readUtf8(25); // ", DroidconHello, Droidcon" ! Buffer otherBuffer = new Buffer(); otherBuffer.writeAll(buffer); Buffer byte[] ! pos=0 limit=15 Buffer

Slide 106

Slide 106 text

Okio • Complements java.io.* and java.nio.*   • Source and Sink move data • Buffer and ByteString hold data

Slide 107

Slide 107 text

Okio • Complements java.io.* and java.nio.*   • Source and Sink move data • Buffer and ByteString hold data • Complements java.io.* and java.nio.* • Source and Sink move data • Buffer and ByteString hold data • BufferedSource and BufferedSink move data efficiently

Slide 108

Slide 108 text

Okio interface BufferedSink extends Sink {
 }X

Slide 109

Slide 109 text

Okio interface BufferedSource extends Source {
 }X interface BufferedSink extends Sink {
 }X

Slide 110

Slide 110 text

Okio interface BufferedSink extends Sink {
 BufferedSink write(ByteString byteString);
 BufferedSink write(byte[] source);
 BufferedSink write(byte[] source, int offset, int byteCount);
 long writeAll(Source source);
 BufferedSink write(Source source, long byteCount);
 BufferedSink writeUtf8(String string);
 BufferedSink writeString(String string, Charset charset);
 BufferedSink writeByte(int b);
 BufferedSink writeShort(int s);
 BufferedSink writeShortLe(int s);
 BufferedSink writeInt(int i);
 BufferedSink writeIntLe(int i);
 BufferedSink writeLong(long v);
 BufferedSink writeLongLe(long v);
 BufferedSink writeDecimalLong(long v);
 BufferedSink writeHexadecimalUnsignedLong(long v);
 }X interface BufferedSource extends Source {
 }X

Slide 111

Slide 111 text

Okio interface BufferedSource extends Source {
 byte readByte();
 short readShort();
 short readShortLe();
 int readInt();
 int readIntLe();
 long readLong();
 long readLongLe();
 long readDecimalLong();
 long readHexadecimalUnsignedLong();
 ByteString readByteString();
 ByteString readByteString(long byteCount);
 byte[] readByteArray();
 byte[] readByteArray(long byteCount);
 int read(byte[] sink);
 void readFully(byte[] sink);
 int read(byte[] sink, int offset, int byteCount);
 void readFully(Buffer sink, long byteCount);
 long readAll(Sink sink);
 String readUtf8();
 String readUtf8(long byteCount);
 String readUtf8Line();
 String readUtf8LineStrict();
 String readString(Charset charset);
 String readString(long byteCount, Charset charset); 
 long indexOf(byte b);
 long indexOf(byte b, long fromIndex);
 long indexOfElement(ByteString targetBytes);
 long indexOfElement(ByteString targetBytes, long fromIndex);
 }X interface BufferedSink extends Sink {
 BufferedSink write(ByteString byteString);
 BufferedSink write(byte[] source);
 BufferedSink write(byte[] source, int offset, int byteCount);
 long writeAll(Source source);
 BufferedSink write(Source source, long byteCount);
 BufferedSink writeUtf8(String string);
 BufferedSink writeString(String string, Charset charset);
 BufferedSink writeByte(int b);
 BufferedSink writeShort(int s);
 BufferedSink writeShortLe(int s);
 BufferedSink writeInt(int i);
 BufferedSink writeIntLe(int i);
 BufferedSink writeLong(long v);
 BufferedSink writeLongLe(long v);
 BufferedSink writeDecimalLong(long v);
 BufferedSink writeHexadecimalUnsignedLong(long v);
 }X

Slide 112

Slide 112 text

Okio interface BufferedSource extends Source {
 byte readByte();
 short readShort();
 short readShortLe();
 int readInt();
 int readIntLe();
 long readLong();
 long readLongLe();
 long readDecimalLong();
 long readHexadecimalUnsignedLong();
 ByteString readByteString();
 ByteString readByteString(long byteCount);
 byte[] readByteArray();
 byte[] readByteArray(long byteCount);
 int read(byte[] sink);
 void readFully(byte[] sink);
 int read(byte[] sink, int offset, int byteCount);
 void readFully(Buffer sink, long byteCount);
 long readAll(Sink sink);
 String readUtf8();
 String readUtf8(long byteCount);
 String readUtf8Line();
 String readUtf8LineStrict();
 String readString(Charset charset);
 String readString(long byteCount, Charset charset); 
 long indexOf(byte b);
 long indexOf(byte b, long fromIndex);
 long indexOfElement(ByteString targetBytes);
 long indexOfElement(ByteString targetBytes, long fromIndex); ! boolean exhausted();
 void require(long byteCount);
 boolean request(long byteCount);
 void skip(long byteCount); ! Buffer buffer();
 InputStream inputStream();
 }X interface BufferedSink extends Sink {
 BufferedSink write(ByteString byteString);
 BufferedSink write(byte[] source);
 BufferedSink write(byte[] source, int offset, int byteCount);
 long writeAll(Source source);
 BufferedSink write(Source source, long byteCount);
 BufferedSink writeUtf8(String string);
 BufferedSink writeString(String string, Charset charset);
 BufferedSink writeByte(int b);
 BufferedSink writeShort(int s);
 BufferedSink writeShortLe(int s);
 BufferedSink writeInt(int i);
 BufferedSink writeIntLe(int i);
 BufferedSink writeLong(long v);
 BufferedSink writeLongLe(long v);
 BufferedSink writeDecimalLong(long v);
 BufferedSink writeHexadecimalUnsignedLong(long v);
 BufferedSink emitCompleteSegments(); BufferedSink emit(); ! Buffer buffer();
 OutputStream outputStream();
 }X

Slide 113

Slide 113 text

Okio classxBuffer implements BufferedSink, BufferedSource { }

Slide 114

Slide 114 text

Okio Socket

Slide 115

Slide 115 text

Okio ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• Socket

Slide 116

Slide 116 text

Okio ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• BufferedSource Socket

Slide 117

Slide 117 text

Okio BufferedSource Socket ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• source.readInt();

Slide 118

Slide 118 text

Okio BufferedSource Socket ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• source.readInt();

Slide 119

Slide 119 text

Okio ! ! ! ! ! ! ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• BufferedSource Socket •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• source.readInt();

Slide 120

Slide 120 text

Okio ! ! ! ! ! ! ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• BufferedSource Socket        •••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• source.readInt(); ••••

Slide 121

Slide 121 text

Okio ! ! ! ! ! ! ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• BufferedSource Socket        •••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• source.readInt(); ••••
 source.readInt();

Slide 122

Slide 122 text

Okio ! ! ! ! ! ! ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• BufferedSource Socket                •••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• source.readInt(); ••••
 source.readInt(); ••••

Slide 123

Slide 123 text

Okio ! ! ! ! ! ! ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• BufferedSource Socket                •••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4);

Slide 124

Slide 124 text

Okio ! ! ! ! ! ! ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• BufferedSource Socket                        •••   •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4); ••••

Slide 125

Slide 125 text

Okio ! ! ! ! ! ! ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• BufferedSource Socket                        •••   •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4); ••••
 source.readLong();

Slide 126

Slide 126 text

Okio ! ! ! ! ! ! ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• BufferedSource Socket                                    ••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4); ••••
 source.readLong(); ••••••••

Slide 127

Slide 127 text

Okio ! ! ! ! ! ! ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• BufferedSource Socket ! ! •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4); ••••
 source.readLong(); ••••••••
 source.readUtf8LineStrict();          ••••••••••

Slide 128

Slide 128 text

Okio ! ! ! ! ! ! ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• BufferedSource Socket ! ! ! •••••••••••••••   •••••••••••••••   ••••••••••••••• source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4); ••••
 source.readLong(); ••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••

Slide 129

Slide 129 text

Okio ! ! ! ! ! ! ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• BufferedSource Socket ! ! ! •••••••••••••••   •••••••••••••••   ••••••••••••••• source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4); ••••
 source.readLong(); ••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••
 source.readUtf8LineStrict();

Slide 130

Slide 130 text

Okio ! ! ! ! ! ! ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• BufferedSource Socket ! ! ! !                          ••   ••••••••••••••• source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4); ••••
 source.readLong(); ••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••
 source.readUtf8LineStrict(); ••••••••••••••••••••••••••••

Slide 131

Slide 131 text

Okio ! ! ! ! ! ! ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• ••••••••••••••• BufferedSource Socket ! ! ! !                          ••   ••••••••••••••• source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4); ••••
 source.readLong(); ••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••••• source.readUtf8(40);

Slide 132

Slide 132 text

Okio ! ! ! ! ! ! ! ! ! ! ! ! •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• BufferedSource Socket ! ! ! !                          ••   ••••••••••••••• source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4); ••••
 source.readLong(); ••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••••• source.readUtf8(40);

Slide 133

Slide 133 text

Okio ! ! ! ! ! ! ! ! ! ! ! ! •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• BufferedSource Socket ! ! ! !                          ••   ••••••••••••••• source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4); ••••
 source.readLong(); ••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••••• source.readUtf8(40); •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••

Slide 134

Slide 134 text

Okio ! ! ! ! ! ! ! ! ! ! ! ! •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• BufferedSource Socket source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4); ••••
 source.readLong(); ••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• !              ••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••

Slide 135

Slide 135 text

Okio ! ! ! ! ! ! ! ! ! ! ! ! •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• BufferedSource Socket source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4); ••••
 source.readLong(); ••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• !              ••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••

Slide 136

Slide 136 text

Okio ! ! ! ! ! ! ! ! ! ! ! ! •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• BufferedSource Socket source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4); ••••
 source.readLong(); ••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• source.readUtf8(40); !              ••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••

Slide 137

Slide 137 text

Okio ! ! ! ! ! ! ! ! ! ! ! ! •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• BufferedSource Socket source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4); ••••
 source.readLong(); ••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• ! ! ! ! •••••••••••••••   •••••••••••••••

Slide 138

Slide 138 text

Okio ! ! ! ! ! ! ! ! ! ! ! ! •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• BufferedSource Socket source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4); ••••
 source.readLong(); ••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• source.readInt(); ! ! ! ! •••••••••••••••   •••••••••••••••

Slide 139

Slide 139 text

Okio ! ! ! ! ! ! ! ! ! ! ! ! •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• BufferedSource Socket source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4); ••••
 source.readLong(); ••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• source.readInt(); •••• ! ! ! !        •••••••••••   •••••••••••••••

Slide 140

Slide 140 text

Okio ! ! ! ! ! ! ! ! ! ! ! ! •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• BufferedSource Socket source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4); ••••
 source.readLong(); ••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• source.readInt(); •••• source.readInt(); ! ! ! !        •••••••••••   •••••••••••••••

Slide 141

Slide 141 text

Okio ! ! ! ! ! ! ! ! ! ! ! ! •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• BufferedSource Socket source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4); ••••
 source.readLong(); ••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• source.readInt(); •••• source.readInt(); •••• ! ! ! !                •••••••   •••••••••••••••

Slide 142

Slide 142 text

Okio ! ! ! ! ! ! ! ! ! ! ! ! •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• BufferedSource Socket source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4); ••••
 source.readLong(); ••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• source.readInt(); •••• source.readInt(); •••• source.readLong(); ! ! ! !                •••••••   •••••••••••••••

Slide 143

Slide 143 text

Okio ! ! ! ! ! ! ! ! ! ! ! ! •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• BufferedSource Socket source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4); ••••
 source.readLong(); ••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• source.readInt(); •••• source.readInt(); •••• source.readLong(); •••••••• ! ! ! !                                  ••••••••••••••

Slide 144

Slide 144 text

Okio ! ! ! ! ! ! ! ! ! ! ! ! •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• BufferedSource Socket source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4); ••••
 source.readLong(); ••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• source.readInt(); •••• source.readInt(); •••• source.readLong(); •••••••• source.readLong(); ! ! ! !                                  ••••••••••••••

Slide 145

Slide 145 text

Okio ! ! ! ! ! ! ! ! ! ! ! ! •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• BufferedSource Socket source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4); ••••
 source.readLong(); ••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• source.readInt(); •••• source.readInt(); •••• source.readLong(); •••••••• source.readLong(); •••••••• ! ! ! !                                                  ••••••

Slide 146

Slide 146 text

Okio ! ! ! ! ! ! ! ! ! ! ! ! •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• BufferedSource Socket source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4); ••••
 source.readLong(); ••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• source.readInt(); •••• source.readInt(); •••• source.readLong(); •••••••• source.readLong(); •••••••• source.readUtf8(6); ! ! ! !                                                  ••••••

Slide 147

Slide 147 text

Okio ! ! ! ! ! ! ! ! ! ! ! ! •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• BufferedSource Socket source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4); ••••
 source.readLong(); ••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• source.readInt(); •••• source.readInt(); •••• source.readLong(); •••••••• source.readLong(); •••••••• source.readUtf8(6); ••••••

Slide 148

Slide 148 text

Okio ! ! ! ! ! ! ! ! ! ! ! ! •••••••••••••••   •••••••••••••••   •••••••••••••••   •••••••••••••••   ••••••••••••••• BufferedSource Socket source.readInt(); ••••
 source.readInt(); ••••
 source.readUtf8(4); ••••
 source.readLong(); ••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••
 source.readUtf8LineStrict(); •••••••••••••••••••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• source.readUtf8(40); •••••••••••••••••••••••••••• ••••••••••• source.readInt(); •••• source.readInt(); •••• source.readLong(); •••••••• source.readLong(); •••••••• source.readUtf8(6); ••••••

Slide 149

Slide 149 text

Okio class Okio {
 static BufferedSource buffer(Source source) {}
 static BufferedSink buffer(Sink sink) {}
 }X

Slide 150

Slide 150 text

Okio class Okio {
 static BufferedSource buffer(Source source) {}
 static BufferedSink buffer(Sink sink) {}
 
 static Source source(InputStream in) {}
 static Sink sink(OutputStream out) {}
 }X

Slide 151

Slide 151 text

Okio class Okio {
 static BufferedSource buffer(Source source) {}
 static BufferedSink buffer(Sink sink) {}
 
 static Source source(InputStream in) {}
 static Sink sink(OutputStream out) {}
 
 static Source source(Socket socket) {}
 static Sink sink(Socket socket) {}
 }X

Slide 152

Slide 152 text

Okio class Okio {
 static BufferedSource buffer(Source source) {}
 static BufferedSink buffer(Sink sink) {}
 
 static Source source(InputStream in) {}
 static Sink sink(OutputStream out) {}
 
 static Source source(Socket socket) {}
 static Sink sink(Socket socket) {}
 
 static Source source(File file) {}
 static Sink sink(File file) {}
 static Sink appendingSink(File file) {}
 }X

Slide 153

Slide 153 text

Okio class Okio {
 static BufferedSource buffer(Source source) {}
 static BufferedSink buffer(Sink sink) {}
 
 static Source source(InputStream in) {}
 static Sink sink(OutputStream out) {}
 
 static Source source(Socket socket) {}
 static Sink sink(Socket socket) {}
 
 static Source source(File file) {}
 static Sink sink(File file) {}
 static Sink appendingSink(File file) {}
 
 static Source source(Path path, OpenOption... options) {}
 static Sink sink(Path path, OpenOption... options) {}
 }X

Slide 154

Slide 154 text

Okio class DeflaterSink {
 DeflaterSink(Sink sink, Deflater deflater) {}
 }

Slide 155

Slide 155 text

Okio ! ! ! ! class InflaterSource {
 InflaterSource(Source source, Inflater inflater) {}
 } class DeflaterSink {
 DeflaterSink(Sink sink, Deflater deflater) {}
 }

Slide 156

Slide 156 text

Okio ! ! ! ! ! ! ! ! class GzipSink {
 GzipSink(Sink sink) {}
 } ! ! ! ! class InflaterSource {
 InflaterSource(Source source, Inflater inflater) {}
 } class DeflaterSink {
 DeflaterSink(Sink sink, Deflater deflater) {}
 }

Slide 157

Slide 157 text

Okio ! ! ! ! ! ! ! ! class GzipSink {
 GzipSink(Sink sink) {}
 } 
 
 
 
 
 
 
 
 
 
 
 
 class GzipSource {
 GzipSource(Source source) {}
 } ! ! ! ! class InflaterSource {
 InflaterSource(Source source, Inflater inflater) {}
 } class DeflaterSink {
 DeflaterSink(Sink sink, Deflater deflater) {}
 }

Slide 158

Slide 158 text

Okio File file = // ... File

Slide 159

Slide 159 text

Okio File file = // ...
 Sink fileSink = Okio.sink(file); File FileSink

Slide 160

Slide 160 text

Okio File file = // ...
 Sink fileSink = Okio.sink(file);
 Sink gzipSink = new GzipSink(fileSink); File GzipSink FileSink

Slide 161

Slide 161 text

Okio File file = // ...
 Sink fileSink = Okio.sink(file);
 Sink gzipSink = new GzipSink(fileSink);
 BufferedSink bufferedSink = Okio.buffer(gzipSink); File BufferedSink GzipSink FileSink

Slide 162

Slide 162 text

Okio File file = // ...
 Sink fileSink = Okio.sink(file);
 Sink gzipSink = new GzipSink(fileSink);
 BufferedSink bufferedSink = Okio.buffer(gzipSink);
 bufferedSink.writeUtf8("Hello, hello, hello!"); File FileSink GzipSink BufferedSink 
 
 
 
 "Hello, hello, hello!"

Slide 163

Slide 163 text

Okio File file = // ...
 Sink fileSink = Okio.sink(file);
 Sink gzipSink = new GzipSink(fileSink);
 BufferedSink bufferedSink = Okio.buffer(gzipSink);
 bufferedSink.writeUtf8("Hello, hello, hello!"); File FileSink GzipSink BufferedSink Hello, hello, hello!

Slide 164

Slide 164 text

x??H????Q?@?H?? Okio File file = // ...
 Sink fileSink = Okio.sink(file);
 Sink gzipSink = new GzipSink(fileSink);
 BufferedSink bufferedSink = Okio.buffer(gzipSink);
 bufferedSink.writeUtf8("Hello, hello, hello!"); bufferedSink.close(); File FileSink GzipSink BufferedSink Hello, hello, hello!

Slide 165

Slide 165 text

Hello, hello, hello! Okio File file = // ...
 Sink fileSink = Okio.sink(file);
 Sink gzipSink = new GzipSink(fileSink);
 BufferedSink bufferedSink = Okio.buffer(gzipSink);
 bufferedSink.writeUtf8("Hello, hello, hello!"); bufferedSink.close(); File FileSink GzipSink BufferedSink x??H????Q?@?H??

Slide 166

Slide 166 text

Okio File file = // ...
 Sink fileSink = Okio.sink(file);
 Sink gzipSink = new GzipSink(fileSink);
 BufferedSink bufferedSink = Okio.buffer(gzipSink);
 bufferedSink.writeUtf8("Hello, hello, hello!"); bufferedSink.close(); File FileSink GzipSink BufferedSink x??H????Q?@?H??

Slide 167

Slide 167 text

Okio File file = // ...
 Sink fileSink = Okio.sink(file);
 Sink gzipSink = new GzipSink(fileSink);
 BufferedSink bufferedSink = Okio.buffer(gzipSink);
 bufferedSink.writeUtf8("Hello, hello, hello!"); bufferedSink.close(); File FileSink GzipSink BufferedSink x??H????Q?@?H??

Slide 168

Slide 168 text

Okio File file = // ...
 Sink fileSink = Okio.sink(file);
 Sink gzipSink = new GzipSink(fileSink);
 Sha1Sink hashingSink = new Sha1Sink(gzipSink);
 BufferedSink bufferedSink = Okio.buffer(hashingSink);
 
 bufferedSink.writeUtf8("Hello, hello, hello!");
 bufferedSink.close();
 
 String hash = hashingSink.hash(); File FileSink GzipSink BufferedSink Sha1Sink

Slide 169

Slide 169 text

Okio Socket socket = //...
 Source socketSource = Okio.source(socket);

Slide 170

Slide 170 text

Okio Socket socket = //...
 Source socketSource = Okio.source(socket);
 
 Throttler throttler = new Throttler();
 Source throttledSource = throttler.throttle(socketSource);

Slide 171

Slide 171 text

Okio Socket socket = //...
 Source socketSource = Okio.source(socket);
 
 Throttler throttler = new Throttler();
 Source throttledSource = throttler.throttle(socketSource);
 
 BufferedSource bufferedSource = Okio.buffer(throttledSource);
 bufferedSource.readUtf8(10 * 1024);

Slide 172

Slide 172 text

Okio Socket socket = //...
 Source socketSource = Okio.source(socket);
 
 Throttler throttler = new Throttler();
 Source throttledSource = throttler.throttle(socketSource);
 
 BufferedSource bufferedSource = Okio.buffer(throttledSource);
 bufferedSource.readUtf8(10 * 1024);
 
 throttler.bytesPerTimePeriod(50, 1, SECONDS);
 bufferedSource.readUtf8(10 * 1024);

Slide 173

Slide 173 text

OkHttp

Slide 174

Slide 174 text

OkHttp OkHttpClient client = new OkHttpClient();

Slide 175

Slide 175 text

OkHttp OkHttpClient client = new OkHttpClient(); 
 
 Request request = new Request.Builder()
 .url("http://droidcon.ca/a-few-ok-libraries.html")
 .build();

Slide 176

Slide 176 text

OkHttp OkHttpClient client = new OkHttpClient(); 
 
 RequestBody requestBody = // ... Request request = new Request.Builder()
 .url("http://droidcon.ca/a-few-ok-libraries.html") .post(requestBody)
 .build();

Slide 177

Slide 177 text

OkHttp OkHttpClient client = new OkHttpClient(); 
 
 RequestBody requestBody = // ... Request request = new Request.Builder()
 .url("http://droidcon.ca/a-few-ok-libraries.html") .post(requestBody)
 .build(); class RequestBody {
 static RequestBody create(MediaType mediaType, String body) {}
 static RequestBody create(MediaType mediaType, byte[] body) {}
 static RequestBody create(MediaType mediaType, File body) {}
 }X

Slide 178

Slide 178 text

OkHttp class RequestBody {
 static RequestBody create(MediaType mediaType, String body) {}
 static RequestBody create(MediaType mediaType, byte[] body) {}
 static RequestBody create(MediaType mediaType, File body) {}
 }X

Slide 179

Slide 179 text

OkHttp abstract class RequestBody {
 static RequestBody create(MediaType mediaType, String body) {}
 static RequestBody create(MediaType mediaType, byte[] body) {}
 static RequestBody create(MediaType mediaType, File body) {}
 
 long contentLength();
 MediaType contentType();
 void writeTo(BufferedSink sink);
 }X

Slide 180

Slide 180 text

OkHttp ! ! ! ! ! ! ! requestBody.writeTo(sink);

Slide 181

Slide 181 text

OkHttp ! ! ! ! ! ! ! requestBody.writeTo(sink); Socket

Slide 182

Slide 182 text

OkHttp GET  /a-­‐few-­‐ok-­‐libraries.html  HTTP/1.1   Host:  droidcon.ca   Content-­‐Type:  text/plain   Content-­‐Length:  3000 ! ! ! ! ! ! ! requestBody.writeTo(sink); Socket

Slide 183

Slide 183 text

OkHttp GET  /a-­‐few-­‐ok-­‐libraries.html  HTTP/1.1   Host:  droidcon.ca   Content-­‐Type:  text/plain   Content-­‐Length:  3000 ! ! ! ! ! ! ! requestBody.writeTo(sink); Socket FixedLengthSink

Slide 184

Slide 184 text

OkHttp GET  /a-­‐few-­‐ok-­‐libraries.html  HTTP/1.1   Host:  droidcon.ca   Content-­‐Type:  text/plain   Content-­‐Length:  3000 ! ! ! ! ! ! ! requestBody.writeTo(sink); Socket FixedLengthSink ! ! ! ! ! You  think  water  moves  fast?  You  should  see  ice.  It   moves  like  it  has  a  mind.  Like  it  knows  it  killed  the   world  once  and  got  a  taste  for  murder.  After  the   avalanche,  it  took  us  a  week  to  climb  out.  Now,  I  don't   know  exactly  when  we  turned  on  each  other,  but  I  know   that  seven  of  us  survived  the  slide...  and  only  five   made  it  out.  Now  we  took  an  oath,  that  I'm  breaking   now.  We  said  we'd  say  it  was  the  snow  that  killed  the   other  two,  but  it  wasn't.  Nature  is  lethal  but  it   doesn't  hold  a  candle  to  man.   ! Your  bones  don't  break,  mine  do.  That's  clear.  Your   cells  react  to  bacteria  and  viruses  differently  than   mine.  You  don't  get  sick,  I  do.  That's  also  clear.  But   for  some  reason,  you  and  I  react  the  exact  same  way  to   water.  We  swallow  it  too  fast,  we  choke.  We  get  some  in   our  lungs,  we  drown.  However  unreal  it  may  seem,  we  are   connected,  you  and  I.  We're  on  the  same  curve,  just  on   opposite  ends.   ! Normally,  both  your  asses  would  be  dead  as  fucking   fried  chicken,  but  you  happen  to  pull  this  shit  while   I'm  in  a  transitional  period  so  I  don't  wanna  kill  you,   I  wanna  help  you.  But  I  can't  give  you  this  case,  it   don't  belong  to  me.  Besides,  I've  already  been  through   too  much  shit  this  morning  over  this  case  to  hand  it   over  to  your  dumb  ass.   ! The  path  of  the  righteous  man  is  beset  on  all  sides  by   the  iniquities  of  the  selfish  and  the  tyranny  of  evil   men.  Blessed  is  he  who,  in  the  name  of  charity  and  good   will,  shepherds  the  weak  through  the  valley  of   darkness,  for  he  is  truly  his  brother's  keeper  and  the   finder  of  lost  children.  And  I  will  strike  down  upon   thee  with  great  vengeance  and  furious  anger  those  who   would  attempt  to  poison  and  destroy  My  brothers.  And   you  will  know  My  name  is  the  Lord  when  I  lay  My   vengeance  upon  thee.   ! My  money's  in  that  office,  right?  If  she  start  giving   me  some  bullshit  about  it  ain't  there,  and  we  got  to  go   someplace  else  and  get  it,  I'm  gonna  shoot  you  in  the   head  then  and  there.  Then  I'm  gonna  shoot  that  bitch  in   the  kneecaps,  find  out  where  my  goddamn  money  is.  She   gonna  tell  me  too.  Hey,  look  at  me  when  I'm  talking  to   you,  motherfucker.  You  listen:  we  go  in  there,  and  that   nigga  Winston  or  anybody  else  is  in  there,  you  the   first  motherfucker  to  get  shot.  You  understand?   ! Look,  just  because  I  don't  be  givin'  no  man  a  foot   massage  don't  make  it  right  for  Marsellus  to  throw   Antwone  into  a  glass  motherfuckin'  house,  fuckin'  up   the  way  the  nigger  talks.  Motherfucker  do  that  shit  to   me,  he  better  paralyze  my  ass,  'cause  I'll  kill  the   motherfucker,  know  what  I'm  sayin’?   ! Well,  the  way  they  make  shows  is,  they  make  one  show.   That  show's  called  a  pilot.  Then  they  show  that  show  to   the  people  who  make  shows,  and  on  the  strength  of  that   one  show  they  decide  if  they're  going  to  make  more   shows.  Some  pilots  get  picked  and  become  television   programs.  Some  don't,  become  nothing.  She  starred  in   one  of  the  ones  that  became  nothing.

Slide 185

Slide 185 text

OkHttp Socket HTTP/2

Slide 186

Slide 186 text

OkHttp requestBody1 Socket requestBody2 HTTP/2

Slide 187

Slide 187 text

OkHttp requestBody1 Socket FramedSink FramedSink requestBody2 HTTP/2

Slide 188

Slide 188 text

OkHttp requestBody1 Socket FixedLengthSink FramedSink FramedSink FixedLengthSink requestBody2 HTTP/2

Slide 189

Slide 189 text

OkHttp requestBody1 Socket FixedLengthSink FramedSink FramedSink FixedLengthSink requestBody2 HTTP/2

Slide 190

Slide 190 text

OkHttp OkHttpClient client = new OkHttpClient(); 
 
 Request request = new Request.Builder()
 .url("http://droidcon.ca/a-few-ok-libraries.html")
 .build();

Slide 191

Slide 191 text

OkHttp OkHttpClient client = new OkHttpClient(); 
 
 Request request = new Request.Builder()
 .url("http://droidcon.ca/a-few-ok-libraries.html")
 .build(); 
 
 
 
 
 
 Response response = .execute(); client.newCall(request)

Slide 192

Slide 192 text

OkHttp OkHttpClient client = new OkHttpClient(); 
 
 Request request = new Request.Builder()
 .url("http://droidcon.ca/a-few-ok-libraries.html")
 .build(); 
 
 
 
 
 
 Response response = .execute(); 
 
 
 
 
 
 
 
 System.out.println( ); client.newCall(request) response.body().string()

Slide 193

Slide 193 text

OkHttp 
 
 
 
 
 
 .enqueue(new Callback() {
 @Override void onResponse(Response response) {
 
 }
 
 @Override void onFailure(Request request, IOException e) {
 // ...
 }
 }); OkHttpClient client = new OkHttpClient(); 
 
 Request request = new Request.Builder()
 .url("http://droidcon.ca/a-few-ok-libraries.html")
 .build(); 
 
 
 
 
 
 
 
 System.out.println( ); client.newCall(request) response.body().string()

Slide 194

Slide 194 text

OkHttp String string = ; response.body().string()

Slide 195

Slide 195 text

OkHttp ResponseBody body = response.body();
 String string = body.string();

Slide 196

Slide 196 text

OkHttp ResponseBody body = response.body();
 String string = body.string(); 
 
 Reader reader = body.charStream();

Slide 197

Slide 197 text

OkHttp ResponseBody body = response.body(); 
 String string = body.string();
 Reader reader = body.charStream();
 InputStream stream = body.byteStream();

Slide 198

Slide 198 text

OkHttp ResponseBody body = response.body(); 
 String string = body.string();
 Reader reader = body.charStream();
 InputStream stream = body.byteStream();
 byte[] bytes = body.bytes();

Slide 199

Slide 199 text

OkHttp ResponseBody body = response.body(); 
 String string = body.string();
 Reader reader = body.charStream();
 InputStream stream = body.byteStream();
 byte[] bytes = body.bytes(); ! BufferedSource source = body.source();

Slide 200

Slide 200 text

OkHttp ! ! ! ! ! ! ! body.source();

Slide 201

Slide 201 text

OkHttp HTTP/1.1  200  OK   Date:  Thu,  9  Apr  2015  15:14:34  GMT   Server:  JakeWharton/2.3.7  (Human)   Content-­‐Type:  application/presentation;  charset=UTF-­‐8   Content-­‐Length:  3000   ! You  think  water  moves  fast?  You  should  see  ice.  It   moves  like  it  has  a  mind.  Like  it  knows  it  killed  the   world  once  and  got  a  taste  for  murder.  After  the   avalanche,  it  took  us  a  week  to  climb  out.  Now,  I  don't   know  exactly  when  we  turned  on  each  other,  but  I  know   that  seven  of  us  survived  the  slide...  and  only  five   made  it  out.  Now  we  took  an  oath,  that  I'm  breaking   now.  We  said  we'd  say  it  was  the  snow  that  killed  the   other  two,  but  it  wasn't.  Nature  is  lethal  but  it   doesn't  hold  a  candle  to  man.   ! Your  bones  don't  break,  mine  do.  That's  clear.  Your   cells  react  to  bacteria  and  viruses  differently  than   mine.  You  don't  get  sick,  I  do.  That's  also  clear.  But   for  some  reason,  you  and  I  react  the  exact  same  way  to   water.  We  swallow  it  too  fast,  we  choke.  We  get  some  in   our  lungs,  we  drown.  However  unreal  it  may  seem,  we  are   connected,  you  and  I.  We're  on  the  same  curve,  just  on   opposite  ends.   ! Normally,  both  your  asses  would  be  dead  as  fucking   fried  chicken,  but  you  happen  to  pull  this  shit  while   I'm  in  a  transitional  period  so  I  don't  wanna  kill  you,   I  wanna  help  you.  But  I  can't  give  you  this  case,  it   don't  belong  to  me.  Besides,  I've  already  been  through   too  much  shit  this  morning  over  this  case  to  hand  it   over  to  your  dumb  ass.   ! The  path  of  the  righteous  man  is  beset  on  all  sides  by   the  iniquities  of  the  selfish  and  the  tyranny  of  evil   men.  Blessed  is  he  who,  in  the  name  of  charity  and  good   will,  shepherds  the  weak  through  the  valley  of   darkness,  for  he  is  truly  his  brother's  keeper  and  the   finder  of  lost  children.  And  I  will  strike  down  upon   thee  with  great  vengeance  and  furious  anger  those  who   would  attempt  to  poison  and  destroy  My  brothers.  And   you  will  know  My  name  is  the  Lord  when  I  lay  My   vengeance  upon  thee.   ! My  money's  in  that  office,  right?  If  she  start  giving   me  some  bullshit  about  it  ain't  there,  and  we  got  to  go   someplace  else  and  get  it,  I'm  gonna  shoot  you  in  the   head  then  and  there.  Then  I'm  gonna  shoot  that  bitch  in   the  kneecaps,  find  out  where  my  goddamn  money  is.  She   gonna  tell  me  too.  Hey,  look  at  me  when  I'm  talking  to   you,  motherfucker.  You  listen:  we  go  in  there,  and  that   nigga  Winston  or  anybody  else  is  in  there,  you  the   first  motherfucker  to  get  shot.  You  understand?   ! Look,  just  because  I  don't  be  givin'  no  man  a  foot   massage  don't  make  it  right  for  Marsellus  to  throw   Antwone  into  a  glass  motherfuckin'  house,  fuckin'  up   the  way  the  nigger  talks.  Motherfucker  do  that  shit  to   me,  he  better  paralyze  my  ass,  'cause  I'll  kill  the   motherfucker,  know  what  I'm  sayin’?   ! Well,  the  way  they  make  shows  is,  they  make  one  show.   That  show's  called  a  pilot.  Then  they  show  that  show  to   the  people  who  make  shows,  and  on  the  strength  of  that   one  show  they  decide  if  they're  going  to  make  more   shows.  Some  pilots  get  picked  and  become  television   programs.  Some  don't,  become  nothing.  She  starred  in   one  of  the  ones  that  became  nothing. ! ! ! ! ! ! ! body.source(); Socket HTTP/1.1  200  OK   Date:  Thu,  9  Apr  2015  15:14:34  GMT   Server:  JakeWharton/2.3.7  (Human)   Content-­‐Type:  application/presentation;  charset=UTF-­‐8   Content-­‐Length:  3000

Slide 202

Slide 202 text

OkHttp HTTP/1.1  200  OK   Date:  Thu,  9  Apr  2015  15:14:34  GMT   Server:  JakeWharton/2.3.7  (Human)   Content-­‐Type:  application/presentation;  charset=UTF-­‐8   Content-­‐Length:  3000   ! You  think  water  moves  fast?  You  should  see  ice.  It   moves  like  it  has  a  mind.  Like  it  knows  it  killed  the   world  once  and  got  a  taste  for  murder.  After  the   avalanche,  it  took  us  a  week  to  climb  out.  Now,  I  don't   know  exactly  when  we  turned  on  each  other,  but  I  know   that  seven  of  us  survived  the  slide...  and  only  five   made  it  out.  Now  we  took  an  oath,  that  I'm  breaking   now.  We  said  we'd  say  it  was  the  snow  that  killed  the   other  two,  but  it  wasn't.  Nature  is  lethal  but  it   doesn't  hold  a  candle  to  man.   ! Your  bones  don't  break,  mine  do.  That's  clear.  Your   cells  react  to  bacteria  and  viruses  differently  than   mine.  You  don't  get  sick,  I  do.  That's  also  clear.  But   for  some  reason,  you  and  I  react  the  exact  same  way  to   water.  We  swallow  it  too  fast,  we  choke.  We  get  some  in   our  lungs,  we  drown.  However  unreal  it  may  seem,  we  are   connected,  you  and  I.  We're  on  the  same  curve,  just  on   opposite  ends.   ! Normally,  both  your  asses  would  be  dead  as  fucking   fried  chicken,  but  you  happen  to  pull  this  shit  while   I'm  in  a  transitional  period  so  I  don't  wanna  kill  you,   I  wanna  help  you.  But  I  can't  give  you  this  case,  it   don't  belong  to  me.  Besides,  I've  already  been  through   too  much  shit  this  morning  over  this  case  to  hand  it   over  to  your  dumb  ass.   ! The  path  of  the  righteous  man  is  beset  on  all  sides  by   the  iniquities  of  the  selfish  and  the  tyranny  of  evil   men.  Blessed  is  he  who,  in  the  name  of  charity  and  good   will,  shepherds  the  weak  through  the  valley  of   darkness,  for  he  is  truly  his  brother's  keeper  and  the   finder  of  lost  children.  And  I  will  strike  down  upon   thee  with  great  vengeance  and  furious  anger  those  who   would  attempt  to  poison  and  destroy  My  brothers.  And   you  will  know  My  name  is  the  Lord  when  I  lay  My   vengeance  upon  thee.   ! My  money's  in  that  office,  right?  If  she  start  giving   me  some  bullshit  about  it  ain't  there,  and  we  got  to  go   someplace  else  and  get  it,  I'm  gonna  shoot  you  in  the   head  then  and  there.  Then  I'm  gonna  shoot  that  bitch  in   the  kneecaps,  find  out  where  my  goddamn  money  is.  She   gonna  tell  me  too.  Hey,  look  at  me  when  I'm  talking  to   you,  motherfucker.  You  listen:  we  go  in  there,  and  that   nigga  Winston  or  anybody  else  is  in  there,  you  the   first  motherfucker  to  get  shot.  You  understand?   ! Look,  just  because  I  don't  be  givin'  no  man  a  foot   massage  don't  make  it  right  for  Marsellus  to  throw   Antwone  into  a  glass  motherfuckin'  house,  fuckin'  up   the  way  the  nigger  talks.  Motherfucker  do  that  shit  to   me,  he  better  paralyze  my  ass,  'cause  I'll  kill  the   motherfucker,  know  what  I'm  sayin’?   ! Well,  the  way  they  make  shows  is,  they  make  one  show.   That  show's  called  a  pilot.  Then  they  show  that  show  to   the  people  who  make  shows,  and  on  the  strength  of  that   one  show  they  decide  if  they're  going  to  make  more   shows.  Some  pilots  get  picked  and  become  television   programs.  Some  don't,  become  nothing.  She  starred  in   one  of  the  ones  that  became  nothing. ! ! ! ! ! ! ! body.source(); Socket HTTP/1.1  200  OK   Date:  Thu,  9  Apr  2015  15:14:34  GMT   Server:  JakeWharton/2.3.7  (Human)   Content-­‐Type:  application/presentation;  charset=UTF-­‐8   Content-­‐Length:  3000

Slide 203

Slide 203 text

OkHttp HTTP/1.1  200  OK   Date:  Thu,  9  Apr  2015  15:14:34  GMT   Server:  JakeWharton/2.3.7  (Human)   Content-­‐Type:  application/presentation;  charset=UTF-­‐8   Content-­‐Length:  3000   ! You  think  water  moves  fast?  You  should  see  ice.  It   moves  like  it  has  a  mind.  Like  it  knows  it  killed  the   world  once  and  got  a  taste  for  murder.  After  the   avalanche,  it  took  us  a  week  to  climb  out.  Now,  I  don't   know  exactly  when  we  turned  on  each  other,  but  I  know   that  seven  of  us  survived  the  slide...  and  only  five   made  it  out.  Now  we  took  an  oath,  that  I'm  breaking   now.  We  said  we'd  say  it  was  the  snow  that  killed  the   other  two,  but  it  wasn't.  Nature  is  lethal  but  it   doesn't  hold  a  candle  to  man.   ! Your  bones  don't  break,  mine  do.  That's  clear.  Your   cells  react  to  bacteria  and  viruses  differently  than   mine.  You  don't  get  sick,  I  do.  That's  also  clear.  But   for  some  reason,  you  and  I  react  the  exact  same  way  to   water.  We  swallow  it  too  fast,  we  choke.  We  get  some  in   our  lungs,  we  drown.  However  unreal  it  may  seem,  we  are   connected,  you  and  I.  We're  on  the  same  curve,  just  on   opposite  ends.   ! Normally,  both  your  asses  would  be  dead  as  fucking   fried  chicken,  but  you  happen  to  pull  this  shit  while   I'm  in  a  transitional  period  so  I  don't  wanna  kill  you,   I  wanna  help  you.  But  I  can't  give  you  this  case,  it   don't  belong  to  me.  Besides,  I've  already  been  through   too  much  shit  this  morning  over  this  case  to  hand  it   over  to  your  dumb  ass.   ! The  path  of  the  righteous  man  is  beset  on  all  sides  by   the  iniquities  of  the  selfish  and  the  tyranny  of  evil   men.  Blessed  is  he  who,  in  the  name  of  charity  and  good   will,  shepherds  the  weak  through  the  valley  of   darkness,  for  he  is  truly  his  brother's  keeper  and  the   finder  of  lost  children.  And  I  will  strike  down  upon   thee  with  great  vengeance  and  furious  anger  those  who   would  attempt  to  poison  and  destroy  My  brothers.  And   you  will  know  My  name  is  the  Lord  when  I  lay  My   vengeance  upon  thee.   ! My  money's  in  that  office,  right?  If  she  start  giving   me  some  bullshit  about  it  ain't  there,  and  we  got  to  go   someplace  else  and  get  it,  I'm  gonna  shoot  you  in  the   head  then  and  there.  Then  I'm  gonna  shoot  that  bitch  in   the  kneecaps,  find  out  where  my  goddamn  money  is.  She   gonna  tell  me  too.  Hey,  look  at  me  when  I'm  talking  to   you,  motherfucker.  You  listen:  we  go  in  there,  and  that   nigga  Winston  or  anybody  else  is  in  there,  you  the   first  motherfucker  to  get  shot.  You  understand?   ! Look,  just  because  I  don't  be  givin'  no  man  a  foot   massage  don't  make  it  right  for  Marsellus  to  throw   Antwone  into  a  glass  motherfuckin'  house,  fuckin'  up   the  way  the  nigger  talks.  Motherfucker  do  that  shit  to   me,  he  better  paralyze  my  ass,  'cause  I'll  kill  the   motherfucker,  know  what  I'm  sayin’?   ! Well,  the  way  they  make  shows  is,  they  make  one  show.   That  show's  called  a  pilot.  Then  they  show  that  show  to   the  people  who  make  shows,  and  on  the  strength  of  that   one  show  they  decide  if  they're  going  to  make  more   shows.  Some  pilots  get  picked  and  become  television   programs.  Some  don't,  become  nothing.  She  starred  in   one  of  the  ones  that  became  nothing. ! ! ! ! ! ! ! body.source(); Socket HTTP/1.1  200  OK   Date:  Thu,  9  Apr  2015  15:14:34  GMT   Server:  JakeWharton/2.3.7  (Human)   Content-­‐Type:  application/presentation;  charset=UTF-­‐8   Content-­‐Length:  3000

Slide 204

Slide 204 text

OkHttp HTTP/1.1  200  OK   Date:  Thu,  9  Apr  2015  15:14:34  GMT   Server:  JakeWharton/2.3.7  (Human)   Content-­‐Type:  application/presentation;  charset=UTF-­‐8   Content-­‐Length:  3000   ! You  think  water  moves  fast?  You  should  see  ice.  It   moves  like  it  has  a  mind.  Like  it  knows  it  killed  the   world  once  and  got  a  taste  for  murder.  After  the   avalanche,  it  took  us  a  week  to  climb  out.  Now,  I  don't   know  exactly  when  we  turned  on  each  other,  but  I  know   that  seven  of  us  survived  the  slide...  and  only  five   made  it  out.  Now  we  took  an  oath,  that  I'm  breaking   now.  We  said  we'd  say  it  was  the  snow  that  killed  the   other  two,  but  it  wasn't.  Nature  is  lethal  but  it   doesn't  hold  a  candle  to  man.   ! Your  bones  don't  break,  mine  do.  That's  clear.  Your   cells  react  to  bacteria  and  viruses  differently  than   mine.  You  don't  get  sick,  I  do.  That's  also  clear.  But   for  some  reason,  you  and  I  react  the  exact  same  way  to   water.  We  swallow  it  too  fast,  we  choke.  We  get  some  in   our  lungs,  we  drown.  However  unreal  it  may  seem,  we  are   connected,  you  and  I.  We're  on  the  same  curve,  just  on   opposite  ends.   ! Normally,  both  your  asses  would  be  dead  as  fucking   fried  chicken,  but  you  happen  to  pull  this  shit  while   I'm  in  a  transitional  period  so  I  don't  wanna  kill  you,   I  wanna  help  you.  But  I  can't  give  you  this  case,  it   don't  belong  to  me.  Besides,  I've  already  been  through   too  much  shit  this  morning  over  this  case  to  hand  it   over  to  your  dumb  ass.   ! The  path  of  the  righteous  man  is  beset  on  all  sides  by   the  iniquities  of  the  selfish  and  the  tyranny  of  evil   men.  Blessed  is  he  who,  in  the  name  of  charity  and  good   will,  shepherds  the  weak  through  the  valley  of   darkness,  for  he  is  truly  his  brother's  keeper  and  the   finder  of  lost  children.  And  I  will  strike  down  upon   thee  with  great  vengeance  and  furious  anger  those  who   would  attempt  to  poison  and  destroy  My  brothers.  And   you  will  know  My  name  is  the  Lord  when  I  lay  My   vengeance  upon  thee.   ! My  money's  in  that  office,  right?  If  she  start  giving   me  some  bullshit  about  it  ain't  there,  and  we  got  to  go   someplace  else  and  get  it,  I'm  gonna  shoot  you  in  the   head  then  and  there.  Then  I'm  gonna  shoot  that  bitch  in   the  kneecaps,  find  out  where  my  goddamn  money  is.  She   gonna  tell  me  too.  Hey,  look  at  me  when  I'm  talking  to   you,  motherfucker.  You  listen:  we  go  in  there,  and  that   nigga  Winston  or  anybody  else  is  in  there,  you  the   first  motherfucker  to  get  shot.  You  understand?   ! Look,  just  because  I  don't  be  givin'  no  man  a  foot   massage  don't  make  it  right  for  Marsellus  to  throw   Antwone  into  a  glass  motherfuckin'  house,  fuckin'  up   the  way  the  nigger  talks.  Motherfucker  do  that  shit  to   me,  he  better  paralyze  my  ass,  'cause  I'll  kill  the   motherfucker,  know  what  I'm  sayin’?   ! Well,  the  way  they  make  shows  is,  they  make  one  show.   That  show's  called  a  pilot.  Then  they  show  that  show  to   the  people  who  make  shows,  and  on  the  strength  of  that   one  show  they  decide  if  they're  going  to  make  more   shows.  Some  pilots  get  picked  and  become  television   programs.  Some  don't,  become  nothing.  She  starred  in   one  of  the  ones  that  became  nothing. ! ! ! ! ! ! ! body.source(); Socket HTTP/1.1  200  OK   Date:  Thu,  9  Apr  2015  15:14:34  GMT   Server:  JakeWharton/2.3.7  (Human)   Content-­‐Type:  application/presentation;  charset=UTF-­‐8   Content-­‐Length:  3000 FixedLengthSource

Slide 205

Slide 205 text

OkHttp HTTP/1.1  200  OK   Date:  Thu,  9  Apr  2015  15:14:34  GMT   Server:  JakeWharton/2.3.7  (Human)   Content-­‐Type:  application/presentation;  charset=UTF-­‐8   Content-­‐Length:  3000   ! You  think  water  moves  fast?  You  should  see  ice.  It   moves  like  it  has  a  mind.  Like  it  knows  it  killed  the   world  once  and  got  a  taste  for  murder.  After  the   avalanche,  it  took  us  a  week  to  climb  out.  Now,  I  don't   know  exactly  when  we  turned  on  each  other,  but  I  know   that  seven  of  us  survived  the  slide...  and  only  five   made  it  out.  Now  we  took  an  oath,  that  I'm  breaking   now.  We  said  we'd  say  it  was  the  snow  that  killed  the   other  two,  but  it  wasn't.  Nature  is  lethal  but  it   doesn't  hold  a  candle  to  man.   ! Your  bones  don't  break,  mine  do.  That's  clear.  Your   cells  react  to  bacteria  and  viruses  differently  than   mine.  You  don't  get  sick,  I  do.  That's  also  clear.  But   for  some  reason,  you  and  I  react  the  exact  same  way  to   water.  We  swallow  it  too  fast,  we  choke.  We  get  some  in   our  lungs,  we  drown.  However  unreal  it  may  seem,  we  are   connected,  you  and  I.  We're  on  the  same  curve,  just  on   opposite  ends.   ! Normally,  both  your  asses  would  be  dead  as  fucking   fried  chicken,  but  you  happen  to  pull  this  shit  while   I'm  in  a  transitional  period  so  I  don't  wanna  kill  you,   I  wanna  help  you.  But  I  can't  give  you  this  case,  it   don't  belong  to  me.  Besides,  I've  already  been  through   too  much  shit  this  morning  over  this  case  to  hand  it   over  to  your  dumb  ass.   ! The  path  of  the  righteous  man  is  beset  on  all  sides  by   the  iniquities  of  the  selfish  and  the  tyranny  of  evil   men.  Blessed  is  he  who,  in  the  name  of  charity  and  good   will,  shepherds  the  weak  through  the  valley  of   darkness,  for  he  is  truly  his  brother's  keeper  and  the   finder  of  lost  children.  And  I  will  strike  down  upon   thee  with  great  vengeance  and  furious  anger  those  who   would  attempt  to  poison  and  destroy  My  brothers.  And   you  will  know  My  name  is  the  Lord  when  I  lay  My   vengeance  upon  thee.   ! My  money's  in  that  office,  right?  If  she  start  giving   me  some  bullshit  about  it  ain't  there,  and  we  got  to  go   someplace  else  and  get  it,  I'm  gonna  shoot  you  in  the   head  then  and  there.  Then  I'm  gonna  shoot  that  bitch  in   the  kneecaps,  find  out  where  my  goddamn  money  is.  She   gonna  tell  me  too.  Hey,  look  at  me  when  I'm  talking  to   you,  motherfucker.  You  listen:  we  go  in  there,  and  that   nigga  Winston  or  anybody  else  is  in  there,  you  the   first  motherfucker  to  get  shot.  You  understand?   ! Look,  just  because  I  don't  be  givin'  no  man  a  foot   massage  don't  make  it  right  for  Marsellus  to  throw   Antwone  into  a  glass  motherfuckin'  house,  fuckin'  up   the  way  the  nigger  talks.  Motherfucker  do  that  shit  to   me,  he  better  paralyze  my  ass,  'cause  I'll  kill  the   motherfucker,  know  what  I'm  sayin’?   ! Well,  the  way  they  make  shows  is,  they  make  one  show.   That  show's  called  a  pilot.  Then  they  show  that  show  to   the  people  who  make  shows,  and  on  the  strength  of  that   one  show  they  decide  if  they're  going  to  make  more   shows.  Some  pilots  get  picked  and  become  television   programs.  Some  don't,  become  nothing.  She  starred  in   one  of  the  ones  that  became  nothing. ! ! ! ! ! ! ! body.source(); Socket HTTP/1.1  200  OK   Date:  Thu,  9  Apr  2015  15:14:34  GMT   Server:  JakeWharton/2.3.7  (Human)   Content-­‐Type:  application/presentation;  charset=UTF-­‐8   Content-­‐Length:  3000 FixedLengthSource

Slide 206

Slide 206 text

OkHttp HTTP/1.1  200  OK   Date:  Thu,  9  Apr  2015  15:14:34  GMT   Server:  JakeWharton/2.3.7  (Human)   Content-­‐Type:  application/presentation;  charset=UTF-­‐8   Content-­‐Encoding:  gzip   Content-­‐Length:  3000   ! You  think  water  moves  fast?  You  should  see  ice.  It   moves  like  it  has  a  mind.  Like  it  knows  it  killed  the   world  once  and  got  a  taste  for  murder.  After  the   avalanche,  it  took  us  a  week  to  climb  out.  Now,  I  don't   know  exactly  when  we  turned  on  each  other,  but  I  know   that  seven  of  us  survived  the  slide...  and  only  five   made  it  out.  Now  we  took  an  oath,  that  I'm  breaking   now.  We  said  we'd  say  it  was  the  snow  that  killed  the   other  two,  but  it  wasn't.  Nature  is  lethal  but  it   doesn't  hold  a  candle  to  man.   ! Your  bones  don't  break,  mine  do.  That's  clear.  Your   cells  react  to  bacteria  and  viruses  differently  than   mine.  You  don't  get  sick,  I  do.  That's  also  clear.  But   for  some  reason,  you  and  I  react  the  exact  same  way  to   water.  We  swallow  it  too  fast,  we  choke.  We  get  some  in   our  lungs,  we  drown.  However  unreal  it  may  seem,  we  are   connected,  you  and  I.  We're  on  the  same  curve,  just  on   opposite  ends.   ! Normally,  both  your  asses  would  be  dead  as  fucking   fried  chicken,  but  you  happen  to  pull  this  shit  while   I'm  in  a  transitional  period  so  I  don't  wanna  kill  you,   I  wanna  help  you.  But  I  can't  give  you  this  case,  it   don't  belong  to  me.  Besides,  I've  already  been  through   too  much  shit  this  morning  over  this  case  to  hand  it   over  to  your  dumb  ass.   ! The  path  of  the  righteous  man  is  beset  on  all  sides  by   the  iniquities  of  the  selfish  and  the  tyranny  of  evil   men.  Blessed  is  he  who,  in  the  name  of  charity  and  good   will,  shepherds  the  weak  through  the  valley  of   darkness,  for  he  is  truly  his  brother's  keeper  and  the   finder  of  lost  children.  And  I  will  strike  down  upon   thee  with  great  vengeance  and  furious  anger  those  who   would  attempt  to  poison  and  destroy  My  brothers.  And   you  will  know  My  name  is  the  Lord  when  I  lay  My   vengeance  upon  thee.   ! My  money's  in  that  office,  right?  If  she  start  giving   me  some  bullshit  about  it  ain't  there,  and  we  got  to  go   someplace  else  and  get  it,  I'm  gonna  shoot  you  in  the   head  then  and  there.  Then  I'm  gonna  shoot  that  bitch  in   the  kneecaps,  find  out  where  my  goddamn  money  is.  She   gonna  tell  me  too.  Hey,  look  at  me  when  I'm  talking  to   you,  motherfucker.  You  listen:  we  go  in  there,  and  that   nigga  Winston  or  anybody  else  is  in  there,  you  the   first  motherfucker  to  get  shot.  You  understand?   ! Look,  just  because  I  don't  be  givin'  no  man  a  foot   massage  don't  make  it  right  for  Marsellus  to  throw   Antwone  into  a  glass  motherfuckin'  house,  fuckin'  up   the  way  the  nigger  talks.  Motherfucker  do  that  shit  to   me,  he  better  paralyze  my  ass,  'cause  I'll  kill  the   motherfucker,  know  what  I'm  sayin’?   ! Well,  the  way  they  make  shows  is,  they  make  one  show.   That  show's  called  a  pilot.  Then  they  show  that  show  to   the  people  who  make  shows,  and  on  the  strength  of  that   one  show  they  decide  if  they're  going  to  make  more   shows.  Some  pilots  get  picked  and  become  television   programs.  Some  don't,  become  nothing.  She  starred  in   one  of  the  ones  that  became  nothing. ! ! ! ! ! ! ! body.source(); Socket HTTP/1.1  200  OK   Date:  Thu,  9  Apr  2015  15:14:34  GMT   Server:  JakeWharton/2.3.7  (Human)   Content-­‐Type:  application/presentation;  charset=UTF-­‐8   Content-­‐Encoding:  gzip   Content-­‐Length:  3000 GzipSource FixedLengthSource

Slide 207

Slide 207 text

OkHttp HTTP/1.1  200  OK   Date:  Thu,  9  Apr  2015  15:14:34  GMT   Server:  JakeWharton/2.3.7  (Human)   Content-­‐Type:  application/presentation;  charset=UTF-­‐8   Transfer-­‐Encoding:  chunked   ! 1F6   You  think  water  moves  fast?  You  should  see  ice.  It   moves  like  it  has  a  mind.  Like  it  knows  it  killed  the   world  once  and  got  a  taste  for  murder.  After  the   avalanche,  it  took  us  a  week  to  climb  out.  Now,  I  don't   know  exactly  when  we  turned  on  each  other,  but  I  know   that  seven  of  us  survived  the  slide...  and  only  five   made  it  out.  Now  we  took  an  oath,  that  I'm  breaking   now.  We  said  we'd  say  it  was  the  snow  that  killed  the   other  two,  but  it  wasn't.  Nature  is  lethal  but  it   doesn't  hold  a  candle  to  man.   ! 18C   Your  bones  don't  break,  mine  do.  That's  clear.  Your   cells  react  to  bacteria  and  viruses  differently  than   mine.  You  don't  get  sick,  I  do.  That's  also  clear.  But   for  some  reason,  you  and  I  react  the  exact  same  way  to   water.  We  swallow  it  too  fast,  we  choke.  We  get  some  in   our  lungs,  we  drown.  However  unreal  it  may  seem,  we  are   connected,  you  and  I.  We're  on  the  same  curve,  just  on   opposite  ends.   ! 158   Normally,  both  your  asses  would  be  dead  as  fucking   fried  chicken,  but  you  happen  to  pull  this  shit  while   I'm  in  a  transitional  period  so  I  don't  wanna  kill  you,   I  wanna  help  you.  But  I  can't  give  you  this  case,  it   don't  belong  to  me.  Besides,  I've  already  been  through   too  much  shit  this  morning  over  this  case  to  hand  it   over  to  your  dumb  ass.   ! 1EF   The  path  of  the  righteous  man  is  beset  on  all  sides  by   the  iniquities  of  the  selfish  and  the  tyranny  of  evil   men.  Blessed  is  he  who,  in  the  name  of  charity  and  good   will,  shepherds  the  weak  through  the  valley  of   darkness,  for  he  is  truly  his  brother's  keeper  and  the   finder  of  lost  children.  And  I  will  strike  down  upon   thee  with  great  vengeance  and  furious  anger  those  who   would  attempt  to  poison  and  destroy  My  brothers.  And   you  will  know  My  name  is  the  Lord  when  I  lay  My   vengeance  upon  thee.   ! 1E3   My  money's  in  that  office,  right?  If  she  start  giving   me  some  bullshit  about  it  ain't  there,  and  we  got  to  go   someplace  else  and  get  it,  I'm  gonna  shoot  you  in  the   head  then  and  there.  Then  I'm  gonna  shoot  that  bitch  in   the  kneecaps,  find  out  where  my  goddamn  money  is.  She   gonna  tell  me  too.  Hey,  look  at  me  when  I'm  talking  to   you,  motherfucker.  You  listen:  we  go  in  there,  and  that   nigga  Winston  or  anybody  else  is  in  there,  you  the   first  motherfucker  to  get  shot.  You  understand?   ! 12B   Look,  just  because  I  don't  be  givin'  no  man  a  foot   massage  don't  make  it  right  for  Marsellus  to  throw   Antwone  into  a  glass  motherfuckin'  house,  fuckin'  up   the  way  the  nigger  talks.  Motherfucker  do  that  shit  to   me,  he  better  paralyze  my  ass,  'cause  I'll  kill  the   motherfucker,  know  what  I'm  sayin’?   ! 165   Well,  the  way  they  make  shows  is,  they  make  one  show.   That  show's  called  a  pilot.  Then  they  show  that  show  to   the  people  who  make  shows,  and  on  the  strength  of  that   one  show  they  decide  if  they're  going  to  make  more   shows.  Some  pilots  get  picked  and  become  television   programs.  Some  don't,  become  nothing.  She  starred  in   one  of  the  ones  that  became  nothing. ! ! ! ! ! ! ! body.source(); Socket HTTP/1.1  200  OK   Date:  Thu,  9  Apr  2015  15:14:34  GMT   Server:  JakeWharton/2.3.7  (Human)   Content-­‐Type:  application/presentation;  charset=UTF-­‐8   Transfer-­‐Encoding:  chunked ChunkedSource

Slide 208

Slide 208 text

OkHttp HTTP/1.1  200  OK   Date:  Thu,  9  Apr  2015  15:14:34  GMT   Server:  JakeWharton/2.3.7  (Human)   Content-­‐Type:  application/presentation;  charset=UTF-­‐8   Transfer-­‐Encoding:  chunked   ! 1F6   You  think  water  moves  fast?  You  should  see  ice.  It   moves  like  it  has  a  mind.  Like  it  knows  it  killed  the   world  once  and  got  a  taste  for  murder.  After  the   avalanche,  it  took  us  a  week  to  climb  out.  Now,  I  don't   know  exactly  when  we  turned  on  each  other,  but  I  know   that  seven  of  us  survived  the  slide...  and  only  five   made  it  out.  Now  we  took  an  oath,  that  I'm  breaking   now.  We  said  we'd  say  it  was  the  snow  that  killed  the   other  two,  but  it  wasn't.  Nature  is  lethal  but  it   doesn't  hold  a  candle  to  man.   ! 18C   Your  bones  don't  break,  mine  do.  That's  clear.  Your   cells  react  to  bacteria  and  viruses  differently  than   mine.  You  don't  get  sick,  I  do.  That's  also  clear.  But   for  some  reason,  you  and  I  react  the  exact  same  way  to   water.  We  swallow  it  too  fast,  we  choke.  We  get  some  in   our  lungs,  we  drown.  However  unreal  it  may  seem,  we  are   connected,  you  and  I.  We're  on  the  same  curve,  just  on   opposite  ends.   ! 158   Normally,  both  your  asses  would  be  dead  as  fucking   fried  chicken,  but  you  happen  to  pull  this  shit  while   I'm  in  a  transitional  period  so  I  don't  wanna  kill  you,   I  wanna  help  you.  But  I  can't  give  you  this  case,  it   don't  belong  to  me.  Besides,  I've  already  been  through   too  much  shit  this  morning  over  this  case  to  hand  it   over  to  your  dumb  ass.   ! 1EF   The  path  of  the  righteous  man  is  beset  on  all  sides  by   the  iniquities  of  the  selfish  and  the  tyranny  of  evil   men.  Blessed  is  he  who,  in  the  name  of  charity  and  good   will,  shepherds  the  weak  through  the  valley  of   darkness,  for  he  is  truly  his  brother's  keeper  and  the   finder  of  lost  children.  And  I  will  strike  down  upon   thee  with  great  vengeance  and  furious  anger  those  who   would  attempt  to  poison  and  destroy  My  brothers.  And   you  will  know  My  name  is  the  Lord  when  I  lay  My   vengeance  upon  thee.   ! 1E3   My  money's  in  that  office,  right?  If  she  start  giving   me  some  bullshit  about  it  ain't  there,  and  we  got  to  go   someplace  else  and  get  it,  I'm  gonna  shoot  you  in  the   head  then  and  there.  Then  I'm  gonna  shoot  that  bitch  in   the  kneecaps,  find  out  where  my  goddamn  money  is.  She   gonna  tell  me  too.  Hey,  look  at  me  when  I'm  talking  to   you,  motherfucker.  You  listen:  we  go  in  there,  and  that   nigga  Winston  or  anybody  else  is  in  there,  you  the   first  motherfucker  to  get  shot.  You  understand?   ! 12B   Look,  just  because  I  don't  be  givin'  no  man  a  foot   massage  don't  make  it  right  for  Marsellus  to  throw   Antwone  into  a  glass  motherfuckin'  house,  fuckin'  up   the  way  the  nigger  talks.  Motherfucker  do  that  shit  to   me,  he  better  paralyze  my  ass,  'cause  I'll  kill  the   motherfucker,  know  what  I'm  sayin’?   ! 165   Well,  the  way  they  make  shows  is,  they  make  one  show.   That  show's  called  a  pilot.  Then  they  show  that  show  to   the  people  who  make  shows,  and  on  the  strength  of  that   one  show  they  decide  if  they're  going  to  make  more   shows.  Some  pilots  get  picked  and  become  television   programs.  Some  don't,  become  nothing.  She  starred  in   one  of  the  ones  that  became  nothing. ! ! ! ! ! ! ! body.source(); Socket HTTP/1.1  200  OK   Date:  Thu,  9  Apr  2015  15:14:34  GMT   Server:  JakeWharton/2.3.7  (Human)   Content-­‐Type:  application/presentation;  charset=UTF-­‐8   Transfer-­‐Encoding:  chunked ChunkedSource

Slide 209

Slide 209 text

OkHttp Socket HTTP/2

Slide 210

Slide 210 text

OkHttp Socket HTTP/2

Slide 211

Slide 211 text

OkHttp Socket FramedSource FramedSource HTTP/2

Slide 212

Slide 212 text

OkHttp Socket FixedLengthSource FramedSource FramedSource FixedLengthSource HTTP/2

Slide 213

Slide 213 text

OkHttp body1.source(); Socket FixedLengthSource FramedSource FramedSource FixedLengthSource body2.source(); HTTP/2

Slide 214

Slide 214 text

Moshi

Slide 215

Slide 215 text

Moshi • JsonReader / JsonWriter for streaming

Slide 216

Slide 216 text

Moshi Sink sink = //...
 JsonWriter writer = new JsonWriter(sink);

Slide 217

Slide 217 text

Moshi Sink sink = //...
 JsonWriter writer = new JsonWriter(sink);
 writer.beginObject(); {

Slide 218

Slide 218 text

Moshi Sink sink = //...
 JsonWriter writer = new JsonWriter(sink);
 writer.beginObject();
 writer.name("title")
 .value("A Few 'Ok' Libraries"); {      "title":  "A  Few  'Ok'  Libraries"

Slide 219

Slide 219 text

Moshi Sink sink = //...
 JsonWriter writer = new JsonWriter(sink);
 writer.beginObject();
 writer.name("title")
 .value("A Few 'Ok' Libraries");
 writer.name("presenter")
 .value("Jake Wharton"); {      "title":  "A  Few  'Ok'  Libraries",      "presenter":  "Jake  Wharton"

Slide 220

Slide 220 text

Moshi Sink sink = //...
 JsonWriter writer = new JsonWriter(sink);
 writer.beginObject();
 writer.name("title")
 .value("A Few 'Ok' Libraries");
 writer.name("presenter")
 .value("Jake Wharton");
 writer.name("tags")
 .beginArray(); {      "title":  "A  Few  'Ok'  Libraries",      "presenter":  "Jake  Wharton",      "tags":  [

Slide 221

Slide 221 text

Moshi Sink sink = //...
 JsonWriter writer = new JsonWriter(sink);
 writer.beginObject();
 writer.name("title")
 .value("A Few 'Ok' Libraries");
 writer.name("presenter")
 .value("Jake Wharton");
 writer.name("tags")
 .beginArray()
 .value("Okio")
 .value("OkHttp")
 .value("Moshi")
 .value("Retrofit"); {      "title":  "A  Few  'Ok'  Libraries",      "presenter":  "Jake  Wharton",      "tags":  [          "Okio",          "OkHttp",          "Moshi",          "Retrofit

Slide 222

Slide 222 text

Moshi Sink sink = //...
 JsonWriter writer = new JsonWriter(sink);
 writer.beginObject();
 writer.name("title")
 .value("A Few 'Ok' Libraries");
 writer.name("presenter")
 .value("Jake Wharton");
 writer.name("tags")
 .beginArray()
 .value("Okio")
 .value("OkHttp")
 .value("Moshi")
 .value("Retrofit")
 .endArray(); {      "title":  "A  Few  'Ok'  Libraries",      "presenter":  "Jake  Wharton",      "tags":  [          "Okio",          "OkHttp",          "Moshi",          "Retrofit      ]

Slide 223

Slide 223 text

Moshi Sink sink = //...
 JsonWriter writer = new JsonWriter(sink);
 writer.beginObject();
 writer.name("title")
 .value("A Few 'Ok' Libraries");
 writer.name("presenter")
 .value("Jake Wharton");
 writer.name("tags")
 .beginArray()
 .value("Okio")
 .value("OkHttp")
 .value("Moshi")
 .value("Retrofit")
 .endArray();
 writer.endObject(); {      "title":  "A  Few  'Ok'  Libraries",      "presenter":  "Jake  Wharton",      "tags":  [          "Okio",          "OkHttp",          "Moshi",          "Retrofit      ]   }

Slide 224

Slide 224 text

Moshi Sink sink = //...
 JsonWriter writer = new JsonWriter(sink);
 writer.beginObject();
 writer.name("title")
 .value("A Few 'Ok' Libraries");
 writer.name("presenter")
 .value("Jake Wharton");
 writer.name("tags")
 .beginArray()
 .value("Okio")
 .value("OkHttp")
 .value("Moshi")
 .value("Retrofit")
 .endArray();
 writer.endObject(); 
 writer.close(); {  X      "title":  "A  Few  'Ok'  Libraries",      "presenter":  "Jake  Wharton",      "tags":  [          "Okio",          "OkHttp",          "Moshi",          "Retrofit      ]  Y   }  Z

Slide 225

Slide 225 text

Moshi Sink sink = //...
 JsonWriter writer = new JsonWriter(sink);
 writer.beginObject();
 writer.name("title")
 .value("A Few 'Ok' Libraries");
 writer.name("presenter")
 .value("Jake Wharton");
 writer.name("tags")
 .beginArray()
 .value("Okio")
 .value("OkHttp")
 .value("Moshi")
 .value("Retrofit")
 .endArray();
 writer.endObject(); 
 writer.close(); Sink sink = //...
 BufferedSink s = Okio.buffer(sink); 
 s.writeByte('{');
 s.writeByte('"').writeUtf8("title").writeByte('"');
 s.writeByte(':').writeByte('"')
 .writeUtf8("A Few 'Ok' Libraries")
 .writeByte('"');
 s.writeByte(',');
 s.writeByte('"').writeUtf8("presenter").writeByte('"');
 s.writeByte(':').writeByte('"')
 .writeUtf8("Jake Wharton")
 .writeByte('"');
 s.writeByte(',');
 s.writeByte('"').writeUtf8("tags").writeByte('"');
 s.writeByte(':').writeByte('[');
 s.writeByte('"').writeUtf8("Okio").writeByte('"');
 s.writeByte(','); s.writeByte('"').writeUtf8("OkHttp").writeByte('"');
 s.writeByte(','); s.writeByte('"').writeUtf8("Moshi").writeByte('"');
 s.writeByte(','); s.writeByte('"').writeUtf8("Retrofit").writeByte('"');
 s.writeByte(']');
 s.writeByte('}');
 s.close();

Slide 226

Slide 226 text

Moshi Sink sink = //...
 JsonWriter writer = new JsonWriter(sink);
 writer.beginObject();
 writer.name("title")
 .value("A Few 'Ok' Libraries");
 writer.name("presenter")
 .value("Jake Wharton");
 writer.name("tags")
 .beginArray()
 .value("Okio")
 .value("OkHttp")
 .value("Moshi")
 .value("Retrofit")
 .endArray();
 writer.endObject(); 
 writer.close(); {X      "title":  "A  Few  'Ok'  Libraries",      "presenter":  "Jake  Wharton",      "tags":  [X          "Okio",          "OkHttp",          "Moshi",          "Retrofit      ]X   }X

Slide 227

Slide 227 text

Moshi Source source = //...
 JsonReader reader = new JsonReader(source); {X      "title":  "A  Few  'Ok'  Libraries",      "presenter":  "Jake  Wharton",      "tags":  [          "Okio",          "OkHttp",          "Moshi",          "Retrofit      ]X   }X

Slide 228

Slide 228 text

Moshi Source source = //...
 JsonReader reader = new JsonReader(source);
 
 reader.beginObject();
 while (reader.peek() != Token.END_OBJECT) {
 switch (reader.nextName()) {
 case "title":
 String title = reader.nextString();
 // TODO do something with 'title'...
 break;
 case "presenter":
 String presenter = reader.nextString();
 // TODO do something with 'presenter'...
 break;
 case "tags":
 reader.beginArray();
 Set tags = new LinkedHashSet<>();
 while (reader.peek() != Token.END_ARRAY) {
 tags.add(reader.nextString());
 }
 reader.endArray();
 // TODO do something with 'tags'...
 break;
 default: break; // Ignored
 }
 }
 reader.endObject();
 reader.close(); {X      "title":  "A  Few  'Ok'  Libraries",      "presenter":  "Jake  Wharton",      "tags":  [          "Okio",          "OkHttp",          "Moshi",          "Retrofit      ]X   }X

Slide 229

Slide 229 text

Moshi Source source = //...
 JsonReader reader = new JsonReader(source);
 
 reader.beginObject();
 while (reader.peek() != Token.END_OBJECT) {
 switch (reader.nextName()) {
 case "title":
 String title = reader.nextString();
 // TODO do something with 'title'...
 break;
 case "presenter":
 String presenter = reader.nextString();
 // TODO do something with 'presenter'...
 break;
 case "tags":
 reader.beginArray();
 Set tags = new LinkedHashSet<>();
 while (reader.peek() != Token.END_ARRAY) {
 tags.add(reader.nextString());
 }
 reader.endArray();
 // TODO do something with 'tags'...
 break;
 default: break; // Ignored
 }
 }
 reader.endObject();
 reader.close(); static final ByteString DOUBLE_QUOTE = ByteString.encodeUtf8("\"");
 
 long i = s.indexOfElement(DOUBLE_QUOTE);
 String string = s.readUtf8(i);

Slide 230

Slide 230 text

Moshi • JsonReader / JsonWriter for streaming

Slide 231

Slide 231 text

Moshi • JsonReader / JsonWriter for streaming • JsonAdapter for object mapping

Slide 232

Slide 232 text

Moshi {X      "title":  "A  Few  'Ok'  Libraries",      "presenter":  "Jake  Wharton",      "tags":  [X          "Okio",          "OkHttp",          "Moshi",          "Retrofit      ]X   }X

Slide 233

Slide 233 text

Moshi {X      "title":  "A  Few  'Ok'  Libraries",      "presenter":  "Jake  Wharton",      "tags":  [X          "Okio",          "OkHttp",          "Moshi",          "Retrofit      ]X   }X class Presentation {
 String title;
 String presenter;
 Set tags;
 }

Slide 234

Slide 234 text

Moshi {X      "title":  "A  Few  'Ok'  Libraries",      "presenter":  "Jake  Wharton",      "tags":  [X          "Okio",          "OkHttp",          "Moshi",          "Retrofit      ]X   }X class Presentation {
 String title;
 String presenter;
 Set tags;
 } JsonAdapter adapter = moshi.adapter(Presentation.class); 
 Presentation presentation = adapter.fromJson(source);

Slide 235

Slide 235 text

Retrofit

Slide 236

Slide 236 text

Retrofit interface DroidconMtl {
 @GET("/a-few-ok-libraries.json")
 Presentation okLibraries();
 }

Slide 237

Slide 237 text

Retrofit interface DroidconMtl {
 @GET("/a-few-ok-libraries.json")
 Presentation okLibraries();
 } class Presentation {
 String title;
 String presenter;
 Set tags;
 }

Slide 238

Slide 238 text

Retrofit interface DroidconMtl {
 @GET("/a-few-ok-libraries.json")
 Presentation okLibraries();
 } RestAdapter ra = new RestAdapter.Builder()
 .setEndpoint("http://droidcon.ca")
 .build();

Slide 239

Slide 239 text

Retrofit interface DroidconMtl {
 @GET("/a-few-ok-libraries.json")
 Presentation okLibraries();
 } RestAdapter ra = new RestAdapter.Builder()
 .setEndpoint("http://droidcon.ca")
 .build(); 
 
 
 
 DroidconMtl droidconMtl = ra.create(DroidconMtl.class);

Slide 240

Slide 240 text

Retrofit interface DroidconMtl {
 @GET("/a-few-ok-libraries.json")
 Presentation okLibraries();
 } RestAdapter ra = new RestAdapter.Builder()
 .setEndpoint("http://droidcon.ca")
 .build(); 
 
 
 
 DroidconMtl droidconMtl = ra.create(DroidconMtl.class); 
 
 
 ! 
 Presentation ok = droidconMtl.okLibraries();

Slide 241

Slide 241 text

Retrofit RestAdapter ra = new RestAdapter.Builder()
 .setEndpoint("http://droidcon.ca")
 .build();

Slide 242

Slide 242 text

Retrofit RestAdapter ra = new RestAdapter.Builder()
 .setEndpoint("http://droidcon.ca")
 .setClient(new OkHttpClient())
 .build();

Slide 243

Slide 243 text

Retrofit RestAdapter ra = new RestAdapter.Builder()
 .setEndpoint("http://droidcon.ca")
 .setClient(new OkHttpClient())
 .setConverter(new MoshiConverter())
 .build();

Slide 244

Slide 244 text

Retrofit

Slide 245

Slide 245 text

Retrofit OkHttp

Slide 246

Slide 246 text

Retrofit OkHttp Socket

Slide 247

Slide 247 text

Retrofit OkHttp FixedLengthSource FixedLengthSink Socket

Slide 248

Slide 248 text

Retrofit OkHttp FixedLengthSource FixedLengthSink RequestBody ResponseBody Socket

Slide 249

Slide 249 text

Retrofit OkHttp MoshiConverter FixedLengthSource FixedLengthSink RequestBody ResponseBody Socket

Slide 250

Slide 250 text

Retrofit OkHttp MoshiConverter FixedLengthSource FixedLengthSink RequestBody ResponseBody Socket Moshi

Slide 251

Slide 251 text

Retrofit OkHttp MoshiConverter FixedLengthSource FixedLengthSink RequestBody ResponseBody Socket Moshi BufferedSink BufferedSource

Slide 252

Slide 252 text

Retrofit OkHttp MoshiConverter FixedLengthSource FixedLengthSink RequestBody ResponseBody RequestBody ResponseBody Socket Moshi BufferedSink BufferedSource

Slide 253

Slide 253 text

Retrofit OkHttp MoshiConverter FixedLengthSource FixedLengthSink RequestBody ResponseBody DroidconMtl RequestBody ResponseBody Socket Moshi BufferedSink BufferedSource

Slide 254

Slide 254 text

Retrofit OkHttp MoshiConverter FixedLengthSource FixedLengthSink RequestBody ResponseBody DroidconMtl RequestBody ResponseBody Socket okLibraries() Moshi BufferedSink BufferedSource

Slide 255

Slide 255 text

Retrofit OkHttp MoshiConverter FixedLengthSource FixedLengthSink RequestBody ResponseBody DroidconMtl RequestBody ResponseBody Socket execute() okLibraries() Moshi BufferedSink BufferedSource

Slide 256

Slide 256 text

Retrofit OkHttp MoshiConverter FixedLengthSource FixedLengthSink RequestBody ResponseBody DroidconMtl RequestBody ResponseBody Socket execute() okLibraries() Moshi BufferedSink BufferedSource

Slide 257

Slide 257 text

Retrofit OkHttp MoshiConverter FixedLengthSource FixedLengthSink RequestBody ResponseBody DroidconMtl RequestBody ResponseBody Socket execute() okLibraries() Moshi BufferedSink BufferedSource

Slide 258

Slide 258 text

Retrofit OkHttp MoshiConverter FixedLengthSource FixedLengthSink RequestBody ResponseBody DroidconMtl RequestBody ResponseBody Socket execute() okLibraries() Moshi BufferedSink BufferedSource

Slide 259

Slide 259 text

Retrofit OkHttp MoshiConverter FixedLengthSource FixedLengthSink RequestBody ResponseBody DroidconMtl RequestBody ResponseBody Socket execute() okLibraries() Moshi BufferedSink BufferedSource

Slide 260

Slide 260 text

okio okhttp moshi retrofit

Slide 261

Slide 261 text

A Few “OK” Libraries

Slide 262

Slide 262 text

A Few “OK” Libraries jakewharton jakewharton jakewharton twitter.com/ google.com/+ .com