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

    M.Onirban

    09/09/2021, 5:09 PM
    Is there any major advantage of using kotlin gradle build script over groovy?
    d
    t
    +5
    • 8
    • 15
  • p

    PhongBM

    09/10/2021, 2:26 AM
    How can print directly to added printers, without preview screen by System
    :not-kotlin: 6
    g
    • 2
    • 1
  • s

    Slackbot

    09/10/2021, 6:09 AM
    This message was deleted.
    g
    c
    • 3
    • 2
  • k

    Kulwinder Dhanjal

    09/10/2021, 8:18 AM
    Hiii.... what is the easiest method in kotlin to round a float value upto 2 decimals and for all locales (whether it uses decimal point or decimal comma) currently i am using this method but it throws NumberFormatException for locales that use decimal comma.
    fun Float.round(decimals: Int = 2): Float = "%.${decimals}f".format(this).toFloat()
    e
    • 2
    • 2
  • s

    Slackbot

    09/10/2021, 4:36 PM
    This message was deleted.
    :not-kotlin: 1
    c
    • 2
    • 1
  • c

    Chandan Kumar Pradhan

    09/11/2021, 4:29 PM
    I want to make a QR Generator & Scanner app. Any resources suggestions ? #education
    :not-kotlin: 1
    :google: 3
    l
    x
    c
    • 4
    • 3
  • j

    Jay

    09/12/2021, 5:25 PM
    Hi, I have a doubt about Kotlin lazy property delegation For example, this property delegate with lazy:
    val x: String by lazy{...}
    When I decompile the Kotlin code into Java code, I see that the getX() method is not ultimately called this method
    public inline operator fun <T> Lazy<T>.getValue(thisRef: Any?, property: KProperty<*>): T = value
    It is the getter method of value, which is
    getValue()
    instead of
    getValue(thisRef: Any?, property: KProperty<*>)
    So, I don’t understand how the method
    getValue(thisRef: Any?, property: KProperty<*>)
    is called during the execution of lazy
    👀 1
    e
    • 2
    • 5
  • j

    Jeff

    09/13/2021, 7:34 AM
    How do you achieve nested ordering? i.e When you have a data class eg.
    Chat
    which holds another class with a list of
    Message
    can you order a list of chats with a variable in message like
    createdAt
    d
    • 2
    • 1
  • r

    Remon Shehata

    09/13/2021, 12:09 PM
    Hi, I have a function that does a lengthy operation, but I want it to return only after this operation is completed. Also I would like the caller of the function to call it inside a coroutine because it could block them. I did something like:
    suspend fun foo(){
            runBlocking(<http://Dispatchers.IO|Dispatchers.IO>) {
                // do some operation and return only after it's completed
            }
        }
    How ever adding the suspend modifier gave me the following warning (posted in reply).
    d
    r
    • 3
    • 6
  • t

    Tyler Turnbull

    09/13/2021, 3:10 PM
    anyone know why android lint is not failing with this setup 🤔
    lintOptions {
            checkReleaseBuilds false
            warningsAsErrors true
            abortOnError true
            lintConfig file('lint.xml')
            baseline(file("lint-baseline.xml"))
        }
    I added a new lint violation which is a warning, but should be treated as an error and abort.. yet the build succeeds every time
    :not-kotlin: 4
    c
    • 2
    • 3
  • l

    Lilly

    09/13/2021, 10:25 PM
    I have a
    List<Map<String, String>>.
    I would like to add a pair to a specific map in the list which I determine with
    myList.find { it["myKey"] == "keyValue" }
    What is the best approach to achieve this. The first option that comes in mind is to remove the map and add the map with the new pair. Any better ideas?
    d
    j
    • 3
    • 4
  • r

    Rafiul Islam

    09/14/2021, 2:58 PM
    Is it ok to use broadcast receiver just to refresh content of other activity? I have got a project where I found this. Check Thread.
    🇳🇴 1
    :not-kotlin: 2
    k
    • 2
    • 11
  • b

    Brian Donovan

    09/14/2021, 5:23 PM
    Hello everyone, I’m new to the channel and android/kotlin can I get some help on what is a model, view, and viewModel like I’m 5 year-old?
    :not-kotlin: 3
    a
    • 2
    • 1
  • b

    Bill

    09/14/2021, 10:55 PM
    Hello, I have a recyclerview inside scrollview. Each item has a horizontal recycler also. My main issue is when I want scroll up/down and my finger is on horizontal recyclerview (item) it doesn't scroll up/down. I can't remove the nestedScroll from horizontal recview because I need it. Any ideas?
    :not-kotlin: 4
    g
    • 2
    • 1
  • t

    Trevor Stone

    09/15/2021, 1:03 AM
    I am working on a library that is being consumed by Android clients. We would like to try some of the new functionality by setting languageVersion to 1.6. Does this require our clients to also use that languageVersion or would be generated jar/aar be compatible regardless. The usage of 1.6 language features would only be internal/private
    b
    • 2
    • 1
  • h

    haris mehmood

    09/15/2021, 6:36 AM
    Hi, anyone know how to get this design ..... Thanks
    :not-kotlin: 2
    a
    • 2
    • 3
  • s

    Slackbot

    09/15/2021, 8:24 AM
    This message was deleted.
    g
    k
    • 3
    • 2
  • l

    Loredana Petrea

    09/15/2021, 12:04 PM
    Hi folks, I want to extract from an url the substring before
    v[0..9]
    e.g:
    <https://baseurl.test/v1/example/{id}>
    the result should be only
    <https://baseurl.test/>
    Where the version number can be 1,2....9 Is there a way to do this?
    t
    v
    • 3
    • 4
  • m

    maxmello

    09/15/2021, 2:52 PM
    When collecting a Kotlin flow inside an Activity or Fragement:
    override fun onCreate(…) {
     …
     scope.launch /* on Dispatchers.Main */ {
       viewModel.flow.collect { it ->
          uiElement.text = it
       }
     }
    }
    Is is better to do
    launch(Dispatchers.Default)
    and then wrap the UI operation in
    withContext(Dispatchers.Main)
    , or is there no practical difference since the collect is suspending and not blocking? If I would do more operations except setting the UI element, I would always do the approach with launch on Dispatchers.Default + withContext(Main), but here I really only update the UI on collect
    a
    • 2
    • 4
  • h

    Hien Nguyen

    09/15/2021, 9:19 PM
    does KMM support PagingDataAdapter for ListAdapter in android ? I
    d
    • 2
    • 7
  • l

    Lilly

    09/15/2021, 9:30 PM
    [SOLVED] I have a string, something like "Test;Test1;;;;;". Applying
    myString
        .map { it.split(";") }
    gives me a
    List<List<String>>
    where the last items are empty strings because
    split
    interperets ";" as empty string ->
    ""
    . I would like to have
    null
    instead of
    ""
    . How can I achieve this? Output should be
    List<List<String?>>
    a
    • 2
    • 5
  • n

    nilTheDev

    09/16/2021, 6:25 AM
    Woww.... I'm really impressed by Jetpack Compose. Just checkout this UI 👇👇 In traditional XML it would have taken a whole RecyclerView, ViewHolder, DataBinding maybe, a bunch of Gradle dependencies and whatnot 🥵🥵... But in Compose it's just 20 lines of Kotlin code 🤯🤯🤯
    Compose Basic
    t
    g
    • 3
    • 3
  • h

    Hovhannes

    09/16/2021, 1:42 PM
    Hello,  I get this error  'Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference'. How can I fix this issue?
    override fun onBindViewHolder(holder: DataViewHolder, position: Int) {
        holder.bind(users[position])
    
        holder.itemView.textViewUserName.setOnClickListener(View.OnClickListener {
    
            Toast.makeText(it.context, "Pos:$position", Toast.LENGTH_LONG).show()
            MyCustomDialog().show((it.context as MainActivity).supportFragmentManager, "MyCustomFragment")
           it.tv_name.text = users[position].name    //Error
        
        })
    }
    :not-kotlin: 6
    c
    • 2
    • 1
  • n

    Napa Ram

    09/17/2021, 9:47 AM
    HI team i am using Interface for call back, is there any alternative of interface which i can use in kotlin, as i don't have a lifecyclerowner so i can't use LiveData and coroutines
    m
    h
    j
    • 4
    • 5
  • h

    Hovhannes

    09/17/2021, 11:45 AM
    Hello, how can I convert from geohash (example: dj0rtcbpn) to latitude and longitude using Kotlin? What is the best library? Thanks in advance.
    :not-kotlin: 1
    b
    • 2
    • 9
  • d

    Dan Peluso

    09/17/2021, 6:51 PM
    What is the best way to get a screens dp pixel height programmatically? I tried using
    context.display?.getRealMetrics(displayMetrics)
    but that seems to return a much larger value than I'm looking for. I know for Pixel 2 the height is ~730, but I get 1920 when using
    displayMetrics.heightPixels
    . In other words, I'd like to see programmatically which devices will use
    values
    and which will use
    values-h700dp
    :not-kotlin: 4
    • 1
    • 1
  • a

    Ali.F

    09/19/2021, 12:11 PM
    #android Hey guys, there is a rest Api configuration need to be fetched every few days for getting things like last updated base image's url and etc. I was wondering what is the best way for doing that. I really appreciate it if anyone give me the best way for doing that
    :not-kotlin: 6
    u
    • 2
    • 2
  • s

    Sergio C.

    09/19/2021, 12:17 PM
    Whats the fastest/most efficient way to make a deep copy of an object with lists of other objects?
    ☝️ 1
    c
    e
    • 3
    • 3
  • k

    Kulwinder Dhanjal

    09/20/2021, 4:52 AM
    Hello i want to implement search on nested list in my android project by kotlin... i have written this code
    listItems.forEach { widgetData->
        if(widgetData.title.contains(keyword, true)){
            searchedList.add(widgetData)
        }else{
            val filteredWidgets = item.widgets.filter { widget ->
                widget.title.contains(keyword, true)
            }
            if (filteredWidgets.isNotEmpty()) {
                val newItem = WidgetData(
                    id = widgetData.id,
                    title = widgetData.title,
                    isFree = widgetData.isFree,
                    theme = widgetData.theme,
                    thumbnail = widgetData.thumbnail,
                    widgets = filteredWidgets
                )
                searchedList.add(newItem)
            }
        }
    }
    here is my data classes
    data class WidgetData(
        val id: Int,
        val isFree: Boolean,
        val theme: Any,
        val thumbnail: String,
        val title: String,
        var widgets: List<Widget>
    )
    data class Widget(
        val image: String,
        val title: String,
        val type: String
    )
    i am sure there will be a better option in kotlin to write this, i am searching for that..
    e
    • 2
    • 2
  • s

    Slackbot

    09/21/2021, 6:14 AM
    This message was deleted.
    g
    c
    • 3
    • 2
Powered by Linen
Title
s

Slackbot

09/21/2021, 6:14 AM
This message was deleted.
g

gildor

09/21/2021, 7:29 AM
Hello. Your question is not related to Kotlin, please check this channel description and Guidelines for this Slack: https://kotlinlang.org/community/slackccugl.html#common-channels
👍 1
c

codeslubber

09/21/2021, 9:18 PM
I deleted the message??
View count: 2