Skip to content

Instantly share code, notes, and snippets.

@Struka9

Struka9/blog.md Secret

Created May 12, 2019 11:12
Show Gist options
  • Save Struka9/c1a67946990e9e443cdbeab87e4bad21 to your computer and use it in GitHub Desktop.
Save Struka9/c1a67946990e9e443cdbeab87e4bad21 to your computer and use it in GitHub Desktop.

What’s new in Android Dev?

What’s up guys? Another Google IO has passed and with it some exciting announcements for all the Android developers out there in terms of software and hardware. Here I list some of the changes and additions that I had the chance to check out at the IO and think are worth mention, if I’m missing anything let me know in the comments

Android Q

Technically, this was not an IO announcement since it has been around for some months already and many developers have been using it to test their apps, still it’s worth to mention as the next wave of features will come with this new Android version.

If you have a supported device and would like to try the version of Android before the others (you should be OK trying potential buggy features) you can visit the Android Beta Program site to enroll any of your supported devices.

Kotlin First!!

At the IO 2018 Kotlin was announced as an official supported language to build Android apps, way before that developers were already using it in detriment of Java for it’s concise and modern syntax, rich set of features and interoperability with other JVM languages right out of the box. Now Google has announced that “Android development will become increasingly Kotlin-first. Many new Jetpack APIs and features will be offered first in Kotlin”. So, it’s a good time to start using Kotlin if you hadn’t.

Jetpack Compose

Personally, I think is one of the most exciting features in the list as this is a potential game changer in terms of the development lifecycle itself. From the docs:

Jetpack Compose is an unbundled toolkit designed to simplify UI development. It combines a reactive programming model with the conciseness and ease of use of the Kotlin programming language.

This framework allows you to take advantage of Kotlin’s ability to write DSL to define all your UI right into your code in a beautiful and declarative way. You simply need to describe your UI as a set of Composable functions and the framework will handle the rest, even performing optimizations under the hood and automatic updates to the view hierarchy. A Compose application is made up from functions annotated with @Composable that define how the UI will look and behave: https://gist.github.com/f702b0401549d5b73e14547ee96f69fe

The above code will produce the following UI without a single line of XML layout written: ::INSERT GIF::

It’s worth to note that this is on really early stage of development but we will definitely keep an eye on Jetpack Compose.

CameraX

This is a Jetpack support library built on top of Camera2, it looks to provide a more consistent experience across most devices without the developer needing to write device-specific code, it uses a simpler, use case-based approach that is lifecycle-aware.

CameraX Extensions are optional add-ons that enable you to add effects like Portrait, HDR, Night, and Beauty within your application on supported devices .

ViewPager2

For years ViewPager has needed some improvements and now we are getting them in the form of totally new ViewPager built from scratch, it’s built on top of RecyclerView it has features as:

  • Right-to-Left (RTL) mode support
  • Vertical Paging
  • Improved dataset change notifications

ViewBindings

Say goodbye to findViewById, the idea behind ViewBinding is that you won’t need to clutter your codebase with boilerplate code just to get reference to your views or use an annotation processor to do the job. So instead the binding code will be generated from XML layouts directly at compile time and it will be null-safe and type-safe! Here is an example of how it would work:

search_item.xml https://gist.github.com/f34055cbc635492686735b3649919225

https://gist.github.com/08f66f6522c59a96c2d271c3cee0e092

With the given layout a SearchItemBinding class would be generated to inflate the XML and get the references, again it is type-safe so it knows that the correct type of packageName is TextView. No more boilerplate code to get the references or annotation processors slowing down your builds!

A lot of good stuff going on, I’m particularly excited about Jetpack Compose and want to see how it behaves on real world applications, but we will have to wait for a while before that. Let me know what are you looking forward to or if I’m missing something important.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment