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

    andodeki

    09/30/2021, 10:02 AM
    org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering File being compiled: /home/aok-2/AndroidStudioProjects/Booz/app/src/main/java/com/aok/booz/feature_booz/presentation/home_screen/HomeBoozScreen.kt The root cause java.lang.RuntimeException was thrown at: org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:50) at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException(CodegenUtil.kt:239) at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException$default(CodegenUtil.kt:235) at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invokeSequential(performByIrFile.kt:68)
    👎 1
    z
    • 2
    • 2
  • i

    Igor Brishkoski

    09/30/2021, 1:44 PM
    I’m using
    kotlin.Result
    and trying to come up with a solution to backport it to java since it doesn’t really have good support. I have a simple Java class to kinda mimick the behavior, but
    kotlin.Result
    get’s double wrapped and throwing
    ClassCastExceptions
    . I’m wondering if I’m missing something or it’s just some weird bug. https://gist.github.com/igor-brishkoski/4df636445358f85ca40d22e02b4a9b2d
    c
    • 2
    • 2
  • a

    André Thiele

    09/30/2021, 5:29 PM
    any idea on how to resolve these?
    s
    g
    • 3
    • 6
  • m

    Matthew Laser

    09/30/2021, 6:51 PM
    does anyone know if I should be able to use
    kotlin-reflect
    to see parameter names of java methods? the stubs in the IDE show the parameter names, so I assume they should be accessible in some way (?)
    • 1
    • 1
  • v

    Vivek Modi

    09/30/2021, 7:41 PM
    Hey I have json response coming from retrofit. I want to filter accordingly to
    sentAt
    property. I want to compare latest time and move block accordingly to that. Right now in my json there is 4 items/block but it could be more. Can some one know how to filter list and modify in efficient way. Also i need to convert
    sentAt
    value in time and date format and store in other variable. The format of todays date will be in
    time
    and if date is old i need in
    date
    format. Added Data class ConversationsResponse
    data class ConversationsResponse(
        val conversations: List<Conversations>? = null
    )
    Conversations
    data class Conversations(
        val id: String? = null,
        val title: String? = null,
        val lastMessage: LastMessage? = null
    )
    LastMessage
    data class LastMessage(
        val id: String? = null,
        val text: String? = null,
        val sentAt: String? = null
    )
    :thread-please: 2
    m
    • 2
    • 5
  • h

    Hovhannes

    10/01/2021, 9:28 AM
    Hello, I've a question. How can I use break keyword in LiveData observer?
    for (i in 0 until domainList.size) {
    
        mainViewModel.fetchVbtopUrls(concatenated)
        mainViewModel.vbtopurl.observe(this, { it2 ->
    
            when (it2.status) {
                Status.SUCCESS -> {
                  
                    if (it2.data != null) {
                    
                        break   //error
                    }
                }
    
            }
        })
     
    }
    j
    g
    • 3
    • 8
  • h

    Hovhannes

    10/01/2021, 1:22 PM
    Hello, I've a question. I get that error if I use and the app crashes mainViewModel.fetchVbtopUrls(concatenated), but before it worked well. I can't understand the reason. I use Retrofit2, Coroutines, Hilt
    n
    • 2
    • 1
  • b

    Bharath Malviya

    10/02/2021, 7:19 AM
    🙋 Hi! Who else is here?
    c
    a
    m
    • 4
    • 3
  • a

    appleobject

    10/02/2021, 9:02 AM
    Any solution to this problem? Navigation framework using safearg
    :not-kotlin: 3
    n
    r
    • 3
    • 5
  • s

    Slackbot

    10/02/2021, 3:50 PM
    This message was deleted.
    e
    • 2
    • 2
  • b

    Brian Donovan

    10/03/2021, 2:41 PM
    Where can I ask questions on fragments, adapters, and recyclerView?
    c
    • 2
    • 1
  • b

    Brian Donovan

    10/03/2021, 2:42 PM
    Some of these guys get really pissed if it’s in the wrong channel, don’t know why, it’s not like we all started as pros.
    i
    • 2
    • 3
  • v

    Vivek Modi

    10/04/2021, 10:49 AM
    I want to take first character from firstName and lastName. Also firstName and lastName may be null. I want to ask is there better way to approach this? firstName :
    Vivek
    or
    Dr. Vivek
    lastName
    Modi
    private fun getInitials(firstName: String?, lastName: String?): String {
        var initials = ""
        if (firstName != null && firstName.isNotEmpty()) {
            initials += firstName.take(1)
        }
        if (lastName != null && lastName.isNotEmpty()) {
            initials += lastName.take(1)
        }
        return initials
    }
    For example
    Vivek Modi
    output
    VM
    but when i enter
    Dr. Vivek Modi
    i want
    VM
    g
    w
    a
    • 4
    • 10
  • s

    shahroz

    10/04/2021, 1:24 PM
    Is there any way to restrict possible type allowed? for example, i want to make a method that only accepts, Map<String, <String/Int/Bool>>, is there any way, i can restrict that? because using
    Any
    wont.
    a
    d
    • 3
    • 4
  • p

    Pemba Tamang

    10/04/2021, 1:44 PM
    Hey guys I am working a an app that heavily relies on webviews, the problem is that there is a lot of jank. I tried to turn on hardware acceleration but it didn't help. What else can I do ?
    l
    • 2
    • 2
  • s

    Slackbot

    10/05/2021, 10:18 AM
    This message was deleted.
    l
    • 2
    • 1
  • l

    Lilly

    10/05/2021, 6:33 PM
    When working with byte streams, do you think I get any benefit of working with
    Byte/UByte
    (unsigned types partial stable since v1.5) instead of
    Int
    ? I deal most of the time with values in the range of 0-255. I'm also thinking about the architecture of the cpu (cpu natively works better with
    Int
    while there might be extra steps to convert from
    Byte
    to
    Int
    ???) but tbh, I'm not so deep in this topic. This question might be a no brainer but anyway I'm curious about the pros and cons if there are any.
    e
    • 2
    • 5
  • n

    Napa Ram

    10/06/2021, 6:46 AM
    Hi Team i am new in Unit Testing can anyone suggest me best courses on udemy or anywhere for Junit, Mockito, Mock and Mockk i am facing issue to mock Context also TIA
    k
    c
    +2
    • 5
    • 4
  • l

    luke_c

    10/06/2021, 8:36 AM
    What’s the best practices around libraries settings targetSdkVersion? I’ve seen some posts saying it’s best to omit it, but wouldn’t it then default to the library’s minSdkVersion value?
    :not-kotlin: 1
    • 1
    • 1
  • t

    Tomas Kormanak

    10/06/2021, 11:07 AM
    Hi, is it possible to use kotlinx.datetime in android? It seems it does not support android targets
    a
    • 2
    • 2
  • s

    Sergio C.

    10/06/2021, 1:58 PM
    How do we return from a lambda function? How can I set a name to it?
    c
    • 2
    • 2
  • u

    Umar Ata

    10/06/2021, 7:15 PM
    Hi there, Is there any kotlin native function or workaround I can use to count number of emojis in text And also check if text has only emoji I am using Unicode range to check if text contains surrogate but this feels not good I also written code to use Character class but not confident if it is good to do loops for every text in list
    e
    • 2
    • 12
  • t

    Tallal Tasawar

    10/07/2021, 2:05 AM
    any idea about how to use Koin with work manager, am trying to inject a worker creator in my view model but not sure how
    :not-kotlin: 2
    :kotlin: 1
    a
    • 2
    • 1
  • s

    slartus

    10/07/2021, 5:13 AM
    hi all. how to switch off in compose LazyColumn overscroll effect like android:overScrollMode="never" for RecyclerView
    a
    • 2
    • 6
  • m

    Michael Langford

    10/07/2021, 4:05 PM
    I have a client we're making their first Android app for. They made the account then took a ~10 months to get through contracting, and are now getting "Your count will be closed on Oct 13th unless you". We will not finish the app by Oct 13. Is there a good resource to figure out exactly how much we need to get their account configured to stop that notice? Also, is their account perhaps in a weird state when that happens, so they can't see "internal tested" apps? Google's documentation on this is super lightweight and it's not easy to see how to make this message go away.
    :not-kotlin: 6
    i
    • 2
    • 8
  • r

    Ravin Jain

    10/08/2021, 1:13 AM
    How to provide 
    viewModelScope
     as a constructor injection through hilt to other classes which are 
    viewmodelscoped
    n
    r
    • 3
    • 10
  • r

    Roy Owor

    10/08/2021, 2:39 AM
    Hello can someone please point me to a great resource on working with android contacts. My use case is that a user should be able to search for a contact from a list of contacts on his phone and select one. upon selection the selected contact no. should fill in an editText Field. for some reason I cannot make good use of android documentation on this subject. Thanks
    :not-kotlin: 5
    d
    • 2
    • 2
  • i

    Ink

    10/08/2021, 11:55 AM
    Android 11 SDK 30 <queries> My app interacts with other app. I added to main mainfest
    <queries>
        <package android:name="kl.mobile.myapp" />
    </queries>
    but it doesn't work on Android 11. What I forgot to add? On Android 9, 10 it works https://developer.android.com/guide/topics/manifest/queries-element
    :not-kotlin: 1
    g
    • 2
    • 6
  • l

    Lilly

    10/10/2021, 3:38 PM
    I have noticed that some/many kotlin stdlib functions lack of escape, e.g.
    repeat
    . In the first place it's not clear what a
    return@repeat
    does. I would expect it leaves the iteration but instead it skips the iteration. AFAIK it's not possible to escape from
    repeat
    ??!! And I guess the name does not implicitly tell that the repetition has to be finished. A
    repeatUntil
    counterpart would help here. Another example where a
    return
    is missleading:
    map
    ,
    mapValues
    ,
    mapKeys
    ,
    associateBy
    ,
    associateWith
    etc. Here I would expect that a
    return
    skips the current item, but instead the
    return
    gets part of data (
    Unit
    ). Some
    ..NotNull
    counterparts would help here. What do you guys think about that?
    a
    e
    • 3
    • 8
  • a

    AmrJyniat

    10/10/2021, 6:22 PM
    How to get a boolean value from 
    dataStore Preference
     *synchronously*(one-shot) without delay?
    r
    k
    +2
    • 5
    • 6
Powered by Linen
Title
a

AmrJyniat

10/10/2021, 6:22 PM
How to get a boolean value from 
dataStore Preference
 *synchronously*(one-shot) without delay?
r

Rajput Art Studio

10/10/2021, 7:58 PM
Please try this library it's really owsome https://github.com/rajputmukesh748/EasyDataStore
No need to handle coroutines and it returns data fastly.
k

K Merle

10/10/2021, 8:13 PM
Your usecase might need something else then DataStore.
f

Francesc

10/10/2021, 10:59 PM
You can't. You could wrap the read call in a runBlocking call, but even then it's not guaranteed to be without delay because there is IO involved. The Legacy preferences wasn't without delay either, it was just that you didn't have an easy way to not block when calling the API.
👍 1
☝️ 1
a

AmrJyniat

10/11/2021, 7:00 AM
It's very wired, when you replace
SharedPrefrence
with
dataStore
to optimize the process but actually you miss very basic requirement like this!
z

Zun

10/11/2021, 11:33 AM
There's no such thing as “no delay”
View count: 27