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
stackoverflow
  • u

    user

    06/27/2022, 10:31 PM
    How is mockk's allAny() used I can't find any documentation on allAny() that I can understand. The official documentation describes it as a "special matcher that uses any() instead of eq() for matchers that are provided as simple arguments". I don't understand what that means. I have a line that goes every { mockObject.method(any(), any(), any(), any(), any(), any(), any(), any(), any()) } returns 0 I thought allAny() might be able to replace repeated use of...
  • u

    user

    06/27/2022, 10:51 PM
    Kotlin Worker Pool - Long Running Kotlin Coroutine and Java Heap OutOfMemory I'm trying to replicate a Worker Pool in Kotlin: https://gobyexample.com/worker-pools It works wonderful, but my problem is that I get OutOfMemoryError because all object references from the worker coroutines are kept in the heap as long as the coroutine is running. How can I avoid this problem? Here is my code: I create a channel in Service A and receive the data everytime a channel object is received. class...
  • u

    user

    06/27/2022, 10:51 PM
    CardView CheckBox Empty Space I am making a very simple Android app using Kotlin that has a checkbox list. The checkbox only works when I click on the box itself or the text beside it. My question is: How do I check the boxes by clicking on the empty spaces next to the texts?

    How to check boxes by clicking the empty space?â–¾

  • u

    user

    06/27/2022, 10:51 PM
    Kotlin multi platform flow block convert to custom wrapper flow use for ios I have a kotlin multi platform project which contains apollo graphql api in this project i have BaseRepository Class and in this class there is a method to execute query or mutations suspend fun executeQuery(query: Query): ApolloResponse { val response = getApolloClient().query(query).execute() checkOperation(response) return response } suspend fun executeMutation(mutation: Mutation): ApolloResponse { val response =...
  • u

    user

    06/27/2022, 11:11 PM
    How to implement a recycler view inside a viewpager2 Basically, I want to add a recycler view inside a viewpager2 which will have 3 tabs that can be swiped left/right to switch tabs, and in each tab there will be present the recycler view which can be swiped vertically. But every time I try to do that either viewpager2 is working (when the height of viewpager2 is set to match parent) or the vertically scrollable recycler view (when the viewpager2 height is set 0dp) I am not getting any solutions from anywhere.(I am using kotlin for my app) For...
  • u

    user

    06/27/2022, 11:11 PM
    How to access GcpKmsClient instance I'm following this offical Tink how-to: https://github.com/google/tink/blob/master/docs/JAVA-HOWTO.md Everything works as expected after some fiddling, but I noticed that default constructor for GcpKmsClient is deprecated, and the following is recommended: GcpKmsClient.register( Optional.of(masterKeyUri), Optional.of(pathToSaKeyFile) ) Question is: How do I get access to the...
  • u

    user

    06/28/2022, 12:31 AM
    How to get the list of values that belong to a group after groupBy operation in Kotlin? I have the following data: import kotlin.test.* import java.util.* data class Sales(val year: Int, val price: Int) val myList = listOf( Sales(2017, 10), Sales(2017, 19), Sales(2020, 15), Sales(2021, 100), Sales(2020, 20), ) I want to see how to get the list of values for each group. For example, I want the result as {2017=[10, 19], 2020=[15, 20], 2021=[100]}
  • u

    user

    06/28/2022, 12:51 AM
    Why can't you change a property value permanently in kotlin? Here's the code: class Person(var firstName: String, var lastName: String) { var fullName: String = firstName + lastName fun fullName() = firstName + lastName override fun toString(): String { return fullName() } } fun main(){ val test = Person("test", "fortest1") test.lastName = "fortest2" println(test.fullName) } The result will only be testfortest1. It looks like you are working with a copy of test once test is created.
  • u

    user

    06/28/2022, 2:11 AM
    For Kotlin/JS project conversion I'm getting type mismatch: inferred type is XXX but ZIndex? was expected When trying to add a z-index to a Kotlin JS project the documentation doesn't provide an example: https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.css/-c-s-s-style-declaration/z-index.html css { zIndex = 12 } I need to know what's the right way to assign a z-index in Kotlin-JS. So far I tried to use 12.px but I get errors such as: Type...
  • u

    user

    06/28/2022, 3:31 AM
    How to declare Singleton instance in Kotlin , is it similar to how we declare Singleton class? In an interview I was told to write a Singleton class so I wrote the following code object Ant{ } but later he asked me to write Singleton instance which confused me and I ended up writing like this object what{ } now, I know I am wrong but I am really curious how to write down Singleton Instance.
  • u

    user

    06/28/2022, 4:11 AM
    What is "androidx.lifecycle.BundlableSavedStateRegistry.key" in this bundle? I'm using toolargetool to investigate why the app is crashing from TransactionTooLargeException. I'm seeing there's this key androidx.lifecycle.BundlableSavedStateRegistry.key which can be around 400 KB when I put the app into the background. What is this key and where is it coming from? How can I reduce the size of this in the bundle?
  • u

    user

    06/28/2022, 4:31 AM
    Label doesn't scale down correctly to 0.07f, but if I use font.setUseIntegerPositions(false), it shows both label and font in libGDX I try to make a label to display "You Win" and add it to winStage, but I cannot manage to display the label correctly on winStage. Some words don't show on the screen, and if I downscale further than 0.044f, the String disappears. when I add font.setUseIntegerPositions(false) to my code, the font shows correct, but the wrong label also shows. Is there a way to get this work? (hide the wrong label or get the label shows correctly), code uses Kotlin, but very similar to java <a...
  • u

    user

    06/28/2022, 4:31 AM
    Math in development((( Sup, guys! I have a task to calculate coordinates of continuation line between points A & B. I have a code each calculate distance between these points, and I have tangent of angle for calculating next points D and F. Thanks for any help

    https://i.stack.imgur.com/cGyU0.pngâ–¾

    https://i.stack.imgur.com/6NPuY.pngâ–¾

    `val pointA = LatLng(a.latitude, a.longitude) val pointB = LatLng(b.latitude, b.longitude) val...
  • u

    user

    06/28/2022, 5:11 AM
    Shares of Lifecycle Livedata ViewModel with ViewBinding I'm still new to kotlin. So I want to try lifecycle, livedata, and viewModel in my study project, using moviedb as its data. But since Android Kotlin Extensions dependency is deprecated, I have to use viewBinding as an alternative, but when I run the app, it goes error like this: 2022-06-28 11:39:19.935 25250-25250/? E/AndroidRuntime: FATAL EXCEPTION: main Process: id.kotlin.belajar, PID: 25250 java.lang.RuntimeException: Unable to start activity...
  • u

    user

    06/28/2022, 5:11 AM
    How to Create module class for work manager dependency in kotlin I have a Worker class that needs an app repository class and the app repository class depends on the API service class. API service class in an interface. I do not know how to create a module class that provides dependency for the Worker class. I create a module class below @Module @InstallIn(ViewModelComponent::class) object ApiModule { @Provides fun provideLaunchListApi(retrofit: Retrofit): API { return retrofit.create(API::class.java) } I doubt that I am not passing correct input for...
  • u

    user

    06/28/2022, 5:51 AM
    How can I execute multiple instructions for a when condition in Kotlin? I am trying to execute multiple lines of execution for a when condition in Kotlin, without using an if-else statement. However, kotlin is complaining and returning an error. How can this be achieved? For example: when(studentAnswer2){ quizAnswer2 -> points+=25 quizAnswer2-1 -> points += 20 println("The answer $studentAnswer2 is within 1 point of $quizAnswer2") quizAnswer2+1 -> points += 20 println("The answer $studentAnswer2 is within 1 point of...
  • u

    user

    06/28/2022, 6:11 AM
    Switch video subtitles with ExoPlayer while a video is still playing Let's say I have two subtitles for a video, how do you switch an exoplayer's subtitles while the video is playing without resetting the player itself? Like for an example when a user click a button By following the exoplayer documentation, my current implementation is like this: binding.button.setOnClickListener { val k = player.currentPosition // Get the latest player's current position subtitle =...
  • u

    user

    06/28/2022, 6:11 AM
    Google Pay API for OCR/Card Scanning Has anyone integrated google pay api OCR in the android application. https://developers.google.com/pay/payment-card-recognition/debit-credit-card-recognition Also can I just use OCR feature from the API without using any other payment features. Any help is appreciated
  • u

    user

    06/28/2022, 7:11 AM
    arrow validation more then 10 fields all I have a question how can I validate more then 10 values with arrow in kotlin. fun CreateEventDTO.validate(): Validated = name.isEventNameValid() .zip( about.isAboutValid(), phone.isPhoneValid(), price.isPriceValid(), location.isLocationValid(), startDate.isStartDateValid(), // TODO add common validation for date // endDate.isEndDateValid(), status.isEventStatusValid(), access.isEventAccessValid(),...
  • u

    user

    06/28/2022, 7:51 AM
    Android problem creating multiple AutoCompleteTextViews dynamically I want to dynamically create input views, which each contain an AutoCompleteTextView. Each AutoCompleteTextView shows a Dropdown list. I have defined an item view (item_new_product.xml), which gets inflated and added to the viewContainer (activity_main.xml). Each AutoCompleteTextView has defined a dropDownAnchor in xml, which is the view ID of its parent TextInputLayout. This is where the dropdown list should show up. For the first item the Dropdown appears in the right place (see <a...
  • u

    user

    06/28/2022, 8:11 AM
    Connecting to URL requires authentication in Kotlin I'm beginner in kotlin. I'm try to connect to my http service, wich requires authentication. Have error: Unresolved reference: Authenticator How can I set Authenticator? var url = URL ("https://myURL") val authenticator = object : Authenticator() { val passwordAuthentication: PasswordAuthentication? get() = PasswordAuthentication( "user", "password".toCharArray() ) }
  • u

    user

    06/28/2022, 8:51 AM
    Generate producer function based on yml configuration I'm not even sure if this is possible, but it would be really amazing. I have some configuration in my yaml file. Does anyone know it is possible to kind of generate a javax.enterprise.inject.Produces function from this? My initial thought would be to use some kind of for loop, but then I would be doing something in a function itself, and I'm not sure whether it would be picked up.
  • u

    user

    06/28/2022, 8:51 AM
    Jetpack Compose: TextField grows outside of AlertDialog If you run the following composable and enter a long multiline text into the textfield, you will see that as the text grows, it leaves the AlertDialog. Is there a way to fix this? Ideal would be if it would grow to a certain point and then start scrolling. import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.material.* import androidx.compose.runtime.* import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview @Preview @Composable fun...
  • u

    user

    06/28/2022, 9:11 AM
    How to print paging flow data in kotlin I want to know is there any way to print data in console when use collect function. activity.kt lifecycleScope.launchWhenCreated { viewModel.dataList.collect { adapter.submitData(it) } } viewmodel.kt val dataList = Pager(config = PagingConfig( pageSize = 1 ), pagingSourceFactory = { ViewPagerPagingSource(currentDateLimitDataSource) }).flow
  • u

    user

    06/28/2022, 9:51 AM
    android modern development: how can I understand user did not changed any data in a screen? I built a fragment, using jetpack compose for adding views on screen and state and view model classes for saving state. first time when I navigate to this fragment, fetch API is called and If I have any value on this API, I filled text fields with them. It is possible that the API is empty and do not return any value. Users can enter any data on this text fields or can ignore them because filling the text fields is optional and when he/she clicks on submit button; the data is saved in server...
  • u

    user

    06/28/2022, 9:51 AM
    Not sure what context does an inner flow operate on I have a question about the context in which an inner flow produces flow produces. Consider the following code. withContext(Dispatchers.Main) { val flowA = flowOf(1,2,3,4) val flowB = flowOf("a","b","c") flowA.flatMapConcat { num-> val bResponse = flowB.first() //would this operate on Dispatchers.Main OR IO flowOf(bResponse) }.flowOn(Dispatchers.IO) } } I have a nested flow and I am unsure on what context would the...
  • u

    user

    06/28/2022, 10:31 AM
    RxJava Unit test Observable interval I have a network polling function with Observable interval in my repository class repository @Inject constructor( private val api: api, private val schedulerProvider: SchedulerProvider ) { private fun networkPoll(): Observable { return Observable.interval(1L, TimeUnit.Seconds, schedulerProvider.io()) .startWith(0L) .flatMap { api.getStatus().subscribeOn(schedulerProvider.io()).toObservable() } } private fun...
  • u

    user

    06/28/2022, 10:51 AM
    How to set One to many relation in android room DB in kotlin I have two tables. First table is as below @Entity data class GramPanchayatSurveyEntity( @PrimaryKey var gpCode: Int, var distCode: Int, var locationTypeCode: Int, var location: String, var latitude: String, var longitude: String, var googleLocation: String, var distanceBtwHeadQrToGp: String, var recommendedHeightOfTower: String, var BBNL_Exist: String, var anyCongestion: String, var nearByGpCode: Int, var surveyBy: String,...
  • u

    user

    06/28/2022, 10:51 AM
    Kotlin set lazy field through Java reflection I'm trying to play around with Java reflection in Kotlin, and I have the following field in my Kotlin class: val tree: Tree by lazy { getTree(hashGroup, service) } I'd like to set this field through Java reflection, and so far I got to this point: val tField = transaction::class.java.getDeclaredField("tree\$delegate") tField.isAccessible = true tField.set(transaction, newTree) Obviously this is not going to work, because the tree field has a delegate (tree$delegate) and it wants me to...
  • u

    user

    06/28/2022, 10:51 AM
    How to design circular step progress indicator in native android Please help me to achieve step progress indicator as shown below in android. I could not find any relevant library to achieve this.
Powered by Linen
Title
u

user

06/28/2022, 10:51 AM
How to design circular step progress indicator in native android Please help me to achieve step progress indicator as shown below in android. I could not find any relevant library to achieve this.
View count: 3