https://coroutinedispatcher.github.io/coroutinedispatcher/images/stavro.jpeg

The Android guy

Solving Room "cannot find setter for field" error in build time

Room persistence library is one of the easiest one to set up. However, when using data classes for your Room entities, you might face some small problem, which on the first look doesn’t really make any sense. Let’s try to compile this class: @Entity(tableName = "users") data class User( @PrimaryKey @ColumnInfo(name = "id") val number: Int, @ColumnInfo(name = "user_name") val userName: String, @ColumnInfo(name = "user_status") val userStatus: String, @Ignore val englishNameMeaning: UserGrade ) The problem:

Let's get beyond null safety

_Inspired by myself and perhaps some other people, who coded Java style in Kotlin. I have seen tones of articles which (mostly) highlight Kotlins null safety and nothing more. So that’s it? If it was only for that I swear I would be still using Java with some null checks. Therefore, this article suggest what to use best in Kotlin as well as droping some everyday Java habits. _

Dagger Multibindings saved my time

While the Android architecture made development simpler, we should always be aware of the Lifecycle and with that, the right way to provide ViewModels. Creating one ViewModel factory for each Fragment and ViewModel you have is really expensive, bad architecture, and too much unnecessary code. Not to mention the fact that you should care about scopes, dependencies, components modules when using Dagger for DI. You can have a simple “generic” ViewModel factory for all your app as a Singleton, with the help of Kotlin Reflection and Daggers Multibinding.

Getting hands dirty with KotlinJs

Although web development hasn’t been my thing since I started programming, I was really attracted the way Kotlin does solve things. So I did give a try to KotlinJS. **This is how to set up a KotlinJs page in less than an hour. ** Note: Chose to use the simplest set up without gradle or maven. You are free to chose what you like. First of all, you start with a new project in your IntelliJ and choose Kotlin -> Javascript.

A fusion between WorkManager and AlarmManager

Androids’ WorkManager has been around for a while. However my own expectations about it were a little higher. I wished that the WorkManagercould fire events at exact timing. But since it was made to respect doze mode, I should respect that too. That means that if the phone is idle, the WorkManager wont run. **Lets explore my case: ** Once the user logs into my app, I need to schedule 5 alarms for him.

What I learned from unit testing

Testing, testing testing. I was getting inside the “Fear of getting behind” every time I heard that word. So I decided to react quickly. I knew nothing about testing and this is my experience getting my hands dirty with it. Please feel free to correct anywhere I’m wrong. This is a reason why I’m writing blogs. So what the hell is testing? Testing is just a piece of code where you invoke your written production code and check its’ behavior.