amar_1995

    amar_1995

    2 years ago
    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 ??
    Ian Warwick

    Ian Warwick

    2 years ago
    not had this one yet, did it link to where in the code its failing? did you update the dependencies with new compiler etc?
    amar_1995

    amar_1995

    2 years ago
    And, I believe that, I have updated dependencies with new compiler.
    Ian Warwick

    Ian Warwick

    2 years ago
    cool I had a look but can't see anything I am familiar with 😞
    amar_1995

    amar_1995

    2 years ago
    Ian Warwick

    Ian Warwick

    2 years ago
    cool, is that with
    dev04
    because I think +MaterialTheme is no longer needed
    MaterialTheme.colors().surface
    can be this now
    amar_1995

    amar_1995

    2 years ago
    Yes, That code is in dev03
    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
    Ian Warwick

    Ian Warwick

    2 years ago
    aha I see but are you using
    dev04
    now in your project?
    cool
    did you add this?
    composeOptions {
            kotlinCompilerExtensionVersion "$compose_version"
        }
    to your gradle files?
    amar_1995

    amar_1995

    2 years ago
    Yes
    Ian Warwick

    Ian Warwick

    2 years ago
    awesome
    seems the error complains about this line
    val scrollerPosition: ScrollerPosition = remember { ScrollerPosition(0f) }
    amar_1995

    amar_1995

    2 years ago
    I think so But don't know what is going wrong
    matvei

    matvei

    2 years ago
    ScrollerPosition() is a composable function now that does memorization for you
    Just remove outer remember and it will work 🙂
    Ian Warwick

    Ian Warwick

    2 years ago
    nice 😄
    matvei

    matvei

    2 years ago
    remember {
        remember {
        }
    }
    Adam Powell

    Adam Powell

    2 years ago
    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
    matvei

    matvei

    2 years ago
    This won't work and should ideally be a compiler error or a warning
    Adam Powell

    Adam Powell

    2 years ago
    The reason for the change is that ScrollerPosition reads the current density ambient so that it can use the native android fling motion now
    amar_1995

    amar_1995

    2 years ago
    nice, It is working now