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
compose
  • s

    shikasd

    06/26/2020, 11:58 AM
    Hey, I am curious if there's a way to subscribe to recompose of composition instance. Essentially something similar to
    addChangesAppliedObserver
    in composer on dev-14, but actually open for external listeners 🙂 The use case is that whenever changes are getting applied, they can result in multiple small updates. I wanted to batch them, so I could dispatch events more efficiently.
    c
    l
    • 3
    • 10
  • e

    estevanfick

    06/26/2020, 12:23 PM
    Hi, there is a way to get a
    Size
    passing through a
    Modifier
    ?
    t
    • 2
    • 1
  • s

    spierce7

    06/26/2020, 1:15 PM
    @romainguy In your compose video, you made it sound like when alpha is released later this summer, that you encourage people using it in applications. Do you mean production applications, because it’s stable, and you are expecting that some APIs are missing, or there might be some slight changes, or do you mean only in non-production applications?
    l
    r
    r
    • 4
    • 5
  • h

    henrikhorbovyi

    06/26/2020, 10:08 PM
    Hello everyone... has anyone faced this error >>>
    java.lang.IllegalStateException: LayoutCoordinate operations are only valid when isAttached is true
    ?
    z
    • 2
    • 3
  • d

    dimsuz

    06/27/2020, 9:26 AM
    Does anyone know if installation instructions are up-to-date? Like do I need Canary to use Compose etc etc.
    :yes: 5
    🙏 1
    k
    • 2
    • 1
  • h

    Hanzhen

    06/27/2020, 11:06 AM
    Hi, how can I desugar the
    Composable
    function in AS? I would like to see what compose compiler does for those functions.
    r
    • 2
    • 1
  • s

    samueldple

    06/27/2020, 4:01 PM
    It seems that in a
    Scaffold
    , the content starts underneath the
    topBar
    but goes to the bottom of the viewport, even if there's a
    bottomBar
    there. I noticed this because the
    VerticalScroller
    I added wasn't scrolling due to the content only just going under the
    bottomBar
    . Is this the correct behaviour, and if so should I be storing the measured height of the bottom bar to fit the main content inside the
    Scaffold
    ?
    z
    m
    • 3
    • 4
  • t

    Timo Drick

    06/27/2020, 11:50 PM
    In Scaffold you can define a bottomBar with a cutout for the FAB. I would like to get the fabButtonBounds in the body to be able to archive something like in this screenshot. (I was already able to hack something together to get it working. But the code is very messy. Also the current cutout path calculation for rounded edges only works when the cutout is at the top)
    m
    • 2
    • 11
  • s

    segunfamisa

    06/29/2020, 6:19 AM
    Hey folks, I was playing with Compose over the weekend, and I tried working with the 
    mutableStateOf()
     replacement suggestions for 
    @Model
    However, when I use a sealed class hierarchy to model my state, e.g like I've done here (https://github.com/segunfamisa/android-zeitung/pull/17/files#diff-03a45e46e60aaa4e3efa4e4e6041dea3R11-R23), I get an exception during IR lowering. The line that stood out for me was: 
    Caused by: java.lang.AssertionError: Object should have a primary constructor: ...
    I'm wondering if this is a technical limitation worth filing as a FR or bug, or something I totally not should be doing?
    l
    m
    • 3
    • 14
  • m

    Miguel Coleto

    06/29/2020, 4:05 PM
    Asking as a total noob on Compose. Can I create a custom view wrapper around a compose function? In other words, can I inflate a custom view with a compose function instead of an XML file?
    z
    a
    • 3
    • 4
  • a

    andylamax

    06/29/2020, 10:48 PM
    What is the difference between these two?
    // 1st
    (view as FrameLayout).setContent(Recomposer.current()) {
    
    }
    
    //2nd        
    (view as FrameLayout).setViewContent {
    
    }
    z
    l
    • 3
    • 6
  • a

    andylamax

    06/30/2020, 1:10 AM
    Is there some sort of provider consumer pattern in compose? If not, how are we going to deal with the similar prop drilling issue that faced the react community? Because it is still obvious that state hoisting is the best approach. But again state hoisting is the mother of prop drilling or in this case, parameter drilling
    l
    m
    y
    • 4
    • 6
  • c

    chris

    06/30/2020, 1:57 AM
    I’m trying to wrap my head around this. I have an observable come back with the data to make a Profile page, however I have to make a second call to display more data to the user afterwards. How could I react when the second set of data comes back and add that to the tree? Example:
    @Composable
    Profile( username: String, name: String, location: String, activityTotals: List<ActivityTotals>? = null )
    The
    activityTotals
    come back afterwards. Since
    Profile
    isn’t an object I can’t expose a property to update with the new value. Would I expose a state or pass in an observable or do something else?
    a
    • 2
    • 10
  • b

    Brady Aiello

    06/30/2020, 5:04 AM
    I have a question about server-driven UI and Jetpack Compose. I've seen what some think are examples of server-driven UI with Compose, but really aren't (UI's not really configurable from the server, just data). So I was thinking, would it be possible to serialize Compose functions from the server, and deserialize them on an Android client? Kotlin closures are serializable, so that includes lambdas and functions. But the Compose compiler plugin needs to work its magic on that Composable function, which it can't do if it's deserializing it at runtime. Is the current way forward with server-driven UI with Compose to create a custom view engine, as current approaches use? Or is there a way to leverage Compose as the engine itself?
    l
    • 2
    • 2
  • g

    gpaligot

    06/30/2020, 7:28 AM
    Hi, I recently upgrade my sample project from
    dev-08
    to
    dev-14
    (yea, a lot of changes x)) and see that you removed
    @Model
    annotation. According to your changelog, you suggest to use
    state
    or
    remember
    delegate functions but when I see your commit in your git repository with this breaking change, I found
    @Stable
    annotation with the exact same behavior as
    @Model
    . Someone can tell me what is this annotation?
    z
    • 2
    • 1
  • a

    Allan Wang

    06/30/2020, 8:06 AM
    New to compose (still reading). Is there a list of framework/androidx views that are supported/have an equivalent in compose? I see there’s constraintlayout and other viewgroups, but was curious about things like material chips, swiperefreshlayout, etc
    a
    v
    • 3
    • 7
  • a

    Allan Wang

    06/30/2020, 9:23 AM
    Are deferred resources supposed to reload in the preview? I’m testing a basic drawable resource load: • Stack overflow indicates several implementations, and most of them seem to have changed (no DrawImage) • The easiest implementation
    imageResource
    is “likely to be removed” due to synchronous loading, and results in an AIOOB exception • The deferred loading pattern seems preferred, but does not seem to redraw once the icon loads. What is the correct approach here for loading resource content? Edit: I now realize there is a difference between
    imageResource
    and
    vectorResource
    , but the latter is also a transient API
    a
    l
    +2
    • 5
    • 14
  • v

    vityokkv73

    06/30/2020, 10:03 AM
    Hi guys, I try to create test application and I need to implement pagination for LazyColumnItems. But I couldn't find how to get current visible item position to trigger loading of next page. Should I just get index of itemContent and compare it with items count?
    m
    a
    +2
    • 5
    • 7
  • m

    molikto

    06/30/2020, 12:01 PM
    Noticed that
    compose-desktop
    can correctly draw something now (not sure if this happend recently, before it is blank for me), I tried to compile compose runtime to iOS but had some issues with cocoutine kotlin-native abi version (
    The abi versions don't match. Expected '[21]', found '22'
    ), after some struggling I give up because I am not actually very familar with MPP.
    a
    j
    • 3
    • 6
  • a

    andylamax

    06/30/2020, 12:15 PM
    When will the
    kotlin-multiplatfrom
    support jetpack-compose compilation?
    d
    • 2
    • 4
  • h

    Hanzhen

    07/01/2020, 1:58 PM
    Hi, why do we choose
    func
    instead of
    class
    to create composable elements?
    func
    is lack of the capability of chain calls, for instance:
    Text("...").font().textColor()
    .
    👀 5
    a
    m
    +4
    • 7
    • 13
  • j

    Joe Masilotti

    07/01/2020, 7:14 PM
    Hi all! I'm new to Android but have been developing iOS for a while. I'm looking to learn what I need to port a SwiftUI app to Android. Is it worth learning on compose? Can I even deploy an app to the Play Store with it? Or would I be better of sticking to the usual practices for now.
    l
    t
    • 3
    • 6
  • a

    Ankur Gupta

    07/01/2020, 7:53 PM
    Hi, what do you think of having an interface like Resource Manager but for Compose functions? Because as I build more and more samples for fun. I found it's hard to find and navigate through UI components which are scattered over many files. The interface may have utilities like - A small preview, click to navigate to code etc.
    ➕ 1
    l
    • 2
    • 1
  • j

    Julius Marozas

    07/01/2020, 8:02 PM
    Hi, I want to request permissions for my app. Can I use
    registerForActivityResult
    function in Compose? In this section of the android documentation it says that you must always call
    registerForActivtyResult
    in the same order in your Fragment/Activity. Can this be achieved in Compose?
    l
    a
    +4
    • 7
    • 24
  • g

    Guy Bieber

    07/01/2020, 9:39 PM
    I am rendering an animated gif, but it does not animate. Any ideas:
    Image(
                            asset = imageFromResource(mResource!!, R.drawable.mutagent)
                        )
    l
    a
    • 3
    • 5
  • h

    henrikhorbovyi

    07/01/2020, 11:39 PM
    Hello everyone! I'm trying to use
    compose
    on a android module. But the project can't find
    buildFeatures
    🤔
    A problem occurred evaluating project
    > Could not find method buildFeatures() for arguments on extension 'android' of type com.android.build.gradle.LibraryExtension.
    a
    • 2
    • 3
  • h

    henrikhorbovyi

    07/02/2020, 2:19 AM
    Why can't I call
    remember
    inside an inline function? 🤔
    l
    • 2
    • 18
  • a

    Adrian Blanco

    07/02/2020, 1:21 PM
    Hi, I'm encountering a bug which I suspect might be State not causing recomposition if updated the same frame it is created (eg https://kotlinlang.slack.com/archives/CJLTWPH7S/p1585902276072100). My use case is that I have a feed view and a detail view which both load images using Picasso. When entering the detail view, the image is already in the cache and loads instantly which seems to make the detail image stuck in the loading state. Placing a
    delay(1)
    seems to make it work as intended, but feels extremely hacky. What would be the idiomatic solution for this?
    val imageState = stateFor<ImageState, String>(imageUrl) { ImageState.Loading }
    
    launchInComposition(imageUrl) {
        delay(1)
        imageState.value = loadImage(imageUrl, targetWidthPx, targetHeightPx)
    }
    l
    a
    c
    • 4
    • 12
  • l

    Lilly

    07/02/2020, 6:07 PM
    Hey guys, I have a question about how to obtain a
    ViewModel
    properly. dev14 added a
    viewModel()
    composable: Let’s say we need a
    ViewModel
    instance in multiple composable functions. Should we explicit obtain the instance via
    viewModel()
    in every composable function or should we obtain it once on top of the compose hierarchy and then pass it the way down?
    s
    • 2
    • 3
  • a

    amar_1995

    07/02/2020, 6:18 PM
    I am playing with
    AndroidView
    and trying to integrate legacy pagination library but I am getting this error
    jetified-kotlin-stdlib-1.3.71.jar: Runtime JAR file has version 1.3 which is older than required for API version 1.4
    h
    • 2
    • 8
