https://kotlinlang.org logo
Docs
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
  • n

    Nizzle94

    01/23/2018, 2:21 AM
    I mean mixed codes. My team leader does not agree with me for writing mixed Java and Kotlin. He wants only Java or Kotlin.
    d
    g
    +2
    • 5
    • 5
  • h

    hmole

    01/23/2018, 7:53 AM
    For some reason it doesn't work with boolean type.
  • s

    Scott

    01/23/2018, 7:54 AM
    Cool, 👍
    w
    • 2
    • 1
  • p

    Paul Woitaschek

    01/23/2018, 9:37 AM
    Am I right with the assumption that sealed classes are not supported by
    @Parcelize
    ?
    d
    • 2
    • 1
  • n

    nickk

    01/23/2018, 11:28 AM
    I’m trying to find the valid values I can pass to
    @Suppress
    . Is there a list somewhere?
    k
    • 2
    • 2
  • j

    jw

    01/23/2018, 5:18 PM
    https://kotlinlang.org/docs/reference/extensions.html
    y
    b
    • 3
    • 26
  • k

    kirillrakhman

    01/24/2018, 9:12 AM
    I'm getting
    Warning:Configuration 'compile' is obsolete and has been replaced with 'implementation'. It will be removed at the end of 2018
    I don't have any
    compile
    dependencies anymore. Could it be the Kotlin plugin that causes the warning?
    g
    e
    j
    • 4
    • 11
  • a

    Ayden

    01/24/2018, 2:48 PM
    I thought Vector Drawable Animation is also a part of Android?
    g
    • 2
    • 2
  • e

    eyal

    01/24/2018, 3:27 PM
    Here is the Robolectric code causing problem: https://github.com/robolectric/robolectric/blob/6fa38fc48242cbdcb08b54f4bd5b5a0a8dbee6f2/robolectric/src/main/java/org/robolectric/ParameterizedRobolectricTestRunner.java#L153 This is throwing a ClassCastException
    r
    • 2
    • 1
  • t

    tgmcians

    01/24/2018, 6:40 PM
    I am getting an error
    this class implements parcelable but does not provide a creator field
    s
    • 2
    • 1
  • t

    temp_man

    01/24/2018, 11:23 PM
    Hey everyone, I have a question I can not seem to find an answer to. If I have a background function that sends updates to my activity, how can I constantly send those updates to the UI of a fragment? I know you can do this with onCreate but I need to keep a constant flow of updates. Hope that makes sense.
    :stackoverflow: 2
    k
    d
    • 3
    • 3
  • n

    Nizzle94

    01/25/2018, 8:22 AM
    Hello everyone. I have question about. Kotlin and room.
    g
    • 2
    • 27
  • m

    magicleon

    01/25/2018, 6:45 PM
    Hi everyone, I’m new here. Where can I start to learn Kotlin for Android Developement? I come from Java
    l
    m
    +3
    • 6
    • 8
  • y

    yasir-ameen

    01/27/2018, 7:07 AM
    How do i write in kotlin : someFuncName(Activity mAct, Class<?> cls) { ... } real question is that how to write a second parameter in kotlin "Cass<?> cls"
    j
    r
    • 3
    • 5
  • j

    Joe

    01/27/2018, 1:30 PM
    Ah yes, that was to wrapper Ankologger functionality:
    interface Logger : AnkoLogger
    d
    • 2
    • 2
  • z

    zkeme

    01/27/2018, 3:45 PM
    on another topic.. how is the general feeling towards Kotlin coroutines? Is it stable enough for production?
    d
    • 2
    • 1
  • l

    Loránd

    01/28/2018, 3:16 PM
    Hello, just wondering is there any way i can lock a property in kotlin when modifying it so i dont get concurrent modification?
    r
    d
    • 3
    • 11
  • k

    kenkyee

    01/28/2018, 5:52 PM
    That's what the presentations contained though...
    r
    • 2
    • 3
  • n

    noone

    01/28/2018, 7:38 PM
    I’m looking for a good open source android project that uses kotlin. I want to look at the code and learn from it.
    a
    • 2
    • 1
  • o

    oday

    01/29/2018, 10:19 AM
    I see that Lists don’t implement Serializable
    g
    • 2
    • 1
  • a

    Aditya

    01/29/2018, 12:47 PM
    Can anyone one tell me what nullable means in Kotlin ???
    m
    • 2
    • 1
  • j

    jw

    01/30/2018, 12:00 AM
    nullable
    f
    • 2
    • 1
  • j

    jw

    01/30/2018, 12:04 AM
    it emits a null check automatically
    s
    • 2
    • 1
  • r

    Rick

    01/30/2018, 4:39 AM
    Does anyone know a good way to learn unit/instrumental testing? I am having a hard time trying to learn this. Second day studying and can't understand. It looks like a new language that I have to memorize. Could'nt find a good book or article that have this subject well explained. Any help/recomendation here?
    g
    • 2
    • 26
  • a

    aeruhxi

    01/30/2018, 6:29 AM
    Is it a normal practice to consider every parameter/variable coming from android framework nullable? I feel It's not ergonomic to deal with optionality everywhere even though some variables can never be null. Is there any cheeatsheet or anything I should read on to know which parameters can be null or not?
    g
    t
    • 3
    • 8
  • a

    Aditya

    01/30/2018, 7:56 AM
    There is an underline under the Int as well why ???
    g
    • 2
    • 1
  • a

    Aditya

    01/30/2018, 10:13 PM
    Not yet
    👎🏽 1
    😂 2
    e
    • 2
    • 1
  • a

    Ayden

    01/31/2018, 9:38 AM
    Because when I tried to use the method above.
    n
    • 2
    • 1
  • a

    Ayden

    01/31/2018, 9:43 AM
    class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemSelectedListener {
    
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(R.layout.activity_main)
    
            loadFragment(new HomeFragment())
    
            BottomNavigationView navigation = findViewById(R.id.navigation)
            navigation.setOnNavigationItemSelectedListener(this)
        }
    
        ...
    
        fun onNavigationItemSelected(item: MenuItem?): Boolean {
            fragment: Fragment = null
            return true
        }
    }
    n
    • 2
    • 1
  • k

    Kevin Janvier Chinabalire

    01/31/2018, 10:08 AM
    Hey guys i need a quick help here I have a model and i want to access the items outside a for loop
    var model:User()
    forEachIndexed { index, users ->{
    println("my $users ")
    }
    println("I want to access my result outside for loop")
    e
    • 2
    • 30
Powered by Linen
Title
k

Kevin Janvier Chinabalire

01/31/2018, 10:08 AM
Hey guys i need a quick help here I have a model and i want to access the items outside a for loop
var model:User()
forEachIndexed { index, users ->{
println("my $users ")
}
println("I want to access my result outside for loop")
e

edwardwongtl

01/31/2018, 10:20 AM
What kind of result do you want?
k

Kevin Janvier Chinabalire

01/31/2018, 10:22 AM
i want to get back the model result which match with like
println("Result $model")
... Not an arraylist
e

edwardwongtl

01/31/2018, 10:24 AM
Then what object does you actually looping?
k

Kevin Janvier Chinabalire

01/31/2018, 10:24 AM
Am looping into this arraylist
val arraylist = ArrayList<User>()
Example
val arraylist = ArrayList<User>()
var model:User()
forEachIndexed { index, users ->{
println("my $users ")
}
println("Result $model")
e

edwardwongtl

01/31/2018, 10:27 AM
I think you should be calling
arraylist.forEachIndexed
?
k

Kevin Janvier Chinabalire

01/31/2018, 10:28 AM
but i want the model
e

edwardwongtl

01/31/2018, 10:28 AM
And if you are looping the
ArrayList<User>
, then you can use
filter{}
to get the matches, or even
first {}
if you just need one result
k

Kevin Janvier Chinabalire

01/31/2018, 10:28 AM
i actually calling
arraylist.forEachIndexed
val arraylist = ArrayList<User>()
var model:User()
arraylist.forEachIndexed { index, users ->{
println("my $users ")
}
println("Result $model")
where i need help is to access that model ... which is not an arraylist model just a model like above
e

edwardwongtl

01/31/2018, 10:31 AM
If I didn't get it wrong, you want to set
var model
to the first one that matches some condition inside the
val arraylist
?
k

Kevin Janvier Chinabalire

01/31/2018, 10:33 AM
i want to access all the result after looping the array as
var model
which i declare up ...
to give u more clarity i have a `fun which i need to pass that
model
it cannot be an
array
e

edwardwongtl

01/31/2018, 10:35 AM
Can't you just call that
fun
inside the loop?
k

Kevin Janvier Chinabalire

01/31/2018, 10:37 AM
no it will keep looping all the values
e

edwardwongtl

01/31/2018, 10:39 AM
If you don't want to call that
fun
for every
User
in the list, then use
filter
to get rid of the unwanted
User
first, then
map
each
User
to the result of that
fun
k

Kevin Janvier Chinabalire

01/31/2018, 10:56 AM
i will just pass my
fun
inside a
for
cz filtering is not helping
Am i doing it right like this
var getuser:List<User> = arralist.filter { user -> User ==User() }

            println("FILTER 909 $getuser")
            getuser.map { dataModel ->
                log("DADADADADDAAD $dataModel")
            }
e

edwardwongtl

01/31/2018, 11:00 AM
fun action(user: User): T = ...
val arraylist: ArrayList<User>
arraylist.filter { user -> user == ... }.map { action(it) }
If
action()
does not return a value, replace the
.map
with
.forEach
k

Kevin Janvier Chinabalire

01/31/2018, 11:05 AM
when filtering can i replace all the model ? like
arraylist.filter { user -> user == User() }.map
e

edwardwongtl

01/31/2018, 11:06 AM
Oh then you should do
.map { User() }
k

Kevin Janvier Chinabalire

01/31/2018, 11:09 AM
``` arraylist.filter { user -> user == User()}.map {User() println("DDDD ----------- $it") }``that line ain't executed
e

edwardwongtl

01/31/2018, 11:10 AM
Cause nothing matches
user == User()
filter
is not meant for manipulating data
k

Kevin Janvier Chinabalire

01/31/2018, 11:15 AM
how tp get something which matches ?
e

edwardwongtl

01/31/2018, 11:19 AM
Don't understand what you want to ask
To clarify the problem, you have a
ArrayList<User>
, and you want to pass some of them into a function
fun action(user: User): Result
, and gather all the results. Am I getting it wrong, or you want to actually manipulate the
ArrayList<User>
?
k

Kevin Janvier Chinabalire

01/31/2018, 12:04 PM
u are getting it right
it like that .. from my
ArrayList<User>
i want to access the model by looping
e

edwardwongtl

01/31/2018, 12:13 PM
Then its simple as just
users.filter { boolean condition }.map { user -> getResult(user) }
This will gives you back
List<Result>
which you can then operate on
View count: 1