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

    M-iTech

    04/29/2022, 10:07 PM
    Hi 👋 Kotlin Community ❤️ I'm Mohamed
    👋 8
    👋🏾 1
    👋🏼 1
    t
    • 2
    • 1
  • t

    the great warrior

    05/01/2022, 1:11 AM
    hi guys, is there anyway I know if the user changes the position of the phone from landscape to portrait and vice versa ?
    :not-kotlin: 5
    :stackoverflow: 3
    :yes: 4
    c
    • 2
    • 1
  • n

    Nathan Kleinschmidt

    05/01/2022, 3:13 PM
    How do we configure serialization now with Ktor 2.0 on an Android client? This example for previous versions is deprecated and no longer works:
    client = HttpClient(Android) {
        install(JsonFeature) {
          serializer = KotlinxSerializer()
        }
    }
    The migration guide says to use the content negotiation plugin, but there are no examples of how to do this on Android that I can see.
    d
    a
    • 3
    • 9
  • m

    Maku Mazakpe

    05/01/2022, 10:02 PM
    Hello, ive followed these https://github.com/ma-za-kpe/compose-samples/tree/main/Jetsnack instructions on how to run a sample app in AS, but I get this error, can anyone help? FAILURE: Build failed with an exception. * What went wrong: com.intellij.openapi.externalSystem.model.ExternalSystemException (no error message) * Try:
    Run with --info or --debug option to get more log output.
    Run with --scan to get full insights.
    * Exception is: com.intellij.openapi.externalSystem.model.ExternalSystemException: at org.jetbrains.plugins.gradle.model.ProjectImportAction.addBuildModels(ProjectImportAction.java:346) at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:127) at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:42) at org.gradle.tooling.internal.consumer.connection.InternalBuildActionAdapter.execute(InternalBuildActionAdapter.java:64) at org.gradle.tooling.internal.provider.runner.AbstractClientProvidedBuildActionRunner$ActionAdapter.runAction(AbstractClientProvidedBuildActionRunner.java:131) at org.gradle.tooling.internal.provider.runner.AbstractClientProvidedBuildActionRunner$ActionAdapter.fromBuildModel(AbstractClientProvidedBuildActionRunner.java:104) at org.gradle.tooling.internal.provider.runner.AbstractClientProvidedBuildActionRunner$ActionAdapter.fromBuildModel(AbstractClientProvidedBuildActionRunner.java:84) at org.gradle.internal.buildtree.DefaultBuildTreeModelCreator.fromBuildModel(DefaultBuildTreeModelCreator.java:57) at org.gradle.internal.buildtree.DefaultBuildTreeLifecycleController.lambda$fromBuildModel$1(DefaultBuildTreeLifecycleController.java:82) at org.gradle.internal.buildtree.DefaultBuildTreeLifecycleController.lambda$runBuild$4(DefaultBuildTreeLifecycleController.java:106) at org.gradle.internal.model.StateTransitionController.lambda$transition$6(StateTransitionController.java:166) at org.gradle.internal.model.StateTransitionController.doTransition(StateTransitionController.java:238) at org.gradle.internal.model.StateTransitionController.lambda$transition$7(StateTransitionController.java:166) at org.gradle.internal.work.DefaultSynchronizer.withLock(DefaultSynchronizer.java:44) at org.gradle.internal.model.StateTransitionController.transition(StateTransitionController.java:166) at org.gradle.internal.buildtree.DefaultBuildTreeLifecycleController.runBuild(DefaultBuildTreeLifecycleController.java:103) at org.gradle.internal.buildtree.DefaultBuildTreeLifecycleController.fromBuildModel(DefaultBuildTreeLifecycleController.java:74) at org.gradle.tooling.internal.provider.runner.AbstractClientProvidedBuildActionRunner.runClientAction(AbstractClientProvidedBuildActionRunner.java:43) at org.gradle.tooling.internal.provider.runner.ClientProvidedPhasedActionRunner.run(ClientProvidedPhasedActionRunner.java:53) at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) at org.gradle.internal.buildtree.ProblemReportingBuildActionRunner.run(ProblemReportingBuildActionRunner.java:49) at org.gradle.launcher.exec.BuildOutcomeReportingBuildActionRunner.run(BuildOutcomeReportingBuildActionRunner.java:69) at org.gradle.tooling.internal.provider.FileSystemWatchingBuildActionRunner.run(FileSystemWatchingBuildActionRunner.java:119) at org.gradle.launcher.exec.BuildCompletionNotifyingBuildActionRunner.run(BuildCompletionNotifyingBuildActionRunner.java:41) at org.gradle.launcher.exec.RootBuildLifecycleBuildActionExecutor.lambda$execute$0(RootBuildLifecycleBuildActionExecutor.java:40) at org.gradle.composite.internal.DefaultRootBuildState.run(DefaultRootBuildState.java:128) at org.gradle.launcher.exec.RootBuildLifecycleBuildActionExecutor.execute(RootBuildLifecycleBuildActionExecutor.java:40) at org.gradle.internal.buildtree.DefaultBuildTreeContext.execute(DefaultBuildTreeContext.java:40) at org.gradle.launcher.exec.BuildTreeLifecycleBuildActionExecutor.lambda$execute$0(BuildTreeLifecycleBuildActionExecutor.java:65) at org.gradle.internal.buildtree.BuildTreeState.run(BuildTreeState.java:53) at org.gradle.launcher.exec.BuildTreeLifecycleBuildActionExecutor.execute(BuildTreeLifecycleBuildActionExecutor.java:65) at org.gradle.launcher.exec.RunAsBuildOperationBuildActionExecutor$3.call(RunAsBuildOperationBuildActionExecutor.java:61) at org.gradle.launcher.exec.RunAsBuildOperationBuildActionExecutor$3.call(RunAsBuildOperationBuildActionExecutor.java:57) at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204) at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199) at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66) at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59) at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157) at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59) at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53) at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73) at org.gradle.launcher.exec.RunAsBuildOperationBuildActionExecutor.execute(RunAsBuildOperationBuildActionExecutor.java:57) at org.gradle.launcher.exec.RunAsWorkerThreadBuildActionExecutor.lambda$execute$0(RunAsWorkerThreadBuildActionExecutor.java:36) at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:270) at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:119) at org.gradle.launcher.exec.RunAsWorkerThreadBuildActionExecutor.execute(RunAsWorkerThreadBuildActionExecutor.java:36) at org.gradle.tooling.internal.provider.ContinuousBuildActionExecutor.execute(ContinuousBuildActionExecutor.java:103) at org.gradle.tooling.internal.provider.SubscribableBuildActionExecutor.execute(SubscribableBuildActionExecutor.java:64) at org.gradle.internal.session.DefaultBuildSessionContext.execute(DefaultBuildSessionContext.java:46) at org.gradle.tooling.internal.provider.BuildSessionLifecycleBuildActionExecuter$ActionImpl.apply(BuildSessionLifecycleBuildActionExecuter.java:100) at org.gradle.tooling.internal.provider.BuildSessionLifecycleBuildActionExecuter$ActionImpl.apply(BuildSessionLifecycleBuildActionExecuter.java:88) at org.gradle.internal.session.BuildSessionState.run(BuildSessionState.java:69) at org.gradle.tooling.internal.provider.BuildSessionLifecycleBuildActionExecuter.execute(BuildSessionLifecycleBuildActionExecuter.java:62) at org.gradle.tooling.internal.provider.BuildSessionLifecycleBuildActionExecuter.execute(BuildSessionLifecycleBuildActionExecuter.java:41) at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:63) at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:31) at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:58) at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:42) at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:47) at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:31) at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:65) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104) at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:39) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104) at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:29) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104) at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:35) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104) at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.create(ForwardClientInput.java:78) at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.create(ForwardClientInput.java:75) at org.gradle.util.internal.Swapper.swap(Swapper.java:38) at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:75) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104) at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104) at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:63) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104) at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:84) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104) at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:52) at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48) java.lang.NullPointerException
    :thread-please: 5
    f
    • 2
    • 2
  • h

    hawklike

    05/02/2022, 7:11 AM
    Hi, I am using the databinding and ViewModel with the repository pattern. My repository is exposing Flow that contains Result wrapper (indicates Loading, Success or Failure state). I could convert Flow to LiveData in ViewModel and observe (and handle) changes in a fragment, but since I am using databinding, it seems to me as one extra step. Therefore, is there a way how to safely collect flows in the ViewModel?
    d
    • 2
    • 2
  • g

    George Toppo

    05/02/2022, 11:20 AM
    Hi, I wanted to know that in jetpack compose what is best way to optimize app for different Screen Size and dpi. In my current project in many place we are using Hard-coded DP and SP for defining layout Size or padding it is looking good in xhdpi device's but it becomes weird on smaller Devices. What is common way to solve this issue ??? I also did some search and only post I found is this. but I still wanted to know if there is any other or easier way to do it. https://proandroiddev.com/supporting-different-screen-sizes-on-android-with-jetpack-compose-f215c13081bd
    a
    • 2
    • 1
  • j

    Josh Yun

    05/02/2022, 12:38 PM
    Hi, I have a question regarding kotlin reflection. Does anyone have experience with (sealed class).sealedSubclasses? It always returns empty list if I apply obfuscation. Here’s the definition of classes
    sealed class Data
    
    object DataChild1 : Data()
    
    object DataChild2 : Data()
    and this is what I am trying to do:
    val dataList = Data::class.sealedSubclasses.mapNotNull { it.objectInstance }
    It works fine when I do not apply obfuscation.
    • 1
    • 1
  • s

    Sergio C.

    05/03/2022, 3:38 PM
    Hi! Has anyone tested -Xcontext-receivers ? How do I enable it in the project?
    • 1
    • 1
  • m

    Mjahangiry75

    05/03/2022, 6:40 PM
    hello How to test
    StateFlow
    if I use
    stateIn
    function then I can't test the
    stateFlow
    using
    CoroutineTestRule
    code in thread
    • 1
    • 1
  • t

    the great warrior

    05/03/2022, 11:01 PM
    Hi guys I used the Inuit library in my app in order to support multiple screen sizes but when I runed my app in multiple emulators and physical devices I found Inuit didn’t work properly with devices that have 480 screen width or more, what should I do ?
    :not-kotlin: 4
    a
    • 2
    • 2
  • n

    nuhkoca

    05/04/2022, 5:21 PM
    Hello, I need to sort a list of items by their prices. Sorting criteria is like this; • When sorting low to high, negative values need to always be before positive ones. The highest negative value being at the top and the highest green value being at the bottom • When sorting high to low, vice versa However, some items may have null price. Let’s say there is a negative trending item with null price so then all negative values that have non-null price need to come first before those that have null price. However, I can’t make it work in no way. I am using
    nullsLast
    with combination of
    compareBy
    but it is not working. Do you know what’s wrong? I tried;
    sortedWith(nullsLast(compareBy { it.price }))
    ✅ 1
    r
    • 2
    • 10
  • l

    Lisandro Di Meo

    05/05/2022, 1:38 PM
    Hello ! I'm building a wear os app using compose, and using
    SwipeDismissableNavHost
    I've found that the swiping gesture is ignoring the
    BackHandler
    inside the composable. For example, if my nav graph is: A -> B -> C, and the swipe from C should redirect to A. I think I have to custom some behavior of the SwipeToDismissBox, but I'm not sure how. Any help is appreciated!
    composable(
        Paths.WORD,
        arguments = listOf(navArgument("language") { defaultValue = "EN" })
    ){ navBackStackEntry ->
        BackHandler() { navController.navigate(Paths.HOME) }
        CompleteWord(navController, listState, completeWordViewModel, navBackStackEntry.arguments?.getString("language")!!.toLanguage())
    }
    :nice: 1
    • 1
    • 1
  • n

    Nandu

    05/05/2022, 4:17 PM
    Hi all, I am developing a Android library with one API exposed to encrypt a file. It returns the Flow. On the client app I have a list of files for which I need to encrypt. Can you please let me know how to chain all the calls for the list of files to be encrypted and run in parallel and get all the encrypted content once so that I can do the further processing.
    😒uspend: 1
    :not-kotlin: 4
    :kotlin: 1
    c
    • 2
    • 2
  • z

    Zoltan Demant

    05/06/2022, 5:32 AM
    Does anyone know if there is any work being done to "normalize" exceptions thrown by compose? I often find that while the stack traces themselves are mostly identical, the source will point to seemingly random things -
    View
    ,
    ViewGroup
    , `BaseContinuationImpl`; usually things that are not directly related to whats actually causing the crash (which is often times a bug in compose, or me abusing it too much).
    r
    • 2
    • 2
  • a

    Ali

    05/06/2022, 11:41 AM
    Which one is better? With
    data class
    or only
    class
    ? I can only see the flexibility of using
    copy()
    fun when its data class. Any others pros/cons?
    sealed class Errors(open val errorCode: String) {
        data class SomeError(
            override val errorCode: String
        ) : Errors(errorCode)
    }
    
    OR 
    
    sealed class Errors(open val errorCode: String) {
        class SomeError(
            override val errorCode: String
        ) : Errors(errorCode)
    }
    s
    d
    • 3
    • 6
  • h

    Hritik

    05/07/2022, 6:53 AM
    Hello everyone, can someone help me out with this? Recently I was trying to implement a swipe like feature same as that in Tinder, so I chose to use a library for it https://github.com/yuyakaido/CardStackView. I also added the dependencies for it in the build,gradle(app) file. But I'm unable to access it inside my activity. It says "class could not be found" Please have a look at the screenshots below for reference
    :not-kotlin: 2
    c
    j
    • 3
    • 5
  • a

    Atsushi Usui

    05/08/2022, 7:07 AM
    Hi there. I'm implementing a photo gallery with Jetpack Compose. The URI obtained from ContentResolver is passed to AsyncImage of Coil library. It works. However, every time the app is restarted, the images are reloaded, which causes a slight time lag in the display. I think caching the small thumbnail images needed for display to disk will speed up loading, but Coil's disk cache only works with HTTP Fetcher. Do you have a good idea? Should I implement a disk cache myself?
    r
    • 2
    • 2
  • t

    Tran Thang

    05/09/2022, 2:43 AM
    Hi guys, I have question as below:
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP)
    Can you guys explain why have “or” in the code as above?
    e
    • 2
    • 4
  • n

    Nikolas Guillen Leon

    05/09/2022, 9:45 AM
    Log.d(TAG, descriptionResult.errorMessage.toString())
     intervention.value = intervention.value?.copy(
      descriptionError = descriptionResult.errorMessage,
      timeError = timeResult.errorMessage
    )
    Log.d(TAG, "intervention: ${intervention.value?.descriptionError}")
    return
    :thread-please: 2
    l
    d
    • 3
    • 5
  • f

    Fisayo

    05/09/2022, 10:16 PM
    Hi guys, I'm new to Kotlin (and coding in general) and I need help and guidance with some codes, I have created four activities on Android studio, and I am trying to use "Intent" to navigate from one activity to the other....My code worked well when moving from MainActivity to the second activity (Genderpg, but when I tried moving from the 2nd Activity to the third (AgePg02), the Emulator keeps returning me back to the Main activity.....here are images of my code...
    :stackoverflow: 4
    :not-kotlin: 7
    l
    r
    • 3
    • 5
  • j

    jun hamington

    05/10/2022, 4:04 PM
    hey 👋 such a pleasure to see y'all. i'm jun learning computer thingy. also am working for the graduation projects so joined here to find something to learn or to give help for others if i can!
    :android-wave: 5
    r
    • 2
    • 3
  • s

    Slackbot

    05/10/2022, 5:04 PM
    This message was deleted.
    :not-kotlin: 2
    c
    l
    • 3
    • 6
  • n

    Nguyen Van Phuc B

    05/11/2022, 2:19 AM
    Hi guys ❤️ I'm having an issue where show dialogFragment will disappear when from background re-open app. Is there a way the dialog doesn't go away when I reopen the app?
    :not-kotlin: 6
    s
    • 2
    • 1
  • s

    Shira Mandelbaum - SafeUP

    05/11/2022, 8:05 AM
    Hey, I want to use a background coroutine that calls some API each X seconds, where should I call it if I’m using few activities and view models and I want to start this job in one place and what should scope should I use? Thank you!
    :not-kotlin: 2
    r
    a
    • 3
    • 2
  • c

    Ciprian Grigor

    05/11/2022, 4:39 PM
    I wonder why Gradle Kotlin kts is not generated instead of groovy by default or at least to be an option to choose, also there are multiple errors in Android Studio Preview
    👍 2
    l
    • 2
    • 1
  • j

    jun hamington

    05/12/2022, 1:24 PM
    hay, mates! i just wanted to ask this: i've started learning kotlin for the first time and this thing is not working. 😔 it was successfully working on my windows laptop, but it doesn't work on my macbook. my test app has a button and image view. when you click the button, then you'll see the gallery to pick your image file. after picking, the picked image will be shown on the image view. i have the same code that i wrote on my windows laptop and also, android studio says the build is successful without any error so i checked it on the emulator and it's not getting launched. 😢
    a
    • 2
    • 6
  • j

    jun hamington

    05/12/2022, 1:26 PM
    OH PLUS, startActivityForResult and onActivityResult are deprecated. do i have any alternative? i googled it and read some articles on stackoverflow or something like that, but it didn't work with those clingy red underlines. 😒miling_face_with_tear: thank you… 🥹
    :not-kotlin: 3
    a
    • 2
    • 2
  • a

    Aaron Waller

    05/12/2022, 6:14 PM
    Is this a bug? Why is it passing through the != null check eventhough it is null?
    t
    • 2
    • 7
  • l

    lawlorslaw

    05/12/2022, 7:17 PM
    Is this considered to be executed on the main thread? How do you execute a coroutine on the background thread? to be clear
    exchangeRepository.getExchanges()
    is the call to the
    suspend
    function.
    Untitled.kt
    j
    c
    e
    • 4
    • 19
  • t

    therealbluepandabear

    05/13/2022, 8:16 AM
    var toReturn: PixelArt? = null
    
        CoroutineScope(<http://Dispatchers.IO|Dispatchers.IO>).launch {
            AppData.pixelArtDB.pixelArtCreationsDao().getAllPixelArtCreations().observe(this@extendedGetCurrentPixelArtObj.findViewTreeLifecycleOwner()!!) {
                toReturn = it[currentIndex]
            }
        }
    
        return toReturn!!
    :thread-please: 2
    u
    • 2
    • 7
