Skip to content

Image sorting crashes app when i want to force certain images to be drawn behind others #88

Answered by RikNorakomi
RikNorakomi asked this question in Q&A
Discussion options

You must be logged in to vote

Looks like I found a way to prevent the SO crash as followed:

override fun compareTo(other: ImageComponent): Int {

        if (other.zAxisAlignment == IMAGE_ALWAYS_IN_BACK && zAxisAlignment != IMAGE_ALWAYS_IN_BACK ) return 1
        if (zAxisAlignment == IMAGE_ALWAYS_IN_BACK && other.zAxisAlignment != IMAGE_ALWAYS_IN_BACK ) return -1

        val yDiff = other.image.y.compareTo(image.y)
        return if (yDiff != 0){
            yDiff
        } else {
            other.image.x.compareTo(image.x)
        }
    }

I assume this prevents an endless loop in the BagKt.quickSort function.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@Quillraven
Comment options

@RikNorakomi
Comment options

Answer selected by RikNorakomi
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants