Recently, I started learning Kotlin for Android development, and I really enjoyed it. Kotlin syntax is very similar to Swift, and it is convenient. I'm just a newbie in Android development, so most likely there are still many useful libraries that I haven’t yet had the opportunity to learn, but this list is some of those that I have already successfully used or plan to do so soon.
Kovenant is a promise library (for simplified asynchronous programming) for Kotlin. I use PromiseKit in most of my iOS projects, so I wanted to find something similar for Android. Kovenant covers most of the functionality that I need (the only space I noticed is the absence of the equivalent function of recover
in PromiseKit), so it suits me.
If you need to handle the loading and display of images in the application, then using Picasso is very easy to do. In addition to asynchronous loading and caching of images, you can also transform them, for example:
Picasso.get().load(url).resize(50, 50).centerCrop().into(imageView)
I also use the picasso-transformations library, which adds additional transformations in Picasso, for example, cropping in the shape of a circle.
By the way, I recently learned that Google recommends Glide for working with images, not Picasso. I haven't used Glide yet, but considering that Google also recommends the Volley library for working with a network that has almost no documentation and which has some really strange bugs, I'm not sure how much I will trust this recommendation.
I have not used this Kotlin library yet, but it offers an easy way to add functionality to select a theme in your application. I will postpone it for now and use it in the future when I need this feature.
I saw how everything was said about Anko before I realized what she was and why everyone loves her. Anko is basically a set of convenient methods that will help make Android development at Kotlin easier and more intuitive.
There are some really wonderful things in it, such as this super-laconic method for creating and displaying toast messages:
toast("Hi there!")
And for SnackBar:
longSnackbar(view, "Wow, such duration")
It also greatly simplifies the creation of intents:
startActivity<SomeOtherActivity>("id" to 5)
There are also built-in convenient methods for popular intents, for examplebrowse(url)
and share(text, [subject])
.
Anko also offers beautiful DSL for creating a layout
, but I haven’t used this functionality yet. Here is an example from the documentation:
verticalLayout { val name = editText() button("Say Hello") { onClick { toast("Hello, ${name.text}!") } } }
There is a lot more that this library has to offer, so it is definitely worth your attention.
After I encountered unusual errors and a lack of documentation for Volley, I stumbled upon Fuel, which is now my favorite library for working with the network in Android.
Fuel uses lambda expressions, not listeners, to process responses. As an iOS developer, this seems more familiar to me. The library also works great with Kovenant if you want to wrap the promise of networking with the network, which I always do.
So far I have not had to use the library for parsing JSON, but when I need it, I will try Forge. It is written by the same developer who wrote Fuel, and it seems nice and easy to use.
I probably will not open America with Result-types, but I just started to study them in iOS, so I am glad that I have found such a library for Kotlin. In the README of this project, there is a good example of how Result types can be used to improve code.
Also read: “10 Libraries Every Android Developer Should Know”
Source: https://habr.com/ru/post/429194/
All Articles