Kotlin most featured libraries digest

Andrii Khrystian
ProAndroidDev
Published in
4 min readMay 18, 2017

--

Kotlin is now an official language for Android development! Congrats to all Kotlin lovers. And now Kotlin open source libraries and projects are one of the hottest topics for all Android developers. What have we here? What if I want to use only Kotlin libraries for my project? In this article I’ll try to give you some answers :)

Architecture

  1. What are you using for API calls? Retrofit or Volley? There is a better alternative for Kotlin projects. There is Fuel from Kittinun Vantasin that is easy to implement:
repositories {
jcenter()
}

dependencies {
compile 'com.github.kittinunf.fuel:fuel:<latest-version>'
compile 'com.github.kittinunf.fuel:fuel-android:<latest-version>'
compile 'com.github.kittinunf.fuel:fuel-rxjava:<latest-version>'
}

As you can see it supports RxJava and of course it can make common API request types. Also there is a file uploading/downloading feature. Requests can be canceled as well. And is has a simple syntax.

"http://httpbin.org/get".httpGet().responseString { request, response, result ->
//do something with response
when (result) {
is Result.Failure -> {
error = result.getAs()
}
is Result.Success -> {
data = result.getAs()
}
}
}

Here is an example of a GET request with two callback methods. Amazing library.

2. If you like dependency injection you may try Injekt by kohesive or Kodein by SalomonBrys. Usually I don’t use dependency injection in my projects so I can’t compare them with Dagger 2.

3. Almost everywhere we are using JSONs, so for parsing JSON we have a tool in Kotlin. Here is Kotson by SalomonBrys. In other words this is Gson for Kotlin. There is a great documentation and Kotlin style syntax:

val obj: JsonObject = jsonObject(
"property" to "value",
"array" to jsonArray(
21,
"fourty-two",
jsonObject("go" to "hell")
)
)

That’s all that you need to create JsonObject with Kotson.

View binding

1. The greatest library is of course ANKO by JetBrains. ANKO is actually not only about view binding, it’s about a new way for building user interfaces in Android. Now when Kotlin is an official language for Android, ANKO can be used instead of xml layouts. I will tell you about this library in my future articles.

2. The next library that I really like is KAndroid by pawegio. It looks similar to ANKO but it doesn’t have its own DSL. If you still want to use xml for Android layouts, but you want to simplify views binding and your code, KAndroid should be your choice.

val textView = find<TextView>(R.id.textView) - view binding

The most common classes and interfaces with lambda

editText.textWatcher {
beforeTextChanged { text, start, count, after -> before() }
onTextChanged { text, start, before, count -> onChange() }
afterTextChanged { text -> after() }
}

Also there are such features as logging, asynchronous tasks, easy access to system services.

3. If you like Butterknife, Jake Wharton has developed similar library for Kotlin, KotterKnife.

val firstName: TextView by bindView(R.id.first_name)
val lastName: TextView by bindView(R.id.last_name)

UI components

1. Multi-Selection library by Artem Kholodnyi from Yalantis.

Really interesting realization of the Multi-Selection pattern. It uses two RecyclerViews and different kind of animations. Full implementation stack you can read here.

2. Search-Filter by Irina Galata from Yalantis.

This library can be easily implemented in an Android project :). You can use it in news feeds, contacts and anywhere the content needs to be filtered. Full implementation stack is available on Github.

3. JellyToolbar by Irina Galata from Yalantis.

Fantastic library that is using Bezier curve. Toolbar as one of main UI pattern on your screen should be attractive, shouldn’t it?

4. Bubble-Picker by Irina Galata

Another great library from young and talented Irina Galata.

5. OfficialFoldingTabBar by me from Yalantis.

Since Google had presented bottom tabbar, this pattern became popular. There is another variant of bottom tabbar visual style. I think it should be better animated. The implementation is similar to default bottom tabbar. And also it can be used as FloatingActionButton.

6. DateTimeRangePicker by SkedGo.

Sometimes Android Developers have real problems working with date and time pickers. For example you have to quickly add some date ranges. That’s when this library can be really useful. And the most exiting thing that it uses joda-time. Awesome

7. CircleLayout by Francois Campbell.

The title speaks for itself. Sometime you need to develop a really custom UI and this layout might be useful. There is a good documentation and API.

As you can see there is a wide Kotlin open source community and it’s growing very fast. Now that Google finally decided to use Kotlin as second Android development language, that is when a new era of Kotlin starts.

Enjoy!

--

--