Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Open Source Android Libraries

Open Source Android Libraries

Presentación utilizada en XII Jornadas SLCENT de Actualización Informática y Electrónica. 28 de Octubre de 2015, Almería.

http://hacklabalmeria.net/actividades/2015/10/28/xii-jornadas-slcent.html

Esta charla trata de ofrecer una visión general sobre licencias Open Source y librerías Open Source para Android.

More Decks by José Juan Sánchez Hernández

Other Decks in Programming

Transcript

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

    View Slide

  2. 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

    View Slide

  3. 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?

    View Slide

  4. 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!

    View Slide

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

    View Slide

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

    View Slide

  7. • 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]

    View Slide

  8. • 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?

    View Slide

  9. • 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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  13. 13
    http://protocoder.org

    View Slide

  14. 14

    View Slide

  15. • 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]

    View Slide

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

    View Slide

  17. • 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?

    View Slide

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

    View Slide

  19. • 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]

    View Slide

  20. • 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?

    View Slide

  21. • 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?

    View Slide

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

    View Slide

  23. • 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]

    View Slide

  24. 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!

    View Slide

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

    View Slide

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

    View Slide

  27. • 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]

    View Slide

  28. • 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?

    View Slide

  29. 29

    View Slide

  30. 30
    Integration
    jCenter or Maven Central?

    View Slide

  31. 31
    Example:

    View Slide

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

    View Slide

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

    View Slide

  34. • 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]

    View Slide

  35. Binding Views To Activities
    35

    View Slide

  36. 36
    Before
    Reference [6]

    View Slide

  37. 37
    After
    Reference [6]

    View Slide

  38. 38
    The issue
    Reference [6]

    View Slide

  39. 39
    The ButterKnife way
    Reference [6]

    View Slide

  40. Binding Listeners
    40

    View Slide

  41. 41
    Before
    Reference [6]

    View Slide

  42. 42
    After
    Reference [6]

    View Slide

  43. 43
    Using clicked view
    Reference [6]

    View Slide

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

    View Slide

  45. 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

    View Slide

  46. • 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]

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  50. 50
    3. Post events
    Reference [6]

    View Slide

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

    View Slide

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

    View Slide

  53. • 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]

    View Slide

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

    View Slide

  55. 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.

    View Slide

  56. 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.

    View Slide

  57. 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/

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  62. 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

    View Slide

  63. 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

    View Slide

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

    View Slide