https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
android
  • m

    Mathbl

    01/31/2018, 3:15 PM
    Hey guys, I'm using Butterknife in a mixed Java/Kotlin project. I'm used to declare views as
    lateinit var
    ex.:
    @BindView(R.id.swipe_refresh_layout) lateinit var swipeRefreshLayout: SwipeRefreshLayout
    , that's fine right? To be able to show the loading animation of SwipeRefreshLayout programmatically, I use this method:
    fun showLoading() {
            <http://swipeRefreshLayout.post|swipeRefreshLayout.post>({ 
                swipeRefreshLayout.isRefreshing = true 
            })
        }
    This is inside a fragment, inside a viewpager/tabs. Thing is, I have a case (I supposed that it's because I unbind in onDestroyView) where sometimes the swipeRefreshLayout variable is null once inside the post block. It seems it has to do with the tab/fragment not being visible so I thought I'd check inside post if (isAdded) but no luck there. Any idea?
    g
    • 2
    • 8
  • a

    Aditya

    02/01/2018, 1:56 PM
    Anyone here tell me how to calculate simple interest in Kotlin..
    :stackoverflow: 3
    g
    r
    k
    • 4
    • 3
  • n

    nino

    02/01/2018, 4:42 PM
    As I cannot find anything on the net: What do I have to consider when writing a library in Kotlin which then should be integrated into a pure java Android project? How can I avoid the implementing apps to include Kotlin support in their projects?
    :stackoverflow: 1
    n
    • 2
    • 1
  • a

    agrosner

    02/01/2018, 4:52 PM
    If more devs pick kotlin first then it over time won't be an issue If your lib is in kotlin. Especially for supporting multiplatform
    :kotlin-flag: 1
    r
    • 2
    • 1
  • m

    mansonheart

    02/01/2018, 9:07 PM
    Need help with integration Realm database и
    kotlinx.coroutines
    . Channel in the listener has
    sClosedForSend
    is true. Can i keep channel active? Sample:
    d
    • 2
    • 2
  • k

    katien

    02/02/2018, 12:17 AM
    they discuss creating a static field which is only available within the file, but I can't tell if they're saying sharing an instance is a bad idea
    m
    • 2
    • 1
  • v

    Viral

    02/02/2018, 6:06 AM
    Can some one tell me the meaning of *object : * meaning
    g
    • 2
    • 1
  • a

    Alisson Morais

    02/02/2018, 10:22 AM
    are you missing the 'else' statement?
    l
    • 2
    • 2
  • n

    nicopasso

    02/02/2018, 1:28 PM
    Hi guys, I'm having a problem with Room TypeConverters and Kotlin (I guess it's just a Room issue but since I'm using Kotlin for that, I consider it a Kotlin issue as well). This is the class I'd like to persist or a shorter version of it:
    @Entity
    data class Customer(
    @PrimaryKey
    var id: Int,
    var name: String,
    var paymentAccounts: List<PaymentAccount>,
    var addresses: List<Address> )
    What we want to acheive is a generic solution for TypeConverters. This is the first not-a-100%-correct solution we came up with:
    fun <T> fromList(list: T?): String? {
    list?.let {
    val gson = Gson()
    val type = object: TypeToken<T>(){}.type
    val json = gson.toJson(list, type)
    return json
    } ?: run {
    return null
    }
    }
    
    fun <T> toList(json: String?): T? {
    json?.let {
    val gson = Gson()
    val type = object: TypeToken<T>(){}.type
    val list = gson.fromJson<T>(json, type)
    return list
    } ?: run {
    return null
    }
    }
    @TypeConverter
    fun fromPaymentAccountList(list: List<PaymentAccount>?) = fromList(list)
    @TypeConverter
    fun toPaymentAccountList(json: String?) = toList<List<PaymentAccount>>(json)
    @TypeConverter
    fun fromAddressList(list: List<Address>?) = fromList(list)
    @TypeConverter
    fun toAddressList(json: String?) = toList<List<Address>>(json)
    With this approach we have only one big problem: no compilation errors, no other errors BUT all the properties in the data class are converted to `LinkedTreeMap`s instead of proper objects. Our Customer class fortunately is not so complicated but we have other classes with list of objects and each object contains another list of other objects. It makes no sense to me to write a converter for each type that I want to persist with Room. Is there a solution to this problem? p.s.: we've also tried to create a generic TypeConverter method by using a reified generic with inline functions but at build time, we had multiple convertion errors
    g
    r
    d
    • 4
    • 9
  • e

    eric

    02/02/2018, 4:36 PM
    The
    TypeToken<T>(){}
    will only be a TypeToken<Object> because of type erasure.
    ➕ 1
    n
    • 2
    • 1
  • a

    Aditya

    02/02/2018, 7:54 PM
    Hi can anyone help me making a user interface like twitter ??
    :stackoverflow: 16
    a
    r
    • 3
    • 3
  • v

    Vir

    02/03/2018, 8:40 PM
    Hey can any one send me PDF file to learn kotlin
    o
    • 2
    • 2
  • v

    Vir

    02/03/2018, 8:44 PM
    If I want to code in kotlin then there is any base language to first learn to perform and action on this guy's !?
    a
    r
    • 3
    • 5
  • k

    kingsley

    02/04/2018, 9:08 AM
    Is there a possibility the debugger hasn’t been attached yet? You should see a checkmark (or
    X
    ) on that red dot if everything is indeed setup properly
    e
    k
    +3
    • 6
    • 11
  • t

    Tamás

    02/04/2018, 9:52 PM
    Could someone help me using kotlin with androidInstrumentationTests? I'm getting a "cannot mock final class" exception. I got it working with unit tests with the MockMaker solution, but I'm having trouble with the android tests.
    d
    t
    • 3
    • 6
  • e

    elaborate tissue

    02/05/2018, 11:34 AM
    Complete noob at android.. I'm writing a desktop kotlin app which will require a small database, i'd also like to make an android counterpart. sqlite seems to be the DB to use on android, can it also be used okay on desktop so i can share a lot of code?
    m
    • 2
    • 1
  • g

    Greg Stepniewski

    02/05/2018, 1:44 PM
    I’ve currently ended up doing (much simplified)
    async(UI) {
    delay(10)
    viewState.onNext(...)
    }
    I guess an alternative to delay would be
    bg { Thread.sleep(10) }
    ?
    l
    • 2
    • 1
  • o

    oday

    02/05/2018, 2:10 PM
    meaning from the same reference for View that I pass to the presenter, a showDialog method would be also available
    l
    • 2
    • 4
  • w

    withoutclass

    02/05/2018, 4:21 PM
    presenter fun just takes some number of channels from the view and returns a view model that holds some number of channels the view needs to listen on
    d
    • 2
    • 18
  • s

    Slackbot

    02/06/2018, 7:52 AM
    This message was deleted.
    g
    r
    • 3
    • 3
  • n

    nino

    02/06/2018, 8:11 AM
    Why Android KTX? https://android-developers.googleblog.com/2018/02/introducing-android-ktx-even-sweeter.html Wouldn’t it be better to maintain the same coding style on all platforms?
    g
    e
    • 3
    • 12
  • c

    clockworkant

    02/06/2018, 10:08 AM
    Is it possible in android studio to generate the lambda required for a parameter argument? What I used to do was type new Fuction3() and then use the tools to transform it into a lambda. What I’d love to be able to do is ctrl space and get the template put in place for the lambda. Especially when I’m using rxjava and
    withLatestFrom(o1, o2)
    l
    • 2
    • 2
  • t

    temp_man

    02/06/2018, 5:12 PM
    Any Realm users? I have a question about inserting data.
    m
    s
    • 3
    • 2
  • s

    Slackbot

    02/06/2018, 9:25 PM
    This message was deleted.
    :stackoverflow: 4
    m
    y
    • 3
    • 4
  • m

    Manjee

    02/07/2018, 12:54 AM
    val currentUser = mAuth!!.currentUser what means ‘!!’ ??
    y
    m
    +3
    • 6
    • 8
  • a

    aris

    02/07/2018, 3:25 PM
    you work with mutableList or ArrayList?
    r
    m
    • 3
    • 3
  • a

    aris

    02/07/2018, 3:26 PM
    but If u have to put into a bundle?
    m
    • 2
    • 1
  • a

    aris

    02/07/2018, 3:27 PM
    You have to cast to ArrayList and setParcelableArrayList?
    h
    m
    • 3
    • 2
  • d

    dgngulcan

    02/07/2018, 3:45 PM
    Hi everyone, is there a way to have api documentation for kotlin like javadoc?
    a
    • 2
    • 3
  • s

    sakaroz

    02/07/2018, 5:12 PM
    Hey guys, on java world, I usually used int over Enum on Android with the IntDef annotation (https://developer.android.com/reference/android/support/annotation/IntDef.html), IYO may I use enum over Integer with Kotlin ? Is there any performance diff ? Thanks
    m
    • 2
    • 1
Powered by Linen
Title
s

sakaroz

02/07/2018, 5:12 PM
Hey guys, on java world, I usually used int over Enum on Android with the IntDef annotation (https://developer.android.com/reference/android/support/annotation/IntDef.html), IYO may I use enum over Integer with Kotlin ? Is there any performance diff ? Thanks
m

miha-x64

02/07/2018, 5:15 PM
No performance difference between Kotlin and Java enums. And performance difference between IntDefs and enums is veeeery hard to notice.
View count: 3