Skip to content

Tag: kotlin

Tracing a recursive method in Java/Kotlin

In python, I can write a trace function like: and it’d print the recursive trace for any general recursive function beautifully: Is it possible to write a simple similar one in Java/Kotlin? Or is it only doable with AOP or the like? Answer EDIT: formatting does not 100% match yours, but that is easily f…

how to clean up generated data binding files?

I’ve got a problem I created the activity and xml files in a git branch. Commit these tasks, and change the branch to do something else. However, when build app, the following error occurred. ActivityDebugUserInfo is the file I created in the previous branch. There is no such file in the current branch.…

Kotlin JNA getting declared field names to be empty list

The code below is highly inspired by this answer and this answer, and I am trying to get it work with Kotlin language, rather than Java that was given in the answer there. It is basically based on JNA (Java Native Access), which essentially pulls the SYSTEM_BATTERY_STATE from the Windows Native library (on C+…

Using Java Optional in Kotlin DTOs

Currently I’m using Java 8’s Optional in my Kotlin DTOs as follows: The purpose of it is that for some properties like prop2 I want to also allow delete in the request. So the value of prop2 in the DTO is understood as follows: null => do nothing non-empty optional => update value empty opti…

How to build cordova project with Kotlin

I have a cordova project folder www already in progress. Build this and you will have an Android project. This will create a MainActivity.java file. I don’t know Java so I changed the file to MainActivity.kt and converted the internal code. But when I run it, it doesn’t run as error. Build cordova…