Omega-R / OmegaRecyclerView

Custom RecyclerView with additional functionality. Allow you add divider, itemSpace, emptyView, sticky header and some other features
https://omega-r.github.io/OmegaRecyclerView
MIT License
143 stars 29 forks source link

App crash when use GridLayoutManager #123

Closed leyvien closed 4 years ago

leyvien commented 5 years ago

java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder{2eca69b position=21 id=-1, oldPos=20, pLpos:20 scrap [attachedScrap] tmpDetached no parent} com.omega_r.libs.omegarecyclerview

leyvien commented 5 years ago

My app crash when use gridlayoutmanager in pagination

RomanTcv commented 5 years ago

Hi @leyvien. We checked OmegaRecyclerView, GridLayoutManager and pagination and we couldn't reproduce your crash. Can you provide us an example ?

leyvien commented 5 years ago

Hi @R12rus Sorry for the late reply I already figured out,it not relate to GridLayoutManager , sometime my API return empty list then i add and call notifyItemInserted, then the crash happen, i don't know this error relate to RecyclerView or you library or my fault(happen frequently when try to scroll fast)

leyvien commented 5 years ago

One more thing, with GridLayoutManager the ErrorView, and LoadingView position not put at the bottom like the LinearLayoutManager, how can i put it into the bottom Thank you for great Library!!!

RomanTcv commented 5 years ago

@leyvien Please check out our example - PaginationActivity. Change layout code to

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.omega_r.omegarecyclerview.pagination_example.PaginationActivity">

    <com.omega_r.libs.omegarecyclerview.OmegaRecyclerView
        android:id="@+id/recyclerview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:paginationLayout="@layout/item_progress"
        app:layoutManager="GridLayoutManager"
        app:spanCount="2"
        app:paginationErrorLayout="@layout/item_error_loading"/>

</FrameLayout>

ErrorView and LoadingView now at the bottom. If you change app:spanCount to 3 - LoadingView will be the last position in the list.