kotlin-interop Questions

5

Solved

I was playing with the kotlin-native samples. I wonder how I could get String from pinned ByteArray. Just want to print it in the console.
Ernestoernestus asked 24/3, 2018 at 17:35

4

I don't understand the documentation: Package-Level Functions All the functions and properties declared in a file example.kt inside a package org.foo.bar, including extension functions, are ...
Technics asked 5/11, 2017 at 0:27

6

I'm trying to observe observable on main thread by using: // Kotlin Code Observable .observeOn(AndroidSchedulers.mainThread()) but I'm getting following error: Type Mismatch: Required: rx....
Tutorial asked 22/4, 2017 at 21:6

14

I came across with kotlin equals function to compare two list of same type. It works fine for pure Kotlin with data classes. I'am using a Java library in Kotlin project in which a callback method ...
Hexastich asked 28/8, 2018 at 9:9

4

Solved

When calling Java code from Kotlin, there is SAM conversion so that Java code like this: adapter.setOnClickListener(new OnClickListener() { @Override public void onClick(View view, int position)...

2

Solved

I'm considering porting a Java (Android) library to Kotlin. I really like Kotlin and the benefits over Java should reduce the number of bugs in the library. Since the library is targeting a resou...
Triplicate asked 22/9, 2016 at 8:43

5

I faced the following error trying to extend RuntimeException and implement GraphQLError interface, defined in Java, from my Kotlin code. This is the error: Accidental override: The following decl...
Battology asked 9/2, 2018 at 4:22

5

Solved

Since Kotlin doesn't have primitives, how could this interface be implemented? public interface A { @NotNull Object get(@NotNull Integer i); @NotNull Object get(int i); } I cannot change the J...
Polanco asked 23/5, 2017 at 10:44

6

Solved

In Java we can usually perform an assignment within the while condition. However Kotlin complains about it. So the following code does not compile: val br = BufferedReader(InputStreamReader( conn...
Bivalent asked 8/1, 2017 at 20:40

4

Solved

What is the difference between: Definition 1 data class Person (var name:String, var age:Int) Definition 2 class Person (var name:String, var age:Int) Definition 3 class Person (){ var name:Stri...
Heliotropin asked 12/7, 2017 at 23:58

2

Solved

If I understand correctly, with the release of Kotlin 1.1, we can set JavaScript as a compile target for full compilation to JavaScript of Kotlin projects. Is it possible (or feasible) to write an ...
Quass asked 16/10, 2017 at 17:31

2

Solved

Exceptions.kt: @Suppress("NOTHING_TO_INLINE") inline fun generateStyleNotCorrectException(key: String, value: String) = AOPException(key + " = " + value) In kotlin: fun inKotlin(key: String, v...
Nosography asked 4/6, 2017 at 7:20

5

Solved

I'd like to access Java's private field when using Kotlin extension function. Suppose I have a Java class ABC. ABC has only one private field mPrivateField. I'd like to write an extension functio...
Yiddish asked 16/7, 2017 at 17:49

7

Solved

Autowiring a non-primitive with spring annotations like bellow works: @Autowired lateinit var metaDataService: MetaDataService But this doesn't work: @Value("\${cacheTimeSeconds}") latei...
Cavetto asked 15/9, 2017 at 11:44

3

Solved

Let's say I have particular code in old/legacy Java library: public class JavaClass { private String notNullString; private String nullableString; private String unannotatedString; public Jav...
Whitewall asked 14/6, 2017 at 17:30

4

Solved

I want to use @OneOf annotation from package io.dropwizard.validation; Java usage: @OneOf(value = {"m", "f"}) Kotlin usage: ??? I've tried this: @OneOf(value = arrayOf("m", "f")) and thi...
Tuddor asked 19/5, 2017 at 11:36

3

Solved

How to make a property in Kotlin that has a private getter (or just do not have it) but has a public setter? var status private get doesn't work with an error: Getter visibility must be the same...
Crypto asked 7/7, 2016 at 10:23

3

I created a new layout file in the appropriate resource folder. After syncing, when I try to reference the layout file, i.e. R.layout.activity_test, R is an "unresolved symbol". When I try to build...
Lionellionello asked 21/11, 2017 at 17:53

2

Solved

I'm trying to call Swift/Objective-C code from Kotlin in a multiplatform project. There are no problems with calls to platform code. But when I'm trying to call some library (or framework, not sure...
Surefire asked 2/1, 2019 at 11:24

1

I'm trying to use cocoapods framework in Kotlin Multiplatform project. So I added framework to Pods file. ran pod install. created .def file added cinterop config in build.gradle ./gradlew cinte...
Romanfleuve asked 5/1, 2019 at 0:3

2

Solved

If I have a Kotlin function fun f(cb: (Int) -> Unit) and I want to call f from Java, I have to do it like: f(i -> { dosomething(); return Unit.INSTANCE; }); which looks very ugly. Why...
Clinical asked 15/6, 2016 at 7:28

1

Solved

Reading the Java interop document about SAM Conversions, I expected the Kotlin function Collections.sortWith(comparator: kotlin.Comparator<in T> /* = java.util.Comparator<in T> */) t...
Murmuration asked 12/9, 2018 at 9:51

1

Solved

In Java I have the possibility to "implement" annotations. Sample Java annotation: @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface JavaClassAnno { String[] value(...
Samarium asked 31/7, 2018 at 8:34

2

This is a general question. Let's say I have an extension function written in kotlin which converts DP to PX and return a NonNull Int fun Int.toPx() { /** implementation */ } The function in jav...
Lola asked 12/12, 2017 at 15:14

1

Solved

Kotlin and Groovy both provide a way to write a high-order function where the function parameter has an implicit receiver. Kotlin Version class KotlinReceiver { fun hello() { println("Hello f...
Kore asked 2/7, 2018 at 16:15

© 2022 - 2024 — McMap. All rights reserved.