Return null from fun in kotlin

I've written a function to perform a database query. I want it to return null if it cannot fetch any result. fun getServiceCharge(model: String): ServiceChargeMasterList { val unique = VideoconApplication.daoSession.serviceChargeMasterListDao.qu...
more »

2017-09-07 16:09 (3) Answers

Calling a Kotlin higher-order function from Java

I have a Kotlin helper class defined as: class CountdownTimer(endDateInSeconds: Long, callback: (timeRemaining: RemainingTime) -> Unit) which as the name implies, takes an epoch time and a callback to be invoked at fixed intervals (seconds in t...
more »

2017-09-06 21:09 (1) Answers

Build fails when using 'kotlin-kapt' with Realm

Environment : Android Studio 2.3.3, Gradle 2.3.3 and Kotlin 1.1.4-3 When I create a new Android project with Kotlin, everything works fine at first, adding //in project's build.gradle classpath "io.realm:realm-gradle-plugin:3.5.0" //in app's build...
more »

2017-09-02 01:09 (0) Answers

NoSuchMethodError: java.lang.Long.hashCode

I have the following override of method on hashCode in AbstractORM class: var _id = Random().nextLong() override fun getId() = _id // AbstractORM class implements an interface that defines this method getId() override fun hashCode() = getId().hash...
more »

2017-08-29 11:08 (2) Answers

GridLayout in Kotlin?

I am trying to get a 2x6 (WxH) GridLayout in my Kotlin Android application. I have my xml and fragment / adapter set up for a RecyclerView but am a bit at a loss for as how to apply a GridLayout to this. How can I get my items (listview_row_enrollme...
more »

2017-08-28 22:08 (2) Answers

GridView.LayoutParams doesn't exist in Kotlin?

I want to use GridView and according to the documentation, in adapter I can use this line in adapter: imageView.setLayoutParams(new GridView.LayoutParams(85, 85)); Well, converting it to Kotlin, it says: It works in Java, but not in Kotlin. S...
more »

2017-08-28 15:08 (2) Answers

Jackson ready only collections

I have Spring Boot project with a post endpoint for a entity like this: class Task{ @JoinTable(name = "task_user", joinColumns = arrayOf(JoinColumn(name = "task_id")), inverseJoinColumns = arrayOf(JoinColumn(name = "user_id"))) @...
more »

2017-08-23 14:08 (1) Answers

kotlin setter infinte recursion

I am testing out kotlin on Android and ran into a problem where the setters of two variables get called in an infinte recursion because they try to change each other when they are originally set. Here is a sample code class Example { var a: Int...
more »

2017-08-21 02:08 (1) Answers

Jackson's @JsonAppend with default value

guys! I am developing a web application and I decided to use Jackson as my JSON processing framework. In request data that I am willing to send; let's say the POJO looks like this: data class JSONEnvelope( @JsonProperty("obj1") val...
more »

2017-08-20 23:08 (1) Answers

Nullable types in kotlin annotation processor

I'm working on annotation processor for Kotlin and because the processed elements are in Java I don't receive nullables as ? instead with a @Nullable annotation and that's fine, but I'm facing a problem with receiving null parameters in types and in...
more »

2017-08-19 22:08 (1) Answers

Add an extensions function to Math class in kotlin

I added a function to Math class in the Kotlin but I could not use it, I did this before with MutableList and it worked but I can not do it with Math class. fun Math.divideWithSubtract(num1: Int, num2: Int) = Math.exp(Math.log(num1.toDouble())) - M...
more »

2017-08-17 22:08 (3) Answers

Associate android developer certification

Hi I have few questions for any one who have taken this certification from google. what kind of design pattern does the project follow MVP, MVVM. Can i use room persistence library for all the sqlite task or should i carve out raw sql queries. Does...
more »

2017-08-17 07:08 (1) Answers