kevinmost
09/19/2017, 9:53 PMkevinmost
09/19/2017, 10:03 PMsvenjacobs
09/20/2017, 7:59 AMenum class Status { OK, FAILED }
to a JSON response (with Moshi). Unfortunately the JSON values are written in lower case like “ok” or “failed” and it’s not possible to overwrite the enum classes’ values. Any chances this is somehow possible or do I have to write a custom Moshi adapter?jw
09/20/2017, 1:44 PMwineluis
09/20/2017, 2:38 PMjkbbwr
09/20/2017, 4:34 PMthing {
a = "test"
b = "wat"
}
bdawg.io
09/21/2017, 6:16 AMAny
and expecting it to find the equals of the assigned type instead of the defined typegildor
09/21/2017, 7:07 AMdiesieben07
09/21/2017, 7:33 AM==
it will never call an extension function (same if you call equals
directly), since the equals
in Any
always has higher precedence.bdawg.io
09/21/2017, 8:01 AMCzar
09/21/2017, 8:09 AMcompile "org.jetbrains.kotlin:kotlin-script-util:$kotlinVersion", {
exclude module: 'kotlin-compiler'
}
compile "org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlinVersion"
Now application compiles, but does not start, because kotlin-compiler-embeddable bundles xmlpull which clashes with xstream dependency which we use in the app:
org.xmlpull.v1.XmlPullParserException: No valid parser classes found in resource /META-INF/services/org.xmlpull.v1.XmlPullParserFactory that contained 'org.xmlpull.mxp1.MXParserFactory'
I'm abandoning the experiment. Seems embedding kotlin scripting in a serious real-world application is impossible at this point and we'll have to stick with Groovy. 😢Czar
09/21/2017, 11:09 AM::StringBuilder
is the reference to that function.jstuyts-squins
09/21/2017, 12:42 PMcompanion object
val yo = "yo"
gjesse
09/22/2017, 3:27 AMList<List<String>>
, found List<Any>
kotlin
val hmm: List<List<String>> = listOf(
listOf("a"),
listOf("b")
)
val hmm2: List<List<String>> = hmm + listOf("c")
louiscad
09/22/2017, 11:48 AMkarelpeeters
09/22/2017, 12:39 PMmorozov
09/22/2017, 3:44 PMprivate fun processStickyEvents() {
EventBus.getDefault().getStickyEvent(AccountsSelectEvent::class.java)?.let { onAccountsSelectEvent(it) }
EventBus.getDefault().getStickyEvent(CategoriesSelectEvent::class.java)?.let { onCategoriesSelectEvent(it) }
EventBus.getDefault().removeStickyEvent(AccountsSelectEvent::class.java)
EventBus.getDefault().removeStickyEvent(CategoriesSelectEvent::class.java)
}
mb something like this?
private fun processStickyEvents(Class.name, lambda) {
trevjones
09/22/2017, 4:23 PMfun <T: Any> getStickyEvent(type: Class<T>): T?
you can make it reified inline fun <reified T: Any> getStickyEvent(): T?
then you can use T::class.java
as your replacement for the type
argument you used beforepurereborn
09/22/2017, 6:25 PMreturn lines.collect(CustomCollector)
.flatMap { x -> process(x)}....
It uses a CustomCollector
object CustomCollector : Collector<String, MutableList<MutableList<String>>, MutableList<MutableList<String>>> {
override fun accumulator(): BiConsumer<MutableList<MutableList<String>>, String> {
return CustomBiConsumer() // main logic here, looks for a specific line, creates a new MutableList<String> and append it to the List of Lists, otherwise add non-empty lines to the last List of strings
}
override fun combiner(): BinaryOperator<MutableList<MutableList<String>>> {
return CustomBinaryOperator() // combines 2 Mutable list of lists
}
override fun characteristics(): MutableSet<Collector.Characteristics> {
return Collections.singleton(Collector.Characteristics.IDENTITY_FINISH) //the accumulator object is the same as the result object
}
override fun supplier(): Supplier<MutableList<MutableList<String>>> {
return ArrayListSupplier() //creates a new Muttable list of strings
}
override fun finisher(): Function<MutableList<MutableList<String>>, MutableList<MutableList<String>>> {
return Function.identity() // noop
}
}
class CustomBinaryOperator : BinaryOperator<MutableList<MutableList<String>>> {
override fun apply(t: MutableList<MutableList<String>>,
u: MutableList<MutableList<String>>): MutableList<MutableList<String>> {
t.addAll(u)
return t
}
}
class CustomBiConsumer : BiConsumer<MutableList<MutableList<String>>, String> {
override fun accept(stringGroups: MutableList<MutableList<String>>, line: String) {
if (line.isEmpty()) return
if (line.matches(MacParser.NAME_REGEX)) {
stringGroups.add(ArrayList())
}
stringGroups.last().add(line)
}
}
class ArrayListSupplier : Supplier<MutableList<MutableList<String>>> {
override fun get(): ArrayList<MutableList<String>> {
return ArrayList()
}
}
kovrik
09/22/2017, 8:06 PMdiesieben07
09/22/2017, 8:46 PMfun <T> castUnsafe(input: Any?) = input as T
// later:
thisMethodHasNonNullParameter(castUnsafe(null))
Will compile and fail at runtime with IllegalArgumentException
thrown from thisMethodHasNonNullParameter
.elect
09/23/2017, 6:26 PMinterface reinterpreter<T> {
operator fun get(index: Int): T
operator fun set(index: Int, value: T): Any
}
object vec1bData : reinterpreter<Vec1b> {
override operator fun get(index: Int) = Vec1b(data, index * Vec1b.size)
override fun set(index: Int, value: Vec1b) = <http://value.to|value.to>(data, index * Vec1b.size)
}
but when I type
inline fun <reified T> data():reinterpreter<T> = when (T::class.java) {
Vec1b::class.java -> vec1bData
}
I get:
required, but foundreinterpeter<T>
vec1bData
karelpeeters
09/23/2017, 8:28 PM1.1.50
version of the Kotlin plugin and how do I get it? Idea is complaining about binary incompatibilities, and the auto updater doesn't see the update because the current version is 1.2-M2-release-IJ2017.2-1
and that's considered a higher version.eygraber
09/24/2017, 6:02 AMyoavst
09/24/2017, 11:38 AMfun main(args: Array<String>) {
for (mx in -100L..100) {
println(mx)
}
}
Does it crash compiler only for me on 1.1.50?karelpeeters
09/24/2017, 5:19 PMferoz_baig
09/24/2017, 7:39 PMError:Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.50-release-Studio3.0-1.
Searched in the following locations:
file:/opt/android-studio-preview/gradle/m2repository/org/jetbrains/kotlin/kotlin-gradle-plugin/1.1.50-release-Studio3.0-1/kotlin-gradle-plugin-1.1.50-release-Studio3.0-1.pom
file:/opt/android-studio-preview/gradle/m2repository/org/jetbrains/kotlin/kotlin-gradle-plugin/1.1.50-release-Studio3.0-1/kotlin-gradle-plugin-1.1.50-release-Studio3.0-1.jar
<https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.1.50-release-Studio3.0-1/kotlin-gradle-plugin-1.1.50-release-Studio3.0-1.pom>
<https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.1.50-release-Studio3.0-1/kotlin-gradle-plugin-1.1.50-release-Studio3.0-1.jar>
<https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.1.50-release-Studio3.0-1/kotlin-gradle-plugin-1.1.50-release-Studio3.0-1.pom>
<https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.1.50-release-Studio3.0-1/kotlin-gradle-plugin-1.1.50-release-Studio3.0-1.jar>
Required by:
project :
elect
09/24/2017, 8:49 PMError:Kotlin: [Internal Error] java.lang.RuntimeException: Error generating class file gli_/coreTexture1d$5.class (compiled from [C:\Users\elect\IdeaProjects\gli\src\test\kotlin\gli_\coreTexture1d.kt]): Method code too large!
?
Coz I don't think it is too large..Oleksii
09/24/2017, 9:03 PMkovrik
09/25/2017, 4:01 AMkovrik
09/25/2017, 4:01 AMdawidhyzy
09/25/2017, 5:13 AMnapperley
09/25/2017, 7:03 AM