|Android Support in Groovy 2.4|
|Written by Kay Ewbank|
|Thursday, 29 January 2015|
Groovy 2.4 has been released with support for Android and there is also an update to its multi-purpose library SwissKnife which handles view injection and threading for Android using annotations.
In addition to Android support, the Groovy team has also focused on improving the performance, memory consumption and reducing the bytecode generation.
Writing about the release on his blog, head developer Guillaume Laforge says that the Android support:
“allows developers to write Android applications fully using Groovy, with much less boilerplate code than raw Java”.
Other improvements that Laforge says are worth noting in this release include the fact that traits can use the @SelfType annotation with static type checking enabled to restrict to what classes traits can be applied.
Various GDK methods have been improved, including System.currentTimeSecond(), and List.getIndices(). Collection related methods have been moved to iterator-based variants to apply to all iterable collection types. Missing methods such as init(), dropRight(), and takeRight() have also been added.
There are some refinements to existing AST transformations, and more improvements to the Groovysh shell, including support for custom .rc and .profile scripts to be loaded on startup.
Fitting alongside the release of Groovy was an update to SwissKnife. This is a project that offers a number of Groovy code transformations that deal view injection and threading for Android using annotations.
The idea is that you leave SwissKnife to handle aspects such as handling UI and background threads and dealing with event handling, leaving you to concentrate on your own code. SwissKnife is based on both ButterKnife and AndroidAnnotations, and lets you inject views dynamically on any Object as long as you have a View to find them.
You can also add callback methods to several actions using @OnClick, @OnItemClick, etc; and execute methods in the UI Thread or a background one using @OnUIThread and @OnBackground. You can make your variables persistent across state changes without messing with onSaveInstanceState, and you can make anything Parcelable with the @Parcelable annotation - which can be used with @SaveInstance to automatize data persistence.
The release of Groovy 2.4 comes after Pivotal pulled out of funding Groovy and Grails, which means that the Groovy and Grails teams need to find new sponsors. In the meantime, while development on Groovy will continue, team members say they will only able to work on it in their spare time.
To be informed about new articles on I Programmer, install the I Programmer Toolbar, subscribe to the RSS feed, follow us on, Twitter, Facebook, Google+ or Linkedin, or sign up for our weekly newsletter.
or email your comment to: email@example.com
|Last Updated ( Sunday, 23 September 2018 )|