Slide 1

Slide 1 text

Open Source Android Libraries XII Jornadas SLCENT de Actualización Informática y Electrónica

Slide 2

Slide 2 text

About me José Juan Sánchez Hernández Android Developer (In my spare time :) Member and collaborator of: - Android Almería Developer Group - HackLab Almería @josejuansanchez 2

Slide 3

Slide 3 text

Who are you? 3 • How many Android developers are there in the room? • How many of you have used open source libraries in your projects?

Slide 4

Slide 4 text

This talk is based on the next talks/slides: 1. Can you work without open source libraries?
 Gabriele Mariotti. Droidcon Italy 2015. slides video 2. Android Library Love.
 Andrew Watson. DevFestMN 2015. slides video 3. Don't reinvent the wheel, use libraries.
 Pavel Junak. Droidcon Berlin 2015. slides video 6. A few small useful libraries. Victor Cassone. link
 
 
 4 Advertisement Thanks!

Slide 5

Slide 5 text

Agenda 1. How to evaluate a library? 2. Android Libraries you should know about 3. Demo time 4. References 5

Slide 6

Slide 6 text

Agenda 1. How to evaluate a library? 2. Android Libraries you should know about 3. Demo time 4. References 6

Slide 7

Slide 7 text

• Never choose the first library. • Read the README. • Pay attention to some important points: • License • Maintenance • Support • Documentation • Quality code 7 Before using open source libraries Reference [1]

Slide 8

Slide 8 text

• Check if the license under which the library is released. • Check if the license is compatible with your project. • Pay attention to legal issues. 8 License Reference [1] Can I use it?

Slide 9

Slide 9 text

• Open Source does not mean you are free to do anything you want with the library. • You have to respect the license. 9 What is Open Source? Reference [1] Open Source != Free

Slide 10

Slide 10 text

What do you know about the types of license? 10 Reference [1] Wait a moment, please!

Slide 11

Slide 11 text

11 http://choosealicense.com Demystified with <3 by GitHub, Inc.

Slide 12

Slide 12 text

12 The Free-Libre / Open Source Software (FLOSS) License Slide Reference [5]

Slide 13

Slide 13 text

13 http://protocoder.org

Slide 14

Slide 14 text

14

Slide 15

Slide 15 text

• Never choose the first library. • Read the README. • Pay attention to some important points: • License • Maintenance • Support • Documentation • Quality code 15 Before using open source libraries Reference [1]

Slide 16

Slide 16 text

• a company? • a community? • a single developer? 16 Maintenance Reference [1] Who is the author of this library?

Slide 17

Slide 17 text

• Checks the last commits in the repository. • Check how often the project is updated (or was updated). • If you use a library which is no longer maintained, you could have problems in the future. 17 Maintenance Reference [1] Is this library still alive?

Slide 18

Slide 18 text

18 Example: https://github.com/square/picasso

Slide 19

Slide 19 text

• Never choose the first library. • Read the README. • Pay attention to some important points: • License • Maintenance • Support • Documentation • Quality code 19 Before using open source libraries Reference [1]

Slide 20

Slide 20 text

• Evaluate what kind of support you can find using it. • Popular libraries have a tag (and a lot of posts) on stackoverflow. • Popular libraries have a G+ community or a very good issues section where to find a lot of comments and posts. 20 Support Reference [1] Can someone help me?

Slide 21

Slide 21 text

• Check how many issues are open. • Check how many issues were closed. • If you find 300 issues open and 1 issue closed is not a good evidence. 21 Issues Reference [1] Is someone fixing the issues?

Slide 22

Slide 22 text

22 Example: https://github.com/square/picasso

Slide 23

Slide 23 text

• Never choose the first library. • Read the README. • Pay attention to some important points: • License • Maintenance • Support • Documentation • Quality code 23 Before using open source libraries Reference [1]

Slide 24

Slide 24 text

Check if the library provides: • Doc / Wiki section. • A good README file. • Examples. • A demo in Google Play. 24 Documentation Reference [1] You can’t use the library without documentation!

Slide 25

Slide 25 text

25 Example: https://github.com/ReactiveX/RxJava

Slide 26

Slide 26 text

26 Example: https://github.com/ReactiveX/RxJava

Slide 27

Slide 27 text

• Never choose the first library. • Read the README. • Pay attention to some important points: • License • Maintenance • Support • Documentation • Quality code 27 Before using open source libraries Reference [1]

Slide 28

Slide 28 text

• The existence of Unit Tests is a good indicator of a serious project. • Check how it is written. • Check if the authors use comments, javadoc, 
 Clean Code, SOLID principles. 28 Quality code Reference [1] Is it good?

Slide 29

Slide 29 text

29

Slide 30

Slide 30 text

30 Integration jCenter or Maven Central?

Slide 31

Slide 31 text

31 Example:

Slide 32

Slide 32 text

Agenda 1. How to evaluate a library? 2. Android Libraries you should know about 3. Demo time 4. References 32

Slide 33

Slide 33 text

33 Butter Knife Author Jake Wharton License Apache 2.0 View "injection" library for Android https://github.com/JakeWharton/butterknife

Slide 34

Slide 34 text

• Uses annotation for code generation (no reflection). • Reduces boilerplate for view assignment. • Removes anonymous inner classes for listeners associated with views. • Simplifies resource lookups. 34 What does ButterKnife do? Reference [6]

Slide 35

Slide 35 text

Binding Views To Activities 35

Slide 36

Slide 36 text

36 Before Reference [6]

Slide 37

Slide 37 text

37 After Reference [6]

Slide 38

Slide 38 text

38 The issue Reference [6]

Slide 39

Slide 39 text

39 The ButterKnife way Reference [6]

Slide 40

Slide 40 text

Binding Listeners 40

Slide 41

Slide 41 text

41 Before Reference [6]

Slide 42

Slide 42 text

42 After Reference [6]

Slide 43

Slide 43 text

43 Using clicked view Reference [6]

Slide 44

Slide 44 text

44 Reference [6] Other listeners callbacks • @OnLongClick • @OnItemClick • @OnItemLongClick • @OnCheckedChanged • @OnFocusChange • @OnPageChange • @OnTextChange • @OnTouch

Slide 45

Slide 45 text

45 EventBus Author Greenrobot License Apache 2.0 Android optimized event bus that simplifies communication between Activities, Fragments, Threads, Services, etc. https://github.com/greenrobot/EventBus

Slide 46

Slide 46 text

• Developed by greenRobot. • Inspired by Guava’s EventBus. • Android optimized way to simplify communication in application. • Claims to have best performance. • There are other options (Otto, TinyBus, … etc). 46 About EventBus Reference [6]

Slide 47

Slide 47 text

47 EventBus in 4 steps 1. Define an event. 2. Register subscribers. 3. Post event. 4. Receive event. Reference [6]

Slide 48

Slide 48 text

48 1. Define an event Reference [6] • Event: the object that will be delivered. • POJO: Plain Old Java Object

Slide 49

Slide 49 text

49 2. Register subscribers Reference [6] Any object can receive events.

Slide 50

Slide 50 text

50 3. Post events Reference [6]

Slide 51

Slide 51 text

51 4. Receive events Reference [6] • Must have onEvent method or else crash. • Params must be something posted.

Slide 52

Slide 52 text

52 Picasso Author Square License Apache 2.0 A powerful image downloading and caching library for Android. https://github.com/square/picasso

Slide 53

Slide 53 text

• Developed by Square. • Never again: AsyncTask with HttpConnection downloading image. • Picasso allows image loading in your application, often in one line of code! 53 About Picasso Reference [3]

Slide 54

Slide 54 text

54 With Picasso Reference [3] Picasso .with(context) .load(url) .into(imageView);

Slide 55

Slide 55 text

55 Place Holders Reference [3] Picasso.with(context) .load(url) .placeholder(R.drawable.placeholder) .error(R.drawable.placeholder_error) .into(imageView); • Supports both download and error placeholders as optional features. • A request will be retried 3 times before the error placeholder is shown.

Slide 56

Slide 56 text

56 Image Transformations Reference [3] Picasso.with(context) .load(url) .resize(50, 50) .centerCrop() .into(imageView) • Transform images to better fit into layouts and to reduce memory size.

Slide 57

Slide 57 text

57 Retrofit Author Square License Apache 2.0 A type-safe REST client for Android which intelligently maps an API into a client interface using annotations. http://square.github.io/retrofit/

Slide 58

Slide 58 text

58 LeakCanary Author Square License Apache 2.0 A memory leak detection library for Android and Java. https://github.com/square/leakcanary

Slide 59

Slide 59 text

59 Other useful libraries… • RxAndroid • RxJava • Retrolambda • GSON • Timber • ion • okHttp • Dagger • SQLBrite • Sugar ORM • Realm • …

Slide 60

Slide 60 text

Agenda 1. How to evaluate a library? 2. Android Libraries you should know about 3. Demo time 4. References 60

Slide 61

Slide 61 text

Agenda 1. How to evaluate a library? 2. Android Libraries you should know about 3. Demo time 4. References 61

Slide 62

Slide 62 text

References / Talks 1. Can you work without open source libraries?
 Gabriele Mariotti. Droidcon Italy 2015. slides video 2. Android Library Love.
 Andrew Watson. DevFestMN 2015. slides video 3. Don't reinvent the wheel, use libraries.
 Pavel Junak. Droidcon Berlin 2015. slides video 
 
 62

Slide 63

Slide 63 text

References / Links 4. Choosing an open source license doesn’t need to be scary. GitHub, Inc. link 5. The Free-Libre / Open Source Software (FLOSS) License Slide. David A. Wheeler. 2007. link 6. A few small useful libraries. Victor Cassone. link 
 
 63

Slide 64

Slide 64 text

Open Source Android Libraries XII Jornadas SLCENT de Actualización Informática y Electrónica