16. 16
The Gradle Path
Grab some of Cedric's projects
Add what you need and build it
Import to AS
17. 17
Gradle
Hey is Groovy!!
Less verbose than Maven
Is code not XML
Polyglot
Same build tool for different languages
At some point it should set you free from any IDE
25. 25
He swore he would never...
How can avoid repeating
the whole process again ?
26. 26
Wish list
Basic working Groovy skeleton
Basic helpful dependencies to make my life less miserable
Add Asciidoctor :)
Add whatever you want...
27. 27
Lazybones
What's lazybones
A simple project creation tool that uses packaged project
templates.
Created by: Peter Leedbrook
https://github.com/pledbrook/lazybones
28. 28
Lazybones
With lazy bones he could:
Basic working Groovy skeleton...
DONE
Basic dependencies to make my life less miserable...
Add Asciidoctor...
Add whatever you want...
DONE
DONE
30. 30
Groovy by default
At the beginning everything looked like Java:
31. 31
Groovy by default
But even then if you looked a little bit closer...
Some Groovy basic AST transformations saved precious lines
Get rid of accessors
32. 32
Groovy by default
Bean construction:
Using map constructor:
33. 33
Groovy collections and more...
Collections were more fun
Filtering and mapping (find/collect)
34. 34
Closures
Turn functional interfaces to functions (I):
Whenever you have to implement an interface with just one method you can
use a closure
35. 35
Closures
Turn functional interfaces to functions (II):
Whenever you have to implement an interface with just one method you can
use a closure
36. 36
Closures - Fn
Currying and MethodClosure:
Plain Java methods can become high order functions
38. 38
Traits
Traits:
Sometimes you have to extend different clases but still want to share some
common behavior. (Activities/ListActivity)
There are red lines
because Android Studio
doesn't recognize
Traits...yet
39. 39
AST Transformations
ASTs:
Anytime you fill there is boilerplate code there is work for an AST to do
You can create your own
@ASTTest
@AnnotationCollector
@AutoClone
@AutoExternalize
@Canonical
@ConditionalInterrupt
@EqualsAndHashcode
@Field
@Immutable
@IndexedProperty
@InheritConstructors
@Memoized
@Sortable
@TailRecursive
@ThreadInterrupt
@Trait
@ToString
@TupleConstructor
@TypeChecked
@Log
@Log4j
Still a few more
40. 40
SwissKnife
A multi-purpose Groovy library containing view injection and threading for
Android using annotations. It's based on both ButterKnife and
AndroidAnnotations
42. 42
SwissKnife
@OnBackground and @UIThread
@OnBackground
Creates an async task
@UIThread
It gets a handler instance to run the body in the UI thread
44. 44
SwissKnife
@OnClick, @OnItemSelected...
There are several other annotations for annotating methods you want to be
triggered when an event occurs
45. 45
Grooid-tools
A DSL for generating views with Groovy
https://github.com/karfunkel/grooid-tools
For example create a TextView
s
46. 46
What about performance ?
Faster, cleaner, cheaper...
47. 47
Performance
Before blaming the language you may want to check if the
problem is elsewhere ;)
48. 48
Performance
@CompileStatic:
It optimizes bytecode applying static check compilation
Sorry, I don't have benchmarks on Android
In the JDK we're doing well with InvokeDynamic
On Android is advisable to use it...what please don't freak
out !