Lin Min Phyo

    Lin Min Phyo

    2 years ago
    ClassCastException happened when sorting is made in DataTable of dev-06. Worked fine on dev-04. My composition function looks like this.
    @Preview
    @Composable
    fun FullFeaturedTable() {
        val numbers = mutableListOf(1, 2, 100, 500)
        DataTable(
            columns = 1,
            sorting = DefaultDataTableSorting(
                sortableColumns = setOf(0),
                onSortRequest = { column , isAscending ->
                    if (isAscending) {
                        numbers.sortBy { it }
                    } else {
                        numbers.sortByDescending { it }
                    }
                })
        ) {
            headerRow { Text(text = "Number") }
    
            for (number in numbers) {
                dataRow { Text("$number") }
            }
        }
    }
    Logcat shows like the following.
    java.lang.ClassCastException: androidx.ui.material.DataTableKt$DataTable$table$1$invoke$3$2$invoke$4$invoke$2 cannot be cast to kotlin.jvm.functions.Function0
    at androidx.ui.material.DataTableKt$DataTable$table$1$invoke$3$2$invoke$4$invoke$4$invoke$1$invoke$1$invoke$1.invoke(DataTable.kt:411)
    at androidx.ui.material.DataTableKt$DataTable$table$1$invoke$3$2$invoke$4$invoke$4$invoke$1$invoke$1$invoke$1.invoke(Unknown Source:6)
    at androidx.ui.layout.FlexKt$Row$1.invoke(Flex.kt:1110)
    at androidx.ui.layout.FlexKt$Row$1.invoke(Unknown Source:3)
    at androidx.ui.core.LayoutKt.Layout(Layout.kt:641)
    at androidx.ui.core.LayoutKt.Layout(Layout.kt:560)
    at androidx.ui.layout.FlexKt.FlexLayout(Flex.kt:1130)
    at androidx.ui.layout.FlexKt.Row(Flex.kt:1110)
    at androidx.ui.layout.FlexKt.Row$default(Flex.kt:228)
    at androidx.ui.material.DataTableKt$DataTable$table$1$invoke$3$2$invoke$4$invoke$4$invoke$1$invoke$1.invoke(DataTable.kt:547)
    at androidx.ui.material.DataTableKt$DataTable$table$1$invoke$3$2$invoke$4$invoke$4$invoke$1$invoke$1.invoke(Unknown Source:3)
    at androidx.ui.core.gesture.PressReleasedGestureDetectorKt.PressReleasedGestureDetector(PressReleasedGestureDetector.kt:195)
    at androidx.ui.core.gesture.PressReleasedGestureDetectorKt.PressReleasedGestureDetector$default(PressReleasedGestureDetector.kt:52)
    at androidx.ui.foundation.ClickableKt$Clickable$2.invoke(Clickable.kt:63)
    at androidx.ui.foundation.ClickableKt$Clickable$2.invoke(Unknown Source:3)
    at androidx.ui.semantics.SemanticsKt.Semantics(Semantics.kt:102)
    at androidx.ui.semantics.SemanticsKt.Semantics$default(Semantics.kt:25)
    at androidx.ui.foundation.ClickableKt.Clickable(Clickable.kt:45)
    at androidx.ui.foundation.ClickableKt.Clickable$default(Clickable.kt:38)
    at androidx.ui.material.DataTableKt$DataTable$table$1$invoke$3$2$invoke$4$invoke$4$invoke$1.invoke(DataTable.kt:547)
    at androidx.ui.material.DataTableKt$DataTable$table$1$invoke$3$2$invoke$4$invoke$4$invoke$1.invoke(Unknown Source:3)
    at androidx.ui.core.gesture.PressIndicatorGestureDetectorKt.PressIndicatorGestureDetector(PressIndicatorGestureDetector.kt:264)
    at androidx.ui.core.gesture.PressIndicatorGestureDetectorKt.PressIndicatorGestureDetector$default(PressIndicatorGestureDetector.kt:51)
    at androidx.ui.material.ripple.RippleKt.Ripple(Ripple.kt:194)
    at androidx.ui.material.ripple.RippleKt.Ripple$default(Ripple.kt:58)
    at androidx.ui.material.DataTableKt$DataTable$table$1$invoke$3$2$invoke$4$invoke$4.invoke(DataTable.kt:408)
    at androidx.ui.material.DataTableKt$DataTable$table$1$invoke$3$2$invoke$4$invoke$4.invoke(Unknown Source:3)
    at androidx.compose.AmbientKt.Providers(Ambient.kt:176)
    at androidx.ui.core.TextKt.CurrentTextStyleProvider(Text.kt:386)
    at androidx.ui.material.DataTableKt$DataTable$table$1$invoke$3$2$invoke$4.invoke(DataTable.kt:547)
    at androidx.ui.material.DataTableKt$DataTable$table$1$invoke$3$2$invoke$4.invoke(Unknown Source:3)
    at androidx.ui.core.LayoutKt.Layout(Layout.kt:641)
    at androidx.ui.core.LayoutKt.Layout(Layout.kt:580)
    at androidx.ui.layout.ContainerKt.Container(Container.kt:120)
    at androidx.ui.layout.ContainerKt.Container$default(Container.kt:57)
    at androidx.ui.material.DataTableKt$DataTable$table$1$invoke$3$2.invoke(DataTable.kt:557)
    at androidx.ui.material.DataTableKt$DataTable$table$1$invoke$3$2.invoke(Unknown Source:3)
    at androidx.ui.layout.TableChildren$tableRow$1.invoke(Table.kt:799)
    at androidx.ui.layout.TableChildren$tableRow$1.invoke(Unknown Source:3)
    at androidx.ui.layout.TableKt$Table$tableChildren$1$1.invoke(Table.kt:822)
    at androidx.ui.layout.TableKt$Table$tableChildren$1$1.invoke(Unknown Source:3)
    at androidx.ui.core.LayoutKt.Layout(Layout.kt:641)
    at androidx.ui.core.LayoutKt.Layout(Layout.kt:560)
    at androidx.ui.core.LayoutKt.Layout$default(Layout.kt:68)
    at androidx.ui.layout.TableKt.Table(Table.kt:817)
    at androidx.ui.material.DataTableKt$DataTable$table$1.invoke(DataTable.kt:547)
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    2 years ago
    Did you file a bug? Issue tracker link is in the channel topic.
    Lin Min Phyo

    Lin Min Phyo

    2 years ago
    Not yet. I will file a bug.