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

    07/19/2022, 8:21 PM
    Proper use of mutableStateflow with Launcheffect in jetpack compose Hey I am working in MutableStateFlow in jetpack compose. I am trying to load spinner in next screen but it's not working. I am started learning jetpack compose. I didn't find the proper way in jetpack compose. I know MutableStateFlow in legacy way. I'll try explain what I am trying to do and what I want to achieve. I have a Button in the composable function, when I press the Button I am going into the viewModel and calling the api inside viewModelScope.launch. On that basis I have create a...
  • u

    user

    07/19/2022, 8:21 PM
    Add public getter in Java to protected field in Kotlin? I am doing some refactoring to a base class in Kotlin. It looks like the following: abstract class Base constructor (protected val prop: Int) { //... } I have an implementation in Java that wants to expose prop via a public getter. Is this possible? public class Impl extends Base { public Int getProp() { return prop; } } Causes an error like the following: Impl.java:269: error: getProp() in Impl cannot override getProp() in Base public Int getProp() {...
  • u

    user

    07/19/2022, 9:41 PM
    ViewPager2, FragmentStateAdapter, and conflict between pager's currentItem and adapter's createFragment's position parameter When implementing ViewPager2 and its associated FragmentStateAdapter for its contents in Kotlin, I ran into a weird issue: It has to do with the adapter's createFragment(position: Int) method and viewPager2's setCurrentItem(item: Int, smoothScroll: Boolean). Currently, implementing this for an adapter of size 2 items is fine, being able to start from position 0 of the view pager and able to change items as intended. The issue then comes from attempting to set the viewPager's currentItem value...
  • u

    user

    07/19/2022, 10:01 PM
    doOnTextChanged in infinite looping I'm trying to delete the last character in case it's a number in Android's EditText. However, I am falling into an infinite loop. The logic I'm implementing is the following: If the user types a number in the first 4 characters, the doOnTextChang event is called and validated if it's a number. After validation, it removes the last character. However, after removing the last character, it understands that it is to be called again, thus being in a loop and freezing the application. var isNum:...
  • u

    user

    07/19/2022, 10:21 PM
    Test Suite in kotest I don't know if I am missing something but I could not find anything that says how to do a test suite like in JUnit. Can someone help me? I saw that documentation offers grouping tests, but when I run from Gradle, the logs are really large, and not very useful
  • u

    user

    07/19/2022, 11:01 PM
    Android + Kotlin + Hilt: Error building project I'm new to Hilt, and I'm struggling my head in order to implement it in my multi-module app. After infinite attempts the build error varies from "error a" to "error b", then "error c" and so. This is how I've started implementing Hilt into my multi-module app: Project build.gradle: buildscript { ext.kotlin_version = '1.7.10' repositories { jcenter() google() } dependencies { classpath 'com.android.tools.build:gradle:7.2.1' classpath...
  • u

    user

    07/19/2022, 11:21 PM
    GraphQL DGS- Kotlin, Modify the parent resultSet, based on Child dataloader results class UserEntity(val id: UUID, val name: String, val email: String){ val occupation: String? =null } class AddressEntity(val id:UUID){ val line1: String, val line2 : String, val city: City, val state: State, val zipcode: ZipCode @ManyToOne @JoinColumn(name = "user_id", referencedColumnName = "id") var user: UserEntity } class UserResolver(private val userService: UserService) { @DgsQuery(field = DgsConstants.QUERY.GetUsers) fun getUsersByLocation( dfe:...
  • u

    user

    07/19/2022, 11:21 PM
    Java/Kotlin libraries for image rendering I'm looking for simple library or some approach in native libraries to draw some shapes, text etc. by some logic, save as PNG and deliver it. For example, the input is the string "2+2". At the output, I need a picture in PNG format, which shows 4. I tried googling it but found mostly GUI solutions (like AWT) or different libraries for image processing, like resizing, crop etc.
  • u

    user

    07/19/2022, 11:41 PM
    Spring Boot Jpa Kotlin - Not a Managed I am getting the following error attempting to run my kotlin spring boot application. Caused by: java.lang.IllegalArgumentException: Not a managed type: class zielinskin.kotlinsample.data.SampleEntity Trying to create a least possible code example repo with kotlin on the latest spring boot and kotlin, but am struggling. I am using OpenJDK 18. I have tried with and without enable repositories annotation, Int and Integer for id, multiple types of entity scans (and without), but nothing seems...
  • u

    user

    07/19/2022, 11:41 PM
    How to center CustomItem in LazyRow vertically so that each item is in the center of The LazyRow? I tried using a ContraintLayout to center it vertically as shown below. Nothing happens after I run the app, it stays in the same position. However, I used this same code snippet in my button and it seems to center it along side LazyRow. Note: I am trying to accomplish this without modifying padding Logic I am trying to use to center vertically (NOT WORKING) Box( modifier = Modifier .padding(top = padding, bottom = padding) .constrainAs(item) {centerVerticallyTo(lazyRow)}, //...
  • u

    user

    07/20/2022, 12:21 AM
    Android retrofit async api calls won't work after adding okHttp interceptor to check for network connection We have both asynchronous and synchronous calls implemented using retrofit and Either to map success/error. After adding the network interceptor asynchronous calls are returning bad responses(works fine on postman). I have tried adding a general error JSON response thinking Either is not able to catch the exceptions but still no luck. please suggest a fix or new approach Interceptorclass - override fun intercept(chain: Interceptor.Chain): Response { val request = chain.request() try...
  • u

    user

    07/20/2022, 1:21 AM
    How to get connection join/left event in ktor I want to implement the record of adding client connections in ktor's websocket, but I can't find the corresponding document. Is there a way to achieve this? like this install(websockets) ... routing { onOpen(session){ ... } }
  • u

    user

    07/20/2022, 2:01 AM
    Set Shared Preferences data only on install I want to set the user name in my application only once per install. We don't have to worry about if the user clears the data or not. How can I achieve this ?
  • u

    user

    07/20/2022, 2:41 AM
    Is there any way to prevent the bottom navigation bar from moving during rotation? Im trying to get my bottom navigation bar to be fixed on a side of the screen. Let me use pictures to help you understand what I am hoping to achieve.

    https://i.stack.imgur.com/AHUX8.png▾

    As you can see, I am trying to achieve the navigation bar to stay in its same position (i.e. top when in portrait but changed to left in landscape), and the icon buttons in the navigation should be rotated. I remember seeing certain apps do this before but I am...
  • u

    user

    07/20/2022, 3:01 AM
    Kotlin: Keyword cannot be used as a reference fun main() { print("This is a calculator") print("enter your first number") val no1 = readLine()!! print("enter your operation") val operation1 = readLine()!! print("enter your second number") val no2 = readLine()!! val result = if(operation1 == '*') print("$val no1 * $val no2") } It keeps coming up with Kotlin: Keyword cannot be used as a reference. I am very new to kotlyn and I am just trying to create a basic calculator. PLease help.
  • u

    user

    07/20/2022, 3:21 AM
    How to cancel progress bar of Main Activity when moving to a Fragment? I show a spinning progress bar before beginning a fragment. The run debugger shows that it is still running after the fragment is running and functioning. Is there a proper way to end it? I simply want the user to know that something is happening while they wait (network connections, etc). To expand a bit, the run monitoring of the emulator shows many lines like D/eglCodecCommon: setVertexArrayObject and these don't occur if I comment out the View.VISIBLE line of code...
  • u

    user

    07/20/2022, 4:01 AM
    Data class being used by other classes as parameter I want to use data classes to store user input and computed results. Then convert the data classes to Entity and update the data base. The problem is I'm not clear on the best practices for using data classes. I have read the documentation : https://kotlinlang.org/docs/data-classes.html along with other sources. However, they don't have more complex examples of how different classes are supposed to access...
  • u

    user

    07/20/2022, 4:21 AM
    flutter error: Execution failed for task ':app:compileFlutterBuildDebug' who can help me with this error that I have been trying to solve for almost 2 days and I have not been able to.

    Image 1▾

    Image 2▾

    I have done several things, removed flutter and reinstalled it, flutter clean and flutter pub get and tried to update all the dependencies but nothing has worked, what do you think it could be? Thank you very much in...
  • u

    user

    07/20/2022, 4:41 AM
    Showing DialogFragment from RecyclerView in Kotlin [duplicate] I have a DialogFragment that I want to show when clicking on an item inside a Recycler View. Here are my files: DialogFragment.kt: class TaskDialogFragment:DialogFragment() { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { var rootView: View = inflater.inflate(R.layout.task_dialog, container, false) return rootView } } RecyclerViewAdapter.kt: class RecycleViewAdapter():...
  • u

    user

    07/20/2022, 5:41 AM
    Webview gives error while leaving from my app js error Hey stackoverflow I am redirecting user to Webview from my app the redirection url is host on my server which is working fine on my device but in my testing its not working for some other devices. Error which i found from logcat is : I/chromium: [INFO:CONSOLE(478)] "Uncaught TypeError: Cannot set property 'innerHTML' of null", source: https://secure-acs2ui-b1-indmum-mumrdc.wibmo.com/v1/acs/legacy/live/8547/M.P/uid=fd076e4c-afc4-44b2-99f5-97a0bC3lD7qB (478) My webview function is :...
  • u

    user

    07/20/2022, 6:01 AM
    setText of the TextInputEditText does not change - Kotlin Hey fello developers 🖐️ I've been trying to change the text value of the TextInputEditText programatically to save the activity state on orientation as it gets lost, but the setText(text: CharSequence!) doesn't work even when passing explicit String as its arguments. Here's a snippet of the code of the activity in activity_main.xml And here's the Kotlin code in MainActivity.kt lateinit var uriTxt: TextInputEditText override fun onCreate(savedInstanceState: Bundle?) {...
  • u

    user

    07/20/2022, 6:41 AM
    How to wait result from OKHTTP response without freezing app Kotlin? I am writing a small application in Kotlin with JetpackCompose and my application freezes (CountDownLatch) when a request is called, is there any way to avoid this? Without CountDownLatch, okhttp does not have time to return the result before the method completes. MainActivity.kt fun infoServer() { val viewModel = ViewModelProvider(this).get(MainActivityViewModel::class.java) var txt = remember { mutableStateOf(0) } Column( horizontalAlignment =...
  • u

    user

    07/20/2022, 7:01 AM
    Android Paging 3 remoteMediator infinitely load(APPEND) data with Compose I'm trying to implement a list with Paging 3 library using RemoteMediator. Initial loading is OK. Mediator loaded only 3 pages, which is set in 'PageConfig'. But When scroll the list until trigger extra loading for more data, then Mediator starts loading data infinitely until it returns MediatorResult.Success(endOfPaginationReached = true) (Which means all data in remote was loaded). Even though scrolling is stopped. I have no idea what makes Mediator keep loading. I want Mediator to load...
  • u

    user

    07/20/2022, 7:01 AM
    KMM how can I add custom value to Bundle.main.infoDictionary I have kotlin multiplatform project. I know that I can read from infoDictionary (infoplist) data in runtime with: val value = NSBundle.mainBundle.infoDictionary?.get("customValue") My question, how can I add customValue to infoDictionary as part of build process, in build.gradle.kts of shared. it.binaries.framework { baseName = "shared" embedBitcode("disable") // here I want to infoDictionary.add("customValue", myValue) }
  • u

    user

    07/20/2022, 7:21 AM
    Drawables not loading with coil in release build after applying dexguard I am using coil(Kotlin) library to load drawables. Working fine in debug build but after generating release build with dexguard no drawable loads. Library I am using implementation("io.coil-kt:coil:1.1.0") ivGlowingCircles.load(R.drawable.glowing_circles)
  • u

    user

    07/20/2022, 7:21 AM
    How to show BottomSheetDialog below toolbar I'm trying to achieve something that looks like in the image below.

    https://i.stack.imgur.com/6JUkr.jpg▾

    It's a sheet shown from the top and is below the toolbar. It also has dimmed background. I was able to show the sheet from the top as you can see in this video with the help of <a...
  • u

    user

    07/20/2022, 7:41 AM
    Update ProgressBar in aAdapter I want to show a progressBar when upload files to server. I can get progress values according to written bytes of file. But I can not update the progress bar. The problem is progress bar is filled to max immediately. xml: In adapter I used a higher order function to get viewHolder. So in this way I can access the progress bar outside of Adapter and use it. var holderCallback: ((RecyclerView.ViewHolder?) -> Unit) = { } override fun onBindViewHolder(holder: FileViewHolder,...
  • u

    user

    07/20/2022, 7:41 AM
    does coroutines in Kotlin work like threads? So I am trying to learn kotlin coroutines for networking purposes on Android but I don't understand how they work. What am I missing in the code to make it work like a thread (the two counters should mix together ) ? Should I use something else than runBlocking {} ? import kotlinx.coroutines.* suspend fun counter(a: Int) { for(n in 0..a) { print(n.toString() + " ") } } fun main() { runBlocking { counter(10) launch { counter(10) }...
  • u

    user

    07/20/2022, 8:01 AM
    How to update a Webflux object from repository and save it back I want to 1) get an object from my repository, 2) update that object and then 3) save it back. I've already done first two things: fun updateUniversity(id: ObjectId, newName: String, newCity: String, newYearOfFoundation: Int): Mono { return universityRepository .findById(id) .switchIfEmpty(Mono.error(NoSuchElementException())) .map { if (newCity.isNotEmpty()) it.city = newCity if...
  • u

    user

    07/20/2022, 8:21 AM
    What does the @ next to a Class instance mean? I have a question while using IntelliJ IDEA, Android Studio Debug. What does the number next to @(at) mean? No matter how hard I look for development references, I can't find them. There are a number in brackets and a number without brackets. They have different numbers. I am curious about the difference I guess it is the unique hash value of the class instance, but I wonder what it means more accurately. <a href="https://i.stack.imgur.com/aoCKh.png" rel="nofollow noreferrer">enter image...
Powered by Linen
Title
u

user

07/20/2022, 8:21 AM
What does the @ next to a Class instance mean? I have a question while using IntelliJ IDEA, Android Studio Debug. What does the number next to @(at) mean? No matter how hard I look for development references, I can't find them. There are a number in brackets and a number without brackets. They have different numbers. I am curious about the difference I guess it is the unique hash value of the class instance, but I wonder what it means more accurately. <a href="https://i.stack.imgur.com/aoCKh.png" rel="nofollow noreferrer">enter image...
View count: 4