Droidcon Paris 2015 feedback

Droidcon Paris 2015 feedback

4ba9454c776e3d1b279fe373c1c18fb8?s=128

renaudboulard

December 01, 2015
Tweet

Transcript

  1. 9-10 novembre 2015

  2. • Gradle build • Android performance matters • Ingredient for

    a healthy code base • Barcamp • Trending Android
  3. None
  4. 1. Initialization Choose project(s) to build 2. Configuration Execute build.gradle

    Build task graph 3. Execution Execute task chain
  5. Subject application: Google IO app • 28 libraries • 53149

    method references
  6. • Configuration on Demand • Gradle Daemon • Newer versions

    of gradle • JVM 1.8 instead of 1.6 • Avoid expensive things during configuration phase • Don’t use dynamic dependencies (x.y.+)
  7. None
  8. Package cost : 1.297s Resource change cost: 0.939s Jave change

    cost 4.462s • dex : 3.766s • Javac : 0.876s
  9. small project dev { multiDexEnabled true minSdkVersion 21 } 4.633

    secs prod {} 6.599 secs Bigger prject dev { multiDexEnabled true minSdkVersion 21 } 4.416 secs prod { multiDexEnabled true minSdkVersion 15 } 20.703 secs
  10. Goals of a gradle plugin: • Create a gradle task

    that performs a custom task • Inject this task into the android task graph • Parametrize this task regarding the needs of the project • Package it and share it
  11. class MyCustomTask extends DefaultTask { @Input def String input; @Output

    def String output; @TaskAction def trigger() { // Do your stuff here } }
  12. public class MyPlugin implements Plugin<Project> { @Override void apply(Project project)

    { project.afterEvaluate ({ def myTask = project.tasks.create("mytask", MyCustomTask ); myTask.input = "doStuff" def jarTask = project.tasks.findByName("jar") jarTask.dependsOn(myTask); } }) }
  13. class MyTaskExtension { def String input = null; }

  14. public class MyPlugin implements Plugin<Project> { @Override void apply(Project project)

    { project.extensions.create("myExtension", MyTaskExtension) project.afterEvaluate ({ // ... myTask.input = project.myExtension.input // ... } }) }
  15. apply: "myPlugin" android { // ... } myExtension { input

    "doStuff" }
  16. None
  17. None
  18. • Static analysis tools – checkstyle – … • Google

    Play Store publishing • Groovy library for git • Dex count • Sqlite Analyzer Plugin • ...
  19. • Gradle performance: https://speakerdeck.com/madisp/squeezing- the-last-drop-of-performance-out-of-your-gradle-builds-droidcon- paris-2015 • Build your gradle

    plugin https://bit.ly/gradle-plugin-next-level • Improve android builds: https://speakerdeck.com/florianmski/level- up-your-android-build
  20. None
  21. • Networking is the main battery consumer – Less radio

    time means less data – Batching to minimize radio transmission – Prefetching by predicting what the user will do
  22. • GC events eats your app framerate – Reduce images

    size – Use primitives instead of objects – Keep an eye on your memory with management tools (AllocationTracker, TraceView)
  23. <RelativeLayout> <ImageView/> <LinearLayout> <TextView/> <TextView/> </LinearLayout> <ImageView/> <ImageView/> </RelativeLayout> <merge>

    <ImageView/> <TextView/> <TextView/> <ImageView/> <ImageView/> </merge> ->
  24. • Create your own scrolling container – Movement tracking –

    Inertia scrolling – Scrollbars drawing – Edge detection to get feedback
  25. Performance Matter - Ran Nachmany, Google https://youtu.be/04igNM9IpwE?list=PLn7H9CUCuXAv_kAdS0rxL1_jdxXp FVb0r ViewGroups -

    François Blavoet, Deezer https://youtu.be/MSTG0JPOrYk?list=PLn7H9CUCuXAv_kAdS0rxL1_jdxX pFVb0r Advanced Scrolling - Cyril Mottier, Captain Train https://youtu.be/N3J4ZFiR_3Q?list=PLn7H9CUCuXAv_kAdS0rxL1_jdxX pFVb0r
  26. None
  27. None
  28. DATA LAYER DOMAIN LAYER PRESENTER LAYER

  29. Retrofit client DB client ArtistRepository • Shared preferences • ContentProvider

    • BDD
  30. • Orchestrates the flow of data with use “cases” •

    Offers its services to presentation layer • Pure Java module • No Android UI dependencies • No dependency to external source (db,content provider, shared preferences…)
  31. ▸ public class Artist { String displayName; Date onTourUntil; String

    uri; String id; String url; String htmlUrl; String …; Object…; Object …; Object …; } public class ArtistViewModel { String name; boolean isOnTour; } VIEW MODEL PRESENTER VIEW
  32. public interface SearchPresenter { void searchUser(String searchItem); void clickUser(ArtistViewModel artist);

    } public interface SearchView { void showProgress(); void hideProgress(); void showUser(List<ArtistViewModel> artistes); } VIEW MODEL PRESENTER VIEW
  33. public class SearchFragment extends Fragment implements SearchView { private SearchPresenter

    searchPresenter; @Override public void showProgress() { //... } @Override public void hideProgress() { //... } @Override public void showUser(List<UserViewModel> users) { //... } }
  34. DATA LAYER DOMAIN LAYER PRESENTER LAYER OBSERVABLE<MODEL> OBSERVABLE<VIEWMODEL> SUBSCRIBER<VIEWMODEL>

  35. • Provides dependency: @Provides and @Module • Request dependency: @Inject

    • Link modules and injections: @Component • Implement the singleton pattern : @Singleton
  36. APPLICATION MODULE ACTIVITY MODULE FRAGMENT MODULE Repository Domain Activity Activity

    component Application component Presenter Use case
  37. DATA LAYER DOMAIN LAYER PRESENTER LAYER USER REPOSITORY SEARCH USED

    CASE SEARCH PRESENTER SEARCH FRAGMENT
  38. DATA LAYER DOMAIN LAYER PRESENTER LAYER .JSON

  39. • Choose an architecture and stick with it • Test

    while your code • Retrofit • Dagger 2 • Rx-java • Espresso • Junit
  40. • Clean Architecture : https://www.youtube.com/watch?v=- oZswd1j5H0 • Slide https://speakerdeck.com/romainpiel/ingredients-for-a-healthy- codebase

    • Presentation Dagger 2 : https://www.youtube.com/watch?v=IkTST564lA4 • slide Dagger 2 https://speakerdeck.com/jeremiemartinez/dagger-2- back-to-basics
  41. It’s a tool to : ▸ Enhance modularity ▸ Focus

    on business logic ▸ Reduce noise in the source code Occurs at compile time with byte code modification
  42. None
  43. None
  44. None
  45. • To minimize the code necessary to bind your logic

    and your view • Still in Beta • Support library API 7
  46. <data> <variable name="user" type="com.example.User"/> </data> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@{user.firstName}” />

  47. public class User { public final String firstName; public final

    String lastName; public User (String firstName, String lastName) { this.firstName = firstName; this.lastName = lastName; } }
  48. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MainActivityBinding binding =

    MainActivityBinding.inflate(getLayoutInflater()); User user = new User("Test", "User"); binding.setUser(user); }
  49. Le Data Binding sur Android - Guillaume Bernard, Koridev https://youtu.be/fG_93vUfm5s?list=PLn7H9CUCuXAv_kAdS0rxL1_jdxXpFV

    b0r Data Binding -- Write Apps Faster (Android Dev Summit 2015) https://youtu.be/NBbeQMOcnZ0
  50. • Android Emulator • Gives control on hardware features :

    – Control the battery level – GPS Location – Network and call management $
  51. None
  52. • Jack & Jill • Kotlin • Eddystone

  53. Java Android Compiler Kit Jack Intermediate Library Linker Goal is

    to improve incremental build More efficient to compile compared to javac + dex, but still experimental
  54. None
  55. The swift of Android ?

  56. Kotlin is compiled to Java bytecode Possibility to use both

    java and Kotlin in the same project
  57. Pros • Compile time detection of NPE with nullable type

    • Lambda • Type inference • Class extensions
  58. Cons • Overhead of 924 KB for runtime • Still

    in beta • Will it be adopted by the community ?
  59. Beacon • Autonomous • Cheap (15-20€) • Advertise data in

    a one way communication Eddystone Open beacon format
  60. 3 possible messages with Eddystone • UID – Beacon broadcast

    its unique identifier • URL – Beacon broadcast – Physical web – Short range and contactless QRCode • TLM (Telemetry) – Maintenance (battery level, …)
  61. None
  62. Evolution inside the android build system https://drive.google.com/file/d/0B1CCib0JzAOJRXZSY0c1ckZTU0E Kotlin for Android

    https://www.youtube.com/watch?v=50lASllvG3Q Eddystone https://www.youtube.com/watch?v=HR3X5h9xdno
  63. None
  64. ANDROID STUDIO 2.0

  65. USABILITY (GUI) GPS POINTS KML BATTERY PHONE CALL SMS ROTATION

    RESIZE DRAG-DROP FINGERPRINT