https://kotlinlang.org logo
#compose
Title
# compose
a

amar_1995

01/31/2020, 12:56 PM
I updated my project from dev03 to dev04 and get this error.
java.lang.ClassCastException: androidx.compose.GroupStart cannot be cast to androidx.ui.foundation.ScrollerPosition
It was working fine in dev03. Can anyone help me to resolve this error and why this is occuring ??
i

Ian Warwick

01/31/2020, 1:32 PM
not had this one yet, did it link to where in the code its failing? did you update the dependencies with new compiler etc?
a

amar_1995

01/31/2020, 1:39 PM
And, I believe that, I have updated dependencies with new compiler.
i

Ian Warwick

01/31/2020, 1:41 PM
cool I had a look but can't see anything I am familiar with 😞
a

amar_1995

01/31/2020, 1:44 PM
i

Ian Warwick

01/31/2020, 1:45 PM
cool, is that with
dev04
because I think +MaterialTheme is no longer needed
Copy code
MaterialTheme.colors().surface
can be this now
a

amar_1995

01/31/2020, 1:46 PM
Yes, That code is in dev03
Copy code
var internationalState = observer(newArticleModel.internationalHeadline)
Surface(color = (MaterialTheme.colors()).surface, modifier = LayoutSize.Fill) {
    if (internationalState == null) {
        ShowLoading()
    } else if (internationalState.isEmpty()) {
        NoContentMore()
    } else {
        val scrollerPosition: ScrollerPosition = remember { ScrollerPosition(0f) }
        println("MainActivity data here : " + internationalState)

        Observe {
            onCommit(scrollerPosition.isAtEndOfList) {
                println("Is commit entered")
                if(scrollerPosition.isAtEndOfList)
                    newArticleModel.loadMoreData()
            }
        }
        VerticalScroller(scrollerPosition = scrollerPosition) {
            Column(modifier = LayoutSize.Fill) {
                println("Page rendering size " + PageSize.topHeadlineInternationalPageNo)
                internationalState!!.forEach {
                    Ripple(bounded = true) {
                        Clickable() {
                            ArticleTicket(
                                backgroundColor = (MaterialTheme.colors()).background,
                                article = it
                            )
                        }
                    }

                }
            }
        }
    }
}
Dev04 code
i

Ian Warwick

01/31/2020, 1:47 PM
aha I see but are you using
dev04
now in your project?
cool
did you add this?
Copy code
composeOptions {
        kotlinCompilerExtensionVersion "$compose_version"
    }
to your gradle files?
a

amar_1995

01/31/2020, 1:48 PM
Yes
i

Ian Warwick

01/31/2020, 1:48 PM
awesome
seems the error complains about this line
val scrollerPosition: ScrollerPosition = remember { ScrollerPosition(0f) }
a

amar_1995

01/31/2020, 1:51 PM
I think so But don't know what is going wrong
m

matvei

01/31/2020, 1:52 PM
ScrollerPosition() is a composable function now that does memorization for you
☝️ 1
Just remove outer remember and it will work 🙂
i

Ian Warwick

01/31/2020, 1:52 PM
nice 😄
m

matvei

01/31/2020, 1:53 PM
Copy code
remember {
    remember {
    }
}
a

Adam Powell

01/31/2020, 1:53 PM
Matvei beat me to it. 🙂 We're not correctly detecting that you're trying to make a composable call in the non-composable body of remember there. Ideally fixed in the next release
m

matvei

01/31/2020, 1:54 PM
This won't work and should ideally be a compiler error or a warning
a

Adam Powell

01/31/2020, 1:55 PM
The reason for the change is that ScrollerPosition reads the current density ambient so that it can use the native android fling motion now
👍 2
a

amar_1995

01/31/2020, 1:56 PM
nice, It is working now
🙏 1
👍 1
2 Views