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
android
  • f

    Fred Bowker

    12/04/2022, 10:54 AM
    I’m fairly new to android dev so at the moment basing an architecture on https://github.com/android/nowinandroid
    c
    a
    • 3
    • 3
  • t

    the great warrior

    12/04/2022, 6:54 PM
    Hi guys, I have a data store preference value named CURRENT_INPUT and I want to pass it to mutableStateFlow as initial value, but I don't know how to do it. Here's the code.
    @Singleton
    class DataStorePreference  @Inject constructor(@ApplicationContext context: Context) {
    
        private val dataSource = context.dataStore
    
        companion object {
            const val CALCULATOR_USER_PREFERENCES = "CALCULATOR_USER_PREFERENCES"
            val CURRENT_INPUT = stringPreferencesKey("CURRENT_INPUT")
        }
    
        suspend fun <T> getPreference(key: Preferences.Key<T>, defaultValue: T):
                Flow<T> = dataSource.data.catch { exception ->
            if (exception is IOException) {
                emit(emptyPreferences())
            } else {
                throw exception
            }
        }.map { preferences ->
            val result = preferences[key] ?: defaultValue
            result
        }
    }
    @HiltViewModel
    class CalculatorViewModel @Inject constructor(
        private val dataStorePreferenceRepository: DataStorePreferenceRepository
    ) : ViewModel() {
        // pass CURRENT_INPUT preference value to mutableStateFlow initial value
        private val _currentInput: MutableStateFlow<String?> = MutableStateFlow(null)
        val currentInput =  _currentInput.asStateFlow()
    
        suspend fun<T> getPreference(key: Preferences.Key<T>, defaultValue : T) =
            dataStorePreferenceRepository.getPreference(key, defaultValue)
    }
    j
    • 2
    • 1
  • e

    Eugene Maksymenko

    12/04/2022, 11:50 PM
    Huge update of WorldWindKotlin KMP 3D map engine with a lot of bugfixes released! https://github.com/WorldWindEarth/WorldWindKotlin/releases/tag/v1.1.3
  • s

    Slackbot

    12/05/2022, 9:40 AM
    This message was deleted.
    s
    t
    • 3
    • 3
  • e

    Elio Maroun

    12/05/2022, 11:01 AM
    is swipeTorefresh deprecated in jetpack compose and i should replace it with pullrefresh??
    t
    c
    • 3
    • 2
  • r

    Robert St. John

    12/05/2022, 5:38 PM
    hello all. i'm using Room and i have an entity class with 23 properties. the entity's primary key is a natural key that comes from a remote source. my preference would be to use a data class and that only the primary key property participates in the auto-generated
    equals()
    and
    hashCode()
    methods. i also would prefer that all properties of the class are immutable, so the class is more like a functional style data type, and i would appreciate having kotlin auto-generate the
    copy()
    method with the selective override parameters. however, i can't seem to achieve all these things at the same time because if i create the data class with only the primary key property in the primary constructor, Room needs public setters for the rest of the properties, and i will not get the
    copy()
    method with parameters for all the non-constructor properties. if i put all immutable properties in the primary constructor, i lose the desired
    equals()
    and
    hashCode()
    semantics and i also have concerns about the overhead of that many properties participating in those methods. has anyone tried/been able to achieve this with a data class? my current solution is a standard class with all immutable properties in the primary constructor, and a copy constructor that takes a source instance argument, then individual override parameters for all the properties, but that's a bit of headache and error-prone to maintain
    p
    • 2
    • 3
  • c

    Chrimaeon

    12/05/2022, 5:44 PM
    The easiest solution will again be separation of concerns. You should create a separate class for each domain it is used for. I.e. the room database data class and then a class that you create where you only have the primary key in the equals and hashcode functions. If you don’t want to do that, you can still override equals and hashCode yourself even on a data class.
    r
    • 2
    • 1
  • s

    Saadat Sayem

    12/06/2022, 4:47 AM
    New piece of cake from Google itself! Check this out 🤤 https://goo.gle/3Y17KE0
  • a

    AmrJyniat

    12/06/2022, 7:40 AM
    I noticed that when registering
    OnPageChangeCallback()
    to the
    viewPager
    like this:
    binding.viewPager.registerOnPageChangeCallback(pageChangeListener)
    Then, the
    onPageSelected()
    fun is called immediately, can I prevent this behavior(calling the fun on the first initialized)?
  • v

    Vivek Sharma

    12/06/2022, 9:53 AM
    When having
    BottomSheet
    , I am
    not able to have fix footer
    , footer just can not be fixed I mean at bottom and behind the footer, I am doing scrolling and things, so how can we achieve that?
    j
    s
    • 3
    • 5
  • l

    Louis

    12/06/2022, 4:04 PM
    You know if I can use Glance widgets on react native ? I don't know where I can any answer
    a
    • 2
    • 1
  • a

    Abdulaziz Mohammed

    12/07/2022, 5:28 AM
    How to implement long polling with retrofit?
  • s

    Shagun Chahar

    12/07/2022, 6:27 AM
    How to delay a loop
    j
    • 2
    • 1
  • s

    Shagun Chahar

    12/07/2022, 6:27 AM
    Like the loop complete too fast
  • s

    Shagun Chahar

    12/07/2022, 6:27 AM
    I want some time after each iteration
  • s

    Shagun Chahar

    12/07/2022, 6:27 AM
    Can anybody help??
  • s

    Shagun Chahar

    12/07/2022, 9:09 AM
    Unable to call input function
    e
    g
    • 3
    • 5
  • e

    Elio Maroun

    12/07/2022, 12:24 PM
    https://stackoverflow.com/questions/68857820/how-to-share-a-viewmodel-between-two-or-more-jetpack-composables-inside-a-compos
  • e

    Elio Maroun

    12/07/2022, 12:24 PM
    Hello , does SaveStateHandle do the same job? So we can use the ViewModel in the last saved state in another screen ??
  • d

    dead.fish

    12/07/2022, 2:22 PM
    So I stumbled (yet again) upon a name shadowing issue where I’d like the compiler to warn me that my choice is ambiguous, but I don’t know if this is yet something that the Kotlin compiler supports. Imagine the following code:
    import android.os.Bundle
    import androidx.fragment.app.DialogFragment
    import androidx.fragment.app.Fragment
    
    class OuterFragment : Fragment() {
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            
            MyDialogFragment.create(Bundle()).apply {
                show(childFragmentManager, "DIALOG")
                    // ^--- this should be this@OuterFragment.childFragmentManager
            }
        }
    }
    
    class MyDialogFragment : DialogFragment() {
        companion object {
            fun create(bundle: Bundle): MyDialogFragment =
                MyDialogFragment().apply {
                    arguments = bundle
                }
        }
    }
    Any hints how I could make
    childFragmentManager
    yellowish in the IDE?
    k
    • 2
    • 2
  • g

    Guilherme Delgado

    12/08/2022, 1:45 AM
    I’m trying to send a broadcast command with
    ProcessBuilder
    . It “works”, but the output is different if I run the same command via terminal:
    ~ adb shell am broadcast -p com.sample -a sample.action -e "extra" "bla bla"
    produces (correctly):
    Broadcasting: Intent { act=sample.action flg=0x400000 pkg=com.sample (has extras) }
    Broadcast completed: result=0
    but the same command via
    ProcessBuilder
    produces:
    Broadcasting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x400000 pkg= -p }
    Broadcast completed: result=0
    any idea why? 🤔
    d
    p
    +2
    • 5
    • 11
  • b

    Bhargav Pandya

    12/08/2022, 2:22 PM
    Anybody face Webview Performance(ANR) issue due to Accessibility Service Enabled ? Particularly it is happening on vertical fast scrolling. If faced then any solution for fixing this?
  • y

    Yacov Rosenberg

    12/08/2022, 6:51 PM
    Hi Guys, Any one with experience with canvas? Im developing a simple real time drawing app. Basically I'm sending trough web socket the path offsets that the user is drawing. And I'm drawing it in the app that is listening. But I'm facing a problem when I draw it on large phone and receive in a small phone, I think is because of pixels difference. So I wanted to know what the approach to make it work correct? eg.:
    l
    c
    +4
    • 7
    • 23
  • s

    Slackbot

    12/09/2022, 1:40 PM
    This message was deleted.
    c
    • 2
    • 1
  • j

    Justin Tullgren

    12/09/2022, 5:03 PM
    Hi, I am trying to develop a library module that only compiles with the androidx fragment library using
    compileOnly
    as the actual runtime dependency will be provided by a user of the library. This works fine for normal compiling, but compiling the android test class path throws an IR error:
    No such enum entry LIBRARY_GROUP_PREFIX
    I have tried adding the annotations as an
    implementation
    and
    testCompileOnly
    and
    androidTestImplementation
    dependency but I can't get passed that IR error. Does anyone have a workaround or solution? Thanks!
  • m

    Michael Langford

    12/09/2022, 8:20 PM
    Questions about verification-metadata.xml/verification metadata error reporting with Android studio and downloaded artifacts. Google doesn't always seem to update the hash files for libraries well (for instance, aapt for windows doesn't seem to have the right hashes right now for one version, but this happens from time to time). I've noticed some kotlin-specific extensions don't always update the hashes reliably as well. I'm assuming this is a very standard thing to happen per my own observed frequencies. It has happened enough with a kotlin extension or two I often skip those at this point and just work off the plain library (which is why this doesn't deserve the :not-kotlin: marker, some of those extensions look great). Is there some standard mechanism to point out these checksum mismatches to teams somewhere I may be unaware of? Am I missing out on some "major/minor" version convention which is the only time these checksums may be correct? Are there any great public key trackers for the OSS kotlin community I should be paying specific attention to (especially related to the seemingly useful but often out of sync kotlin extensions to libraries). Are there other libraries/tools I should be paying specific attention to?
  • r

    rishabhsinghbisht

    12/10/2022, 3:27 PM
    Is there any example on how to work with
    kotlinx.parcelize.RawValue
    can’t find much.
  • n

    Nat Strangerweather

    12/11/2022, 3:49 PM
    Is there a way in Kotlin to deal with an encoded String so that the hyperlink address does not appear? Like in this example: "Ministers have rebuffed an offer by nursing unions to suspend <a href="https://www.theguardian.com/society/2022/nov/09/nurses-in-uk-vote-to-go-on-strike-for-first-time-in-dispute-over-pay">planned strikes</a> in return for negotiations on pay". What I would like instead would be "Ministers have rebuffed an offer by nursing unions to suspend planned strikes in return for negotiations on pay".
    c
    • 2
    • 3
  • g

    gts13

    12/11/2022, 8:30 PM
    Can someone tell me if we need to use Dispatcher.IO for DataStore or it already runs in a background thread under the hood like Room does?
    • 1
    • 1
  • g

    gts13

    12/11/2022, 8:38 PM
    then why nowinadnroid does this and pass a Dispatchers.IO
    c
    • 2
    • 1
Powered by Linen
Title
g

gts13

12/11/2022, 8:38 PM
then why nowinadnroid does this and pass a Dispatchers.IO
c

Chrimaeon

12/11/2022, 9:53 PM
To be under control of the dispatcher used in data store. I.e. if you unit test the module you can pass a blocking dispatcher.
View count: 9