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
  • r

    ribesg

    11/17/2020, 4:34 PM
    Is the Layout Inspector supposed to work in IntelliJ IDEA Ultimate 2020.2? I just got back to some Android dev, updated my app to Kotlin 1.4, wanted to check something and the Layout Inspector just stays empty, nothing works, no error.
    z
    1 reply · 2 participants
  • s

    Slackbot

    11/17/2020, 4:41 PM
    This message was deleted.
    ❌ 1
    🇳🇴 1
    a
    r
    +1
    3 replies · 4 participants
  • s

    Serhii K

    11/17/2020, 5:07 PM
    com.android.tools.build:gradle:4.1.1 // And I updated gradle
    :google: 1
    z
    1 reply · 2 participants
  • k

    Kshitij Patil

    11/18/2020, 3:48 AM
    Does anyone have working example of Paging 3 with
    RemoteMediator
    ? Especially the cases where we decide the page based on
    loadType
    and
    state
    . Also, where can I ask more Paging 3 related questions?
    :stackoverflow: 2
    h
    2 replies · 2 participants
  • e

    Elnur Jeksenov

    11/18/2020, 4:47 AM
    Hi guys👋 My project contains three modules: 1. app 2. ui(jetpack compose) 3. sdk(kotlin multiplatform, ktor client) So I’m making requests to server in sdk(kotlin multiplatform) module. I want to upload file via multipart-form-data, but there is no support for java.io.file in kotlin multiplatform. Have you got any idea to solve this problem?
    k
    2 replies · 2 participants
  • s

    Slackbot

    11/18/2020, 3:41 PM
    This message was deleted.
    h
    1 reply · 2 participants
  • m

    Mitch

    11/19/2020, 12:32 AM
    Does compose chat go in this channel?
    t
    l
    4 replies · 3 participants
  • s

    Slackbot

    11/19/2020, 2:49 AM
    This message was deleted.
    :stackoverflow: 2
    o
    1 reply · 2 participants
  • r

    Rengu N

    11/19/2020, 2:53 AM
    Hello, how do we specify build variant for kotlin multiplatform. Any specific examples are there?
    h
    1 reply · 2 participants
  • r

    riflockle

    11/19/2020, 8:01 AM
    Is the CI system working well at
    github actions
    now? My kotlin style test, dependencyTest, Unit Test are very slow....
    n
    1 reply · 2 participants
  • t

    Tim Malseed

    11/19/2020, 10:45 AM
    Something that just occurred to me after 8 years of Android programming.. How is Android's colour system integer based? If a colour is represented in hex format, with an alpha channel - it's quite possible (and common) for the resultant decimal value to be Long. That colour value is then cast to integer, and overflows. How does Android's colour system work with overflowed integers? Are there any collisions? Could two different colours end up overflowing to the same value? Or is the explanation just that it's possible to map from the overflowed integer, back to the long value, because the set of possibilities is limited from 0x00000000 to 0xFFFFFFFF (there are no collisions)
    :google: 3
    :stackoverflow: 3
    m
    e
    +3
    15 replies · 6 participants
  • k

    kenkyee

    11/19/2020, 12:46 PM
    Maybe rename this channel to #android-kotlin-questions-only So it's not #android-questions-that-belong-on-stackoverflow 😂
    :stackoverflow: 1
    👍 4
    c
    r
    +5
    17 replies · 8 participants
  • e

    Eric Ampire [MOD]

    11/19/2020, 2:22 PM
    After removing
    apply plugin: 'kotlin-android-extensions'
    I tried to add Kotlin parcelize plugin
    apply plugin: 'kotlin-parcelize'
    but after adding parcelize plugin a got this error message
    Plugin [id: 'kotlin-parcelize'] was not found in any of the following sources:
    Can someone explain why?
    e
    3 replies · 2 participants
  • r

    Ryan

    11/19/2020, 3:43 PM
    anyone know keyboard shortcut to show most recently visible class/file?
    :google: 2
    c
    c
    +1
    21 replies · 4 participants
  • o

    Orhan Tozan

    11/19/2020, 4:08 PM
    Anyone else find the naming of
    lifecycleScope.launchWhenStarted {}
    misleading?
    lifecycleScope.launch { ... }
    -> launches the coroutine immediatly, gets canceled when lifecycle is destroyed. Now I would expect
    lifecycleScope.launchWhenStarted { ... }
    to behave the same as the above, except it being different in the timing of the coroutine launching: coroutine gets launched when the lifecycle is started, and gets canceled when lifecycle is destroyed. But what it actually does, is also suspend the coroutine after it is launched, when the lifecycle is stopped. Maybe I've misunderstood it, but if not, I think a more fitting name would be something like
    lifecycleScope.runWhileStarted {...}
    ? Or maybe perhaps a whole new scope? (
    lifecycleStartedScope
    ), It feels like these
    launchWhen
    methods try to emulate sub-coroutinescopes that could be replaced by introducing new lifecyclescopes that are different instances of CoroutineScope, an API that exists for handling the lifecycles of coroutines. Curious to hear your thoughts about this.
    👍 5
    e
    a
    +3
    9 replies · 6 participants
  • b

    Brady Aiello

    11/19/2020, 5:18 PM
    Haven't had this problem before, but I can't build an Android project at all, from terminal or Android Studio. It just hangs forever, and --info isn't particularly helpful. I'm using Kotlin 1.4.10, Kotlin Gradle DSL, Android Studio 4.2 Canary 16. Anyone have this problem? I'll add a couple interesting logs in a thread.
    c
    a
    4 replies · 3 participants
  • c

    Corey Lanier

    11/20/2020, 2:29 AM
    Hi all, I’m studying MVVM, and having a hard time grasping why a ViewModelFactory would go with a ViewModel when it is sent to a fragment. I’ve seen the ViewModel work standalone as well, so I’m just wondering what benefit using a ViewModelFactory provides. And yes, I’ve been to SO and Google, and yet I still don’t fully grasp the concept, so shoot me.
    :google: 4
    :stackoverflow: 4
    j
    4 replies · 2 participants
  • s

    Slackbot

    11/20/2020, 7:03 AM
    This message was deleted.
    :google: 2
    :stackoverflow: 2
    👍 1
    k
    1 reply · 2 participants
  • a

    Alexa_Gal

    11/20/2020, 7:34 PM
    have anyone here worked with the google-pay lib from google (the one provided to banks/fintechs) that could help me with a tiny issue 👋
    z
    1 reply · 2 participants
  • g

    Gabriel Brollo

    11/20/2020, 11:50 PM
    Hello, AndroidViewModel.getApplication() was accepted for boolean parameter, and i have only a runtime exception. Is that a problem with generic function? But it should extend a Application class
    r
    n
    +1
    16 replies · 4 participants
  • v

    Val Salamakha

    11/21/2020, 12:08 AM
    I use AS-4.2-alpha16. When I started debug mode, I received the following message: “Could not connect to remote process. Aborting debug session.” The studio works fine in the Run mode. What is going on?
    n
    3 replies · 2 participants
  • r

    Rahul Mishra

    11/22/2020, 12:41 AM
    Hi Devs, Have we encountered this kind of issue when working with dagger-hilt in multi module project? https://stackoverflow.com/questions/64949553/multiple-activity-annotated-as-androidentrypoint-in-different-modules-with-hilt Please have a look. Would be great help. Thanks. 😃
    o
    2 replies · 2 participants
  • p

    Priyank Jain

    11/22/2020, 11:00 AM
    Hello all. I am developing a karaoke application in which user can sing with the background music with both video and audio. It is just like one popular application on the Play store StarMaker. But the thing is I am unable to find any library which can do recording and playback with live feedback of own voice in-ear, with music and voice synchronization. StarMaker is actually doing that all of that in realtime. So can anyone tell me about any library or any source from where I can develop a karaoke application?
    :google: 4
    d
    1 reply · 2 participants
  • a

    Alessandro Toninelli

    11/22/2020, 12:24 PM
    hi, i am having problems with the latest update of android studio for mac. every time I open the Preferences or any other window android studio split the current window by creating tabs and freezing the entire ide! Others with the same problem? Solutions?
    s
    4 replies · 2 participants
  • j

    Jonny

    11/22/2020, 1:39 PM
    Do I definitely need to get my viewmodel from a viewmodelprovider? Right now I'm doing it like this:
    @Provides
        @MainScope
        fun contributeViewModel(isSignedInUseCase: IsSignedInUseCase, signOutUseCase:SignOutUseCase, toolbarViewConfig: ToolbarViewConfig): MainActivityViewModel =
            MainActivityViewModel(isSignedInUseCase, signOutUseCase, toolbarViewConfig)
    and then I build it in MainActivity using my builder, and then I can access the viewmodel there.
    interface MainComponent {
        fun mainViewModel(): MainActivityViewModel
        fun navController(): NavController
    
        @Component.Builder
        interface Builder {
            fun build(): MainComponent
    
            @BindsInstance
            fun activity(activity: AppCompatActivity): Builder
            fun coreComponent(coreComponent: CoreComponent): Builder
        }
    
    }
    Am I missing something? Will the viewmodel not be provided to me in the same way using this method? Here's how I use it in MainActivity:
    mainComponent = DaggerMainComponent
                .builder()
                .coreComponent(coreComponent)
                .activity(this)
                .build()
    
            mainActivityViewModel = mainComponent.mainViewModel()
    🤦‍♂️ 3
    d
    1 reply · 2 participants
  • s

    Slackbot

    11/22/2020, 3:23 PM
    This message was deleted.
    🤦‍♂️ 1
    j
    d
    2 replies · 3 participants
  • l

    Lilly

    11/23/2020, 2:43 AM
    Hi, I owned a project which is from 2012 and it is really messy. It's not clear which
    Activity
    belongs to which screen. Is there a faster way than setting break points arbitrarily to determine this?
    🤔 2
    a
    f
    5 replies · 3 participants
  • d

    dammy_abayomi

    11/23/2020, 1:11 PM
    Hi everyone, I’m exploring the possibility of connecting Coroutine 
    StateFlow
     🤝 
    DataBinding
     in a similar way as 
    LiveData
     do. It seems there isn’t a default implementation at the moment that supports it. I found an example online which seems quite “burdensome” if one needs to implement it for a bigger project https://github.com/STAR-ZERO/sample-stateflow-databinding Do you use 
    StateFlow
     🤝 
    DataBinding
     ? How do you connect them?
    f
    n
    +1
    8 replies · 4 participants
  • n

    Nikita Khlebushkin

    11/23/2020, 1:48 PM
    Hello! I updated to 1.4.20, and now all my synthetic views are highlighted red, without any code suggestion or quick documentation (it all builds and work fine though). How do I get the code completion back?
    👍 1
    k
    j
    +1
    37 replies · 4 participants
  • b

    Ben Butterworth

    11/23/2020, 5:17 PM
    Is there a way to wrap an iterator inside a custom iterator? I want to do some logic before returning the values from an iterator, but encapsulate it. A naive approach I tried,
    myMapObject.asSequence().map {
      yield Pair(it.key, processValue(it.value))
    }
    but the iterator method
    override fun next(): Pair<String, OutputType> {}
    doesn't return sequences, but the actual value. My understanding of yield is that it needs to be inside a coroutine, so yield isn't really what im looking for? (im taking cues from the python yield keyword, which is very different)
    v
    8 replies · 2 participants