Powered by Linen
Title
t

therealbluepandabear

05/13/2022, 8:16 AM
var toReturn: PixelArt? = null

    CoroutineScope(<http://Dispatchers.IO|Dispatchers.IO>).launch {
        AppData.pixelArtDB.pixelArtCreationsDao().getAllPixelArtCreations().observe(this@extendedGetCurrentPixelArtObj.findViewTreeLifecycleOwner()!!) {
            toReturn = it[currentIndex]
        }
    }

    return toReturn!!
:thread-please: 2
u

Umar Ata

05/13/2022, 8:23 AM
you can’t observe in worker thread
t

therealbluepandabear

05/13/2022, 8:26 AM
K then what should I do instead, this is very confusing 2 me sir
Please give advice on how to structure this call/similar calls asynchronously
u

Umar Ata

05/13/2022, 8:31 AM
there are many ways to handle it. 1. create a variable in viewmodel (LiveData) and initialize it when you call room function that returns livedata and observe this variable in fragment or activity so when the room return data your live data that you are observing will produce data in fragment, 2. get Flow from room and use it asLiveData in viewModel and observe it in fragment one thing to note when you deal with flow or livedata do not expect your function to return any value directly
https://developer.android.com/codelabs/android-room-with-a-view-kotlin#0
try this
t

therealbluepandabear

05/13/2022, 8:33 AM
Thank u g, appreciated
View count: 20