trivago tech tips - #19 Android Edition
Five tips and tricks we use while working on our Android codebase!
Here are five tips and tricks we use while working on our Android codebase!
Tip 1
Use regions to separate sections of code in your Kotlin and xml files. This is useful for large files, it eases navigation and Intellij based IDEs have inbuilt support for this making it possible to view the regions from the structure tab.
Tip 2
Need to exclude a component from one of your builds? The tools:node="replace" attribute comes in handy. Add it to the component in the manifest for your respective build and it won’t be part of the merged app manifest.
Tip 3
Need to sort a list of custom objects based on one of their string fields for different locales? The Collator class and sortedBy extension function comes in handy for such scenarios.
Tip 4
Are you duplicating a lot of tests to cover different inputs? Well with JunitParams library you can have parameterized tests where one test runs against different set of inputs.
Tip 5
Grouping extension functions into their own individual files makes it easier for navigating through them when the project has a lot of extension functions as opposed to stacking all extension functions in one file e.g activity based extensions can live in an ActivityExtensions File.
We hope you enjoyed our 5 tips for Android development. Do you have some of your own tips to share that we missed? Let us know in the comments, we’d love to hear from you.