Powered by Linen
Title
b

Ben Butterworth

11/23/2020, 5:17 PM
Is there a way to wrap an iterator inside a custom iterator? I want to do some logic before returning the values from an iterator, but encapsulate it. A naive approach I tried,
myMapObject.asSequence().map {
  yield Pair(it.key, processValue(it.value))
}
but the iterator method
override fun next(): Pair<String, OutputType> {}
doesn't return sequences, but the actual value. My understanding of yield is that it needs to be inside a coroutine, so yield isn't really what im looking for? (im taking cues from the python yield keyword, which is very different)
v

Vampire

11/23/2020, 5:33 PM
Nowhere in your approach is any iterator involved. And
yield
is not necessary here, it would allow you to produce values for an arbitrary sequence. It is a suspending function, so it has to be called from a suspending function: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.sequences/-sequence-scope/yield.html If you for example use the
sequence
function, the lambda you give it is a suspending function, so you can call
yield
in it: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.sequences/sequence.html But as you just want to map the elements of an existing sequence,
yield
is not what you are after, just omit it and you have what you want.
b

Ben Butterworth

11/23/2020, 5:36 PM
Sorry, i omitted the Iterator code, but this currently sits inside
override fun next(): Pair<String, ObjectType> {}
it cant return a sequence, which is why it wont work. I want it to be an iterator so clients can call each item independently. Unless this is also possible with sequences?
v

Vampire

11/23/2020, 5:39 PM
Sequences are the lazy Kotlin variant of iterators. Much like `Stream`s in Java. https://kotlinlang.org/docs/reference/sequences.html
b

Ben Butterworth

11/23/2020, 5:42 PM
Yes i know, i think asking about sequences was a redherring in my question. thats not my problem/ solution. It was just my first attempt which i discarded My main objective is to wrap an iterator with more logic, and the clients can use this iterator.
Having said that, i might as well change the clients to use a sequence, because i dont know how to encapsulate an iterator with extra logic.
v

Vampire

11/23/2020, 5:49 PM
There are many ways, at least one indeed involves sequences, like for example
myMapObject.asSequence().map { Pair(it.key, processValue(it.value)) }.iterator()
But if your client is using Kotlin, maybe using sequences is actually the better idea.
b

Ben Butterworth

11/23/2020, 5:51 PM
Ohh, thats a nice solution 😃, i was creating a nested Iterator subclass (boiler plate code)… and even that was not working. Thanks
View count: 6