Powered by Linen
Title
a

amar_1995

07/02/2020, 6:18 PM
I am playing with
AndroidView
and trying to integrate legacy pagination library but I am getting this error
jetified-kotlin-stdlib-1.3.71.jar: Runtime JAR file has version 1.3 which is older than required for API version 1.4
My code
AndroidView(resId = R.layout.paginated_main) {
val myAdapter = MyAdapter()
myList.adapter = myAdapter
lifecycleScope.launch {
@OptIn(ExperimentalCoroutinesApi::class)
myModel.state.collectLatest { myAdapter.submitData(it) }
}
}
h

henrikhorbovyi

07/02/2020, 8:36 PM
If you figure it out tell me please, cause I got the same error 😄
a

amar_1995

07/02/2020, 8:51 PM
I believe
compose-runtime
is using older version internally. I tried including
compose-runtime
package in gradle in legacy android code and then it also leads to same issue.
h

henrikhorbovyi

07/02/2020, 9:02 PM
What version are you using? dev14?
a

amar_1995

07/02/2020, 9:23 PM
Yes
h

henrikhorbovyi

07/02/2020, 9:49 PM
Same here. 😞 I returned to
dev13
and it solved
a

amar_1995

07/02/2020, 10:07 PM
And I tried using older paging library
'androidx.paging:paging-runtime-ktx:2.1.2'
and that resolves the issue
h

henrikhorbovyi

07/03/2020, 12:58 AM
Cool! 👏 At least it worked
View count: 2