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

    07/06/2022, 12:51 PM
    Custom Keyboard With RecyclerView How can we set recyclerview as custom keyboard view instead of the Keys inside the keyboard view. The custom keyboard that I am trying to achieve is a options picker keyboard rather than the one that types. I have seen most of the custom keyboards allows to create typeable keypad but how can we replace it with the recyclerview to show lists and pick them.
  • u

    user

    07/06/2022, 1:11 PM
    How to make StateFlow<Model> polymorphic in Androd? I am at stage when I would like to expose my StateFlow() into the common BaseViewModel() class to implement common operations on it without repeating them in others implementations of ViewModels. I ended up with one idea, but faced with several limitations when has built PoC. My idea and its limitations are below, your solutions for origin question are welcomed. I split my model into interface and one concrete implementation. sealed interface Model { var isLoading: Boolean var errors:...
  • u

    user

    07/06/2022, 1:51 PM
    API fetch gets called twice - Retrofit I'm fiddling with public imdb-api, but the free version has only 100 api calls available daily. I've noticed my function responsible for fetching data is being called twice. I'm exactly sure why is that. Any tips apprecieated. ApiService interface interface ApiService { /** * Get top 250 Movies */ @GET("en/API/Top250Movies/{apiKey}") suspend fun getMovies(@Path("apiKey") apiKey : String) : MovieList /** * Get detailed info about a title with certain ID...
  • u

    user

    07/06/2022, 1:51 PM
    How to make Scrollview automatically scroll to the bottom when RadioButton is clicked How to make Scrollview automatically scroll to the bottom when RadioButton is clicked May I know How to make the Scroll view automatically scroll down to the next_button when any of the Radio Button is clicked , in the same time I need to call "setMeal() method from the ViewModel when the Radio Button is clicked....
  • u

    user

    07/06/2022, 3:11 PM
    Controlling network connectivity on Android I am making a sample app, only to see, how to monitor the network connectivity on Android. For that I follow this document: https://developer.android.com/training/monitoring-device-state/connectivity-status-type Since I am not getting the results I expected, I decided to create this post hoping to get some relevant feedback from experienced users. My source code,...
  • u

    user

    07/06/2022, 3:31 PM
    Kotlin Function Generics - Upper Bound Not Working I faced some issue regarding usage of Kotlin generics in functions fun doSomething(): T { return String() as T } class Something(intValue: Int) Something(doSomething()) // Doesn't show any compile error Now when it is executed it throws error java.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Number Wanted to know why Kotlin compiler is not throwing error for incompatible typecasting
  • u

    user

    07/06/2022, 3:51 PM
    how can I go from groggy to kotlin Dsl protobuf I am applying Proto DataStore and I am applying protobuf in my Kotlin Dsl gradle but I can't implement it correctly. enter the code here. plugins { id("com.android.library") id("org.jetbrains.kotlin.android") id("kotlin-kapt") id("dagger.hilt.android.plugin") id ("com.google.protobuf") version "0.8.12" } protobuf { protoc { artifact = "com.google.protobuf😛rotoc:3.14.0" } generateProtoTasks { all().each { task -> task.builtins {...
  • u

    user

    07/06/2022, 3:51 PM
    How returning of data from addOnSuccessListener{} works in Kotlin? I am trying to get user data from Firebase Firestore database , I am intended to get info of user who is currently logged in. Now for make this information accessible from other Classes I created get method for username and email, when I used get method from Another class , I got an indexOutOfBoundsException with list index 0,size 0. How am I supposed to return data from inside of addOnSuccessListener(), And what is the reason my array is empty although I added the data on it package...
  • u

    user

    07/06/2022, 4:11 PM
    How can I navigate to a particular fragment on app B after opening my app with intent from another app B I have an app A that directs user to another app B when the user clicks on update on app A.The app B contains a MainActivity which holds the fragment container and there are only 3 fragments. The first fragment is a splash screen, the second fragment contains a recycler view of all the apps, and when a user clicks any of the recycler view item, the name of the app on the recycler item is passed as a narvargs, and it takes the user to the third fragment, on the third fragment, which is the...
  • u

    user

    07/06/2022, 4:31 PM
    variable reset to initialize value after for each loop After change value of finalQuizID in if condition in foreach loop, it reset to initialize value in spite of condition is true. My Code: class SelectQuizActivity : AppCompatActivity() { private lateinit var binding: ActivitySelectQuizBinding private val mFireStore = FirebaseFirestore.getInstance() private var finalQuizID: String = "NULL" override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = ActivitySelectQuizBinding.inflate(layoutInflater)...
  • u

    user

    07/06/2022, 4:31 PM
    Databinding adapter doesn't provide data to recycler view I have 2 fragments in my mvvm application that both have different view models but fetch data from the same repository. The first one shows a list of entities which are presented in the recycler view, the second one is for adding a new entity to the database. I also use data binding in my application. The problem appears, when I navigate from the first fragment to the second one and then update room data by adding a new entity to it, but when I pop up to the first on - my recycler view is...
  • u

    user

    07/06/2022, 4:31 PM
    Kotlin Room Database: How to save result from sum query? I´m new to Kotlin and trying to learn it by programming an app for work time recording. I´ve created a room database which works fine when inserting data. In the next step I would like to retrieve the sum of a column and store this value in a variable. And this is the point where I get stuck. Here are the affected snippets of my code. data class sumPojo(var sumOvertime: Double) @Dao interface OvertimeDao { @Query(value = "SELECT SUM(overtime) as sumOvertime FROM...
  • u

    user

    07/06/2022, 4:51 PM
    Bug Firebase sent event add_to_card with item_price I sent the item bundles with params from Google examples and get results in the debug console like this: Why can't i get a normal double price?
  • u

    user

    07/06/2022, 6:31 PM
    How to send data another page and list with kotlin? I just started learning Kotlin. I am making an application that saves bank (IBAN) information. I save the information locally using sharedpreferences. I save the information to the list and save it as sharedpreferences. Information is recorded on page 2 and I want to list this recorded information on page 1. I was doing this simply in Flutter, but I couldn't understand how to do it in Kotlin.

    https://i.stack.imgur.com/2kzeX.png▾

    <a...
  • u

    user

    07/06/2022, 7:11 PM
    (It's not connected with not having the internet Or with enabling auth in firebase menu) ignoring header X-Firebase-Locale because its value was null Firebase problem!(It's not connected with not having the internet in emulator Or with enabling auth in firebase menu) When i created login and password everything worked fine after that i connected Realtime database and since that i get an error "ignoring header X-Firebase-Locale because its value was null." When i delete database and leave only registration and login everything works fine. // change means what i changed since i created realtime database import...
  • u

    user

    07/06/2022, 7:11 PM
    Kotlin not executable

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

    Hi, I tested a simple Kotlin program but it does not print out anything. What would be the causes? Thanks.
  • u

    user

    07/06/2022, 7:11 PM
    How to setup for each loop in Kotlin to avoid out of bounds exception In java I got this construction for (let i = 0; i < x.length-1; I++ And here to avoid outOfBoundsException we are using x.length-1 but how to do the same thing in Kotlin? I got this code so far x.forEachIndexed { index, _ -> output.add((x[index+1]-x[index])*10) } And it crashes on the last element when we call x[index+1] so I need to handle the last element somehow
  • u

    user

    07/06/2022, 8:11 PM
    Getting ERR! Missing script: "test", when running git commit -m "commit message"
    git commit -m "commit message"
    npm ERR! Missing script: "test" npm ERR! npm ERR! To see a list of scripts, run: npm ERR! npm run npm ERR! A complete log of this run can be found in: npm ERR! /Users/user/.npm/_logs/2022-01-25T15_32_42_915Z-debug-0.log husky - pre-commit hook exited with code 1 (error) The .husky/pre-commit script includes an npm test which looks for that script inside package.json. The test script doesn't exist and I can only commit with the --no-verify flag to...
  • u

    user

    07/06/2022, 8:11 PM
    Okio source cannot be read inside a Kotlin Coroutine I am trying to generate a Bitmap from an Okio source using this implementation val file = /* ... */ Okio.source(file).use { CoroutineScope(Dispatchers.IO).launch { Okio.buffer(source).use { bufferedSource -> val bitmap = BitmapFactory.decodeStream(bufferedSource.inputStream()) withContext(Dispatchers.Main) { view.setImageBitmap(bitmap) } } } } Thing is, the resulting bitmap is null and I get the following...
  • u

    user

    07/06/2022, 8:31 PM
    Cannot create kotlin class in itellij idea Cannot find the "create kotlin class" option when I right click on src inside a kotlin project in intellij idea! Doing an online course where they tell to create a kotlin class by right clicking on src but I cannot find it in the latest version
  • u

    user

    07/06/2022, 8:31 PM
    What is opposite to 'in' condition in Kotlin - '!` mark equivalent to Java In Java we do use ! in case we want to say NOT. But what should I use in Kotlin if I follow some range condition. if( item in 5..10) So here I want to say if item NOT in 5..10 ?? what is the proper construction?
  • u

    user

    07/06/2022, 8:51 PM
    How to call async/await method without using GlobalScope.launch{} in Kotlin I am trying to use async/await in kotlin to make calls to an api. I already created the method and it works! but now I don't know how to call it in an activity or in a viewmodel WITHOUT using GlobalScope.launch {} ?? There is another way ? class Service{ var client: OkHttpClient = OkHttpClient(); fun getRequest(sUrl: String) =GlobalScope.async { Thread.sleep(2000) var result: String? = null try { // Create URL val url = URL(sUrl)...
  • u

    user

    07/06/2022, 9:11 PM
    Why replace char doesn't work for Kotlin while calling regular replace on char function [duplicate] I am calling replace() on a string to change the chars but for some reason it does not change it. var result = "Hi!" result.replace('i','z') In logs I still see Hi!
  • u

    user

    07/06/2022, 9:31 PM
    Custom GSON deserializer My response returning colors as strings. So I can get background color like "home_background" etc. I then take string and convert it to color from resource with same name. I do not want to do this in View ( Composables ) I want to create gson deserializer to parse it. Here is my data class: data class QuestionTile( override val id: String, override val type: String, override val author: Author, override val createdDate: String, override var text: PostText?, override...
  • u

    user

    07/06/2022, 9:31 PM
    Circular progress bar in android which rotate like pendulam I want to create a circular progress bar in android that should behave like a pendulum.

    https://i.stack.imgur.com/AyDAv.gif▾

    I have tried multiple libraries online like this https://github.com/lopspower/CircularProgressBar but not able to achieve using this library. I tried using layer-list but looking for some decent way to achieve this behavior...
  • u

    user

    07/07/2022, 12:11 AM
    ./ci/android-wait-for-emulator.sh: No such file or directory I got a gitlab-ci yaml with a build stage and a test stage. The build stage runs successfully but the test stage keeps trowing the next error:

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

    gitlab-ci: image: jangrewe/gitlab-ci-android stages: - build - test - export GRADLE_USER_HOME=$(pwd)/.gradle - chmod +x ./gradlewbefore_script: cache: key: ${CI_PROJECT_ID} paths: - .gradle/ build: stage: build script: - ./gradlew assembleDebug artifacts:...
  • u

    user

    07/07/2022, 1:11 AM
    Kotlin Serialization for Generic Objects...? I had the bright idea to implement a generic object and attempt to serialize / deserialize it, and received this error: Serializer for class 'DetailsRequest' is not found. Mark the class as @Serializable or provide the serializer explicitly. I thought the @Serializer annotation would have achieved this... ??? The implementation of the data class, and its custom serializer (which is probably overkill), are as follows: @Serializable(with=DetailsRequestSerializer::class) data class...
  • u

    user

    07/07/2022, 2:51 AM
    How to add a list of composables as parameter Im trying to pass a list of Composables, in this case Columns, as a parameter to later populate a view, for that I'm adding the parameter List Unit)> on a composable function and populating a List with simple Columns. The problem I'm having is that the Columns generate a Type mismatch Required: List Found: List Is there a way to achieve this? Here I'll provide my code. @Composable fun LotsOfColumns() { ColumnListSample( myColumns = listOf( Column {},...
  • u

    user

    07/07/2022, 2:51 AM
    How do I use flavorDimensions for setting up Environements I am creating a dummy app for testing purposes. The Android app crashes every time I use flavorDimensions. I am new to setting up Android environments and any help would be greatly appreciated. Please help. flavorDimensions "tier" productFlavor { dev { dimension "tier" minSdkVersion rootProject.ext.minSdkVersion applicationId "com.awesomeproject.dev" targetSdkVersion rootProject.ext.targetSdkVersion...
  • u

    user

    07/07/2022, 6:51 AM
    arrow ensure doesn't make value non nullable after check have a question about ensure function, somehow it doesn't make null safe after check in either block. What I am doing wrong, or is there a better way to ensure that value is not null except of using !! here is my code suspend fun checkCanConnectDirectChat( senderId: Int?, receiverId: Int?, chatRoomId: Int? ) = either { ensure(chatRoomId != null && receiverId != null) { BadRequestExceptionResponse(message = ErrorConstants.INVALID_PAYLOAD) } val isSenderInChat...
Powered by Linen
Title
u

user

07/07/2022, 6:51 AM
arrow ensure doesn't make value non nullable after check have a question about ensure function, somehow it doesn't make null safe after check in either block. What I am doing wrong, or is there a better way to ensure that value is not null except of using !! here is my code suspend fun checkCanConnectDirectChat( senderId: Int?, receiverId: Int?, chatRoomId: Int? ) = either { ensure(chatRoomId != null && receiverId != null) { BadRequestExceptionResponse(message = ErrorConstants.INVALID_PAYLOAD) } val isSenderInChat...
View count: 5