Comments (8)
I manage to reproduce it with this test:
@Test
fun testGridRemovalWithSpanLookupDoesNotCrash() {
onRecyclerView("Change span size") { recyclerView ->
recyclerView.setSpanSizeLookup(object : DpadSpanSizeLookup() {
override fun getSpanSize(position: Int): Int {
val adapter = recyclerView.adapter as AbstractTestAdapter<*>
val item = adapter.getItem(position)
return if (item % 9 == 0) {
recyclerView.getSpanCount()
} else {
1
}
}
})
}
KeyEvents.pressDown()
val oldViewBounds = getRelativeItemViewBounds(position = 1)
mutateAdapter { adapter ->
adapter.removeAt(3)
adapter.removeAt(13)
}
assertFocusAndSelection(1)
assertItemAtPosition(position = 1, item = 1)
val newViewBounds = getRelativeItemViewBounds(position = 1)
assertThat(newViewBounds).isEqualTo(oldViewBounds)
}
Will take care of it for the next release
from dpadrecyclerview.
Released in 1.3.0-alpha03
now
from dpadrecyclerview.
@tyrel-carlson is this similar to your setup?
I'm not able to reproduce this. Can you give me more details about the contents of your adapter and which position you're removing?
from dpadrecyclerview.
Here's my current test that is passing:
@Test
fun testGridRemovalWithSpanLookupDoesNotCrash() {
onRecyclerView("Change span size") { recyclerView ->
recyclerView.setSpanSizeLookup(object : DpadSpanSizeLookup() {
override fun getSpanSize(position: Int): Int {
return if (position % 5 == 0) {
recyclerView.getSpanCount()
} else {
1
}
}
})
}
val oldViewBounds = getRelativeItemViewBounds(position = 0)
mutateAdapter { adapter ->
adapter.removeAt(adapter.itemCount - 1)
adapter.removeAt(adapter.itemCount - 1)
adapter.removeAt(0)
adapter.removeAt(0)
}
assertFocusAndSelection(0)
assertItemAtPosition(position = 0, item = 2)
val newViewBounds = getRelativeItemViewBounds(position = 0)
assertThat(newViewBounds).isEqualTo(oldViewBounds)
}
I'm trying to replicate your setup, but I need more details
from dpadrecyclerview.
@tyrel-carlson is this similar to your setup?
I'm not able to reproduce this. Can you give me more details about the contents of your adapter and which position you're removing?
Yeah that looks like my own. My date headers fill the grid but are not focusable themselves.
from dpadrecyclerview.
I manage to reproduce it with this test:
@Test fun testGridRemovalWithSpanLookupDoesNotCrash() { onRecyclerView("Change span size") { recyclerView -> recyclerView.setSpanSizeLookup(object : DpadSpanSizeLookup() { override fun getSpanSize(position: Int): Int { val adapter = recyclerView.adapter as AbstractTestAdapter<*> val item = adapter.getItem(position) return if (item % 9 == 0) { recyclerView.getSpanCount() } else { 1 } } }) } KeyEvents.pressDown() val oldViewBounds = getRelativeItemViewBounds(position = 1) mutateAdapter { adapter -> adapter.removeAt(3) adapter.removeAt(13) } assertFocusAndSelection(1) assertItemAtPosition(position = 1, item = 1) val newViewBounds = getRelativeItemViewBounds(position = 1) assertThat(newViewBounds).isEqualTo(oldViewBounds) }Will take care of it for the next release
Thanks for your consideration. By the way, can you tell me how can I manage to fix this until next version is released?
from dpadrecyclerview.
As a workaround, notifyDataSetChanged
instead of individual notifyItemRemoved
calls should fix it for now. But I plan to release this fix today anyway
from dpadrecyclerview.
Yeah I noticed too that calling notifyDataSetChanged
is a fix but it prevents loading of item data in my case, so I prefer to wait for your release, thanks for your great work!
from dpadrecyclerview.
Related Issues (20)
- Gridrecyclerview with height 0.5 of the screen height - alignment problem (last row cut off) HOT 14
- First item of first row is smaller then all the others HOT 4
- Fast scrolling - loosing focus when having images from an url in the items HOT 21
- Scrolling issue when loading images in onBindViewHolder HOT 9
- Scroll a nested recyclerview to a specific item (without focussing it) HOT 3
- Bug: Last row not getting focused while using DpadSpanSizeLookup HOT 1
- Bug: DpadSpanSizeLookup's getSpanSize function is being called infinitely while fast scrolling HOT 19
- Focus does not leave DpadRecyclerView in some cases when using Compose HOT 1
- Do not allow focusing other rows if grids are incomplete
- how to center scroll like CenterLayoutManager in horizontal HOT 1
- OnViewFocused is not called for parent RecyclerView if child does not attach a listener
- DpadRecyclerView shouldn't lose focus if adapter is cleared
- Nested Child recycler view onCreate called every time during parent recycler view scroll. HOT 9
- Incorrect predictive animation after adapter changes
- java.lang.IllegalStateException: Cannot call removeView(At) within removeView(At) HOT 8
- How can I bind the selected state to the holder content? HOT 7
- Drag & Drop Implementation Help HOT 4
- Crash when app:layoutManager is set in XML
- issue while scrolling top to button and left to right HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dpadrecyclerview.