Giter VIP home page Giter VIP logo

Comments (5)

rubensousa avatar rubensousa commented on July 19, 2024 1

@MRDHR released in 1.2.0-alpha03

from dpadrecyclerview.

rubensousa avatar rubensousa commented on July 19, 2024

Hi @MRDHR can you please share the full stacktrace? I'm interested in knowing if the index was greater than the adapter size or if it was negative.

from dpadrecyclerview.

rubensousa avatar rubensousa commented on July 19, 2024

Hey @MRDHR. I managed to reproduce the crash with this UI test:

    @Test
    fun testSelectingPositionOutOfBoundsDoesNotCrash() {
        val numberOfItems = 500
        launchFragment(TestAdapterConfiguration(numberOfItems = numberOfItems))

        selectPosition(numberOfItems + 100, smooth = true, waitForIdle = false)

        Thread.sleep(1000L)

        mutateAdapter { adapter ->
            adapter.setList(MutableList(numberOfItems + 10) { it })
            adapter.notifyItemRangeInserted(0, 100)
        }

        onRecyclerView("Request layout") { recyclerView ->
            recyclerView.requestLayout()
        }

        assertFocusAndSelection(numberOfItems + 9)
    }

Please check if you're doing the following in your side:

  1. Using DiffUtil and submitList to notify adapter changes correctly
  2. Check if your setSelectedPosition calls are using indexes within bounds of the adapter contents

There's a PR here to address this specific crash now, but you might still hit some issues if you don't follow those 2 steps: #179

from dpadrecyclerview.

MRDHR avatar MRDHR commented on July 19, 2024

Regarding the two points you mentioned

1: I did not use DiffUtil to update data, I used replace. That is, items clear, then add all, and finally execute notifydatasetchanged
2: I can ensure that my items are not empty with setSelectedPosition.

The data updates are not very frequent, and they are not updated every 1 second.

At present, I have added the setSelectedPosition operation to be executed after recyclerview.post, and added the judgment for position>=0&&position<=items. size -1

from dpadrecyclerview.

MRDHR avatar MRDHR commented on July 19, 2024

Looking forward to your pull request being synchronized to the master and release an aar

from dpadrecyclerview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.