question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting inconsistency error on b8 with AbstractExpandableHeader items

See original GitHub issue

I’m using beta 8 version: compile ‘eu.davidea:flexible-adapter:5.0.0-b8’

Hello!

Thank you for your adapter. It helps a lot! however i’ve encountered a series of problems. I’m using firebase to receive my data and then convert POJOs to ViewModels. I studied your official example app and can’t figure wheat i’m doing wrong? I looked at your FragmentExpandableSections example (as this is the closest to what i’m trying to accomplish) So i first init my RecyclerView with empty adapter, here’s my init method:

   @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {

        mRecyclerView = (RecyclerView) view;

        mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        mRecyclerView.setDrawingCacheEnabled(true);

        FlexibleAdapter.enableLogs(true);

        mRecyclerView.setDrawingCacheQuality(RecyclerView.DRAWING_CACHE_QUALITY_HIGH);

        mFlexibleAdapter = new FlexibleAdapter(new ArrayList(), this, true);

        mFlexibleAdapter
                .expandItemsAtStartUp()
                .setAutoCollapseOnExpand(false)
                .setAutoScrollOnExpand(true)
                .setAnimateToLimit(Integer.MAX_VALUE)//Size limit = MAX_VALUE will always animate the changes
                .setNotifyMoveOfFilteredItems(false)//When true, filtering on big list is very slow!
                .setRemoveOrphanHeaders(false)
                .setAnimationOnReverseScrolling(true);
        mRecyclerView.setItemAnimator(new DefaultItemAnimator());
        DividerItemDecoration decor = new DividerItemDecoration(getActivity(),
                R.drawable.divider, 0);
       mRecyclerView.addItemDecoration(decor.withDrawOver(true));//Increase to add gap between sections (Works only with LinearLayout!)
        mRecyclerView.setAdapter(mFlexibleAdapter);
    }

Then after my presenter fetches data from firebase I do update dataset on my View (which is fragment):

  @Override
    public void updateData(List<InstitutionModel> data) {
        if (data != null && !data.isEmpty()) {
            mFlexibleAdapter.updateDataSet(data);
        }
    }

My Header’s item viewholder extends ExpandableViewHolder.

When I receive data and use the updateData method everything looks ok, I see a list of my header items which have their subitems expanded. When I click on top headers they expand and collapse. However when I click on header item which is near end of list or is the last item I receive and error

E/UncaughtException: java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder 

adapter positionViewHolder{9e8e7c38 position=37 id=1167111371, oldPos=37, pLpos:-1 scrap [attachedScrap] tmpDetached no parent}
                                                                                        at android.support.v7.widget.RecyclerView$Recycler.validateViewHolderForOffsetPosition(RecyclerView.java:5046)
                                                                                        at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5177)
                                                                                        at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5158)
                                                                                        at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2061)
                                                                                        at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1445)
                                                                                        at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1408)
                                                                                        at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:580)
                                                                                        at android.support.v7.widget.RecyclerView.dispatchLayoutStep1(RecyclerView.java:3330)
                                                                                        at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3186)
                                                                                        at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3632)
                                                                                        at android.view.View.layout(View.java:14817)
                                                                                        at 

Here’s my log with prior actions to receiving this error: I receive my items and then they are displayed on screen as you can see by log

01-03 07:32:40.235 3331-3802/myapp D/Persistence: Transaction completed. Elapsed: 64ms
01-03 07:32:40.235 3331-3802/myapp D/EventRaiser: Raising 1 event(s)
01-03 07:32:40.235 3331-3802/myapp D/Persistence: Starting transaction.
01-03 07:32:40.235 3331-3802/myapp D/Persistence: Saved new tracked query in 1ms
01-03 07:32:40.245 3331-3802/myapp D/Persistence: Loaded a total of 1 rows for a total of 66 nodes at /Hospitals in 4ms (Query: 0ms, Loading: 1ms, Serializing: 3ms)
01-03 07:32:40.265 3331-3802/myapp D/Persistence: Transaction completed. Elapsed: 23ms
01-03 07:32:40.265 3331-3802/myapp D/EventRaiser: Raising 1 event(s)
01-03 07:32:40.265 3331-3804/myapp W/ActivityThread: ClassLoader.loadClass: The class loader returned by Thread.getContextClassLoader() may fail for processes that host multiple applications. You should explicitly specify a context class loader. For example: Thread.setContextClassLoader(getClass().getClassLoader());
01-03 07:32:40.385 1559-1573/system_process I/ActivityManager: Displayed myapp/.screens.hospitalscreen.HospitalActivity: +407ms
01-03 07:32:40.455 3331-3331/myapp D/EventRaiser: Raising /MedInstitutions: VALUE: {3={phoneInfo={1={number=+380512373766, description=прийомна головного лікаря}, 0={number=+380512373779, description=реєстратура}}, lon=31.987531, address=м. Миколаїв, вул. Адміральська,6, lat=46.97756, branches={3={phoneInfo={0={number=+380512423600, description=реєстратурa}}, lon=31.987531, address=пров. Герцена, 2, lat=46.97756, name=Сімейна амбулаторія №4}, 2={phoneInfo={0={number=+380512424173, description=реєстратурa}}, lon=31.987531, address=пров. Київський, 1, lat=46.97756, name=Сімейна амбулаторія №3}, 1={phoneInfo={0={number=+380512424171, description=реєстратурa}}, lon=31.987531, address=пров. Київський, 1, lat=46.97756, name=Сімейна амбулаторія №2}, 0={phoneInfo={0={number=+380512372243, description=}}, lon=31.987531, address=вул. Адміральська, 6, lat=46.97756, name=Сімейна амбулаторія №1}, 5={phoneInfo={0={number=+380512481604, description=реєстратурa}}, lon=31.947949, address=вул. Ламбертівська, 37, lat=46.998136, name=Сімейна амбулаторія №6}, 4={phoneInfo={0={number=+380512428173, description=реєстратурa}}, lon=31.987531, address=вул. Верхня, 2, lat=46.97756, name=Сімейна амбулаторія №5}}, name=КЗ ММР Центр первинної медико-санітарної допомоги №4}, 2={phoneInfo={1={number=+380512479478, description=реєстратура}, 0={number=+380512476914, description=}}, lon=31.985811, address=м. Миколаїв, вул. Корабелів 14-Б, lat=46.959707, branches={3={phoneInfo={0={number=+380512479478, description=}}, lon=31.985811, address=вул.Чкалова, 93, lat=46.959707, name=Амбулаторія ЗПСМ №4}, 2={phoneInfo={0={number=+380512476914, description=}}, lon=31.985811, address=вул.Корабелів, 14-Б, lat=46.959707, name=Амбулаторія ЗПСМ №3}, 1={phoneInfo={0={number=+380512478526, description=}}, lon=31.985811, address=вул.Декабристів, 23а, lat=46.959707, name=Амбулаторія ЗПСМ №2}, 0={phoneInfo={0={number=+380512475604, description=}}, lon=31.985811, address=вул.Погранічна, 22, lat=46.959707, name=Амбулаторія ЗПСМ №1}}, name=КЗ ММР Центр первинної медико-санітарної допомоги №3}, 1={phoneInfo={0={number=+380512444401, description=}}, lon=32.068266, address=м. Миколаїв, вул. Космонавтів, 126, lat=46.960035, branches={3={phoneInfo={0={number=+380512444390, description=}}, lon=32.049852, address=вул. 11 Повздовжня,45, lat=46.950346, name=Амбулаторія ЗПСМ № 4}, 2={phoneInfo={0={number=+380512561165, description=}}, lon=32.048225, address=вул. 3-я Лінія,17, lat=46.955961, name=Амбулаторія ЗПСМ № 3}, 1={phoneInfo={0={number=+380512216128, description=}}, lon=32.047633, address=вул. Театральна,49, lat=46.945165, name=Амбулаторія ЗПСМ № 2}, 0={phoneInfo={0={number=+380512446633, description=}}, lon=32.057248, address=вул. Космонавтів,57, lat=46.943006, name=Амбулаторія ЗПСМ № 1}, 6={phoneInfo={0={number=+380512569597, description=реєстратура}}, lon=32.079086, address=вул. Космонавтів,144, lat=46.969253, name=Амбулаторія ЗПСМ № 7}, 5={phoneInfo={0={number=+380512444401, description=}}, lon=32.068266, address=вул. Космонавтів,126, lat=46.960035, name=Амбулаторія ЗПСМ № 6}, 4={phoneInfo={0={number=+380512444400, description=}}, lon=32.068266, address=вул. Космонавтів,126, lat=46.960035, name=Амбулаторія ЗПСМ № 5}}, name=КЗ ММР Центр первинної медико-санітарної допомоги �
01-03 07:32:40.495 3331-3331/myapp I/FlexibleAdapter: Initially expanded 5 subItems on position=0
01-03 07:32:40.495 3331-3331/myapp I/FlexibleAdapter: Initially expanded 7 subItems on position=6
01-03 07:32:40.495 3331-3331/myapp I/FlexibleAdapter: Initially expanded 4 subItems on position=14
01-03 07:32:40.495 3331-3331/myapp I/FlexibleAdapter: Initially expanded 6 subItems on position=19
01-03 07:32:40.495 3331-3331/myapp I/FlexibleAdapter: Initially expanded 4 subItems on position=26
01-03 07:32:40.495 3331-3331/myapp I/FlexibleAdapter: Initially expanded 7 subItems on position=31
01-03 07:32:40.495 3331-3331/myapp I/FlexibleAdapter: Initially expanded 4 subItems on position=39
01-03 07:32:40.495 3331-3331/myapp W/FlexibleAdapter: notifyDataSetChanged!
01-03 07:32:40.495 3331-3331/myapp D/EventRaiser: Raising /Hospitals: VALUE: {3={phoneInfo={1={number=+380512478797, description=Реєстратура}, 0={number=+380512477765, description=Приймальне відділення}}, lon=31.974836, address=м. Миколаїв, вул. Адмірала Макарова, 1, lat=46.973165, name=Миколаївська міська лікарня № 4}, 2={phoneInfo={1={number=+380512444969, description=Секретар}, 0={number=+380512239065, description=Приймальне відділення}}, lon=32.083217, address=м.Миколаїв, вул. Космонавтів, 97, lat=46.977361, name=Миколаївська міська лікарня № 3}, 1={phoneInfo={1={number=+380512376161, description=реєстратура}, 0={number=+380512244157, description=приймальне відділення}}, lon=32.018049, address=м. Миколаїв, вул. 2 Екіпажна, 4, lat=46.973537, name=Миколаївська міська лікарня № 1}, 0={phoneInfo={1={number=+380512368285, description=Приймальня головного лікаря}, 0={number=+380512368290, description=приймальне відділення}}, lon=31.98635, address=м. Миколаїв, вул. Корабелів, 14, lat=46.959062, name=Лікарня швидкої медичної допомоги}, 7={phoneInfo={0={number=+380512213144, description=Приймальне відділення}}, lon=32.041258, address=м.Миколаїв, вул.Будівельників,8, lat=46.955054, name=Миколаївський міський пологовий будинок № 2}, 6={phoneInfo={0={number=+380512242352, description=Приймальний покій акушерського стаціонару}}, lon=32.019647, address=м. Миколаїв, вул. 2 Екіпажна, 5, lat=46.973608, name=Миколаївський міський пологовий будинок № 1}, 5={phoneInfo={0={number=+380512675138, description=Приймальне відділення}}, lon=31.975332, address=м. Миколаїв, вул. Рюміна, 5, lat=46.966738, name=Миколаївська міська дитяча лікарня № 2}, 4={phoneInfo={1={number=+380512492202, description=Реєстратура}, 0={number=+380512492227, description=Приймальне відділення}}, lon=31.975216, address=м. Миколаїв, Заводський р-н, вул. Шосейна, 128-б, lat=46.959098, name=Вузлова лікарня станції Миколаїв ДП «Одеська залізниця»}, 8={phoneInfo={1={number=+380512413521, description=Реєстратура}, 0={number=+380512413521, description=Приймальне відділення}}, lon=31.945197, address=м Миколаїв, вул. Київська , 3, lat=46.95245, name=Миколаївський міський пологовий будинок № 3}}
01-03 07:32:40.505 3331-3331/myapp W/FlexibleAdapter: No subItems to Expand on position 0 expanded false
01-03 07:32:40.505 3331-3331/myapp W/FlexibleAdapter: No subItems to Expand on position 1 expanded false
01-03 07:32:40.505 3331-3331/myapp W/FlexibleAdapter: No subItems to Expand on position 2 expanded false
01-03 07:32:40.505 3331-3331/myapp W/FlexibleAdapter: No subItems to Expand on position 3 expanded false
01-03 07:32:40.505 3331-3331/myapp W/FlexibleAdapter: No subItems to Expand on position 4 expanded false
01-03 07:32:40.505 3331-3331/myapp W/FlexibleAdapter: No subItems to Expand on position 5 expanded false
01-03 07:32:40.505 3331-3331/myapp W/FlexibleAdapter: No subItems to Expand on position 6 expanded false
01-03 07:32:40.515 3331-3331/myapp W/FlexibleAdapter: No subItems to Expand on position 7 expanded false
01-03 07:32:40.515 3331-3331/myapp W/FlexibleAdapter: No subItems to Expand on position 8 expanded false
01-03 07:32:40.515 3331-3331/myapp W/FlexibleAdapter: notifyDataSetChanged!
01-03 07:32:40.525 3331-3331/myapp I/FlexibleAdapter: Mapped viewType 2130968622 from InstitutionModel
01-03 07:32:40.525 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=InstitutionViewHolder position=0 itemId=589074116 layoutPosition=0
01-03 07:32:40.525 3331-3331/myapp I/FlexibleAdapter: Mapped viewType 2130968667 from SubInstitution
01-03 07:32:40.525 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=1 itemId=-752849351 layoutPosition=1
01-03 07:32:40.525 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=2 itemId=-891452754 layoutPosition=2
01-03 07:32:40.525 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=3 itemId=-1125319884 layoutPosition=3
01-03 07:32:40.525 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=4 itemId=258937229 layoutPosition=4
01-03 07:32:40.555 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=5 itemId=713505744 layoutPosition=5
01-03 07:32:40.575 3331-3331/myapp D/dalvikvm: GC_FOR_ALLOC freed 1285K, 5% free 27430K/28868K, paused 9ms, total 12ms
01-03 07:32:40.575 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=InstitutionViewHolder position=6 itemId=1895624255 layoutPosition=6
01-03 07:32:40.595 3331-3331/myapp I/FlexibleAdapter: Mapped viewType 2130968622 from InstitutionModel
01-03 07:32:40.595 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=InstitutionViewHolder position=0 itemId=104469483 layoutPosition=0
01-03 07:32:40.605 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=InstitutionViewHolder position=1 itemId=888820344 layoutPosition=1
01-03 07:32:40.605 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=InstitutionViewHolder position=2 itemId=-1649711281 layoutPosition=2
01-03 07:32:40.615 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=InstitutionViewHolder position=3 itemId=-944313735 layoutPosition=3
01-03 07:32:40.615 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=InstitutionViewHolder position=4 itemId=87832554 layoutPosition=4
01-03 07:32:40.715 1132-1132/? W/SurfaceFlinger: couldn't log to binary event log: overflow.
01-03 07:32:40.785 3331-3331/myapp V/AnimatorAdapter: Clear notified for binding Animations
01-03 07:32:40.825 3331-3331/myapp V/AnimatorAdapter: Clear notified for binding Animations
01-03 07:32:41.595 3331-3802/myapp D/dalvikvm: GC_FOR_ALLOC freed 1290K, 5% free 28189K/29632K, paused 8ms, total 8ms
01-03 07:32:41.845 3331-3802/myapp D/Persistence: Starting transaction.
01-03 07:32:41.845 3331-3802/myapp D/Persistence: Transaction completed. Elapsed: 0ms
01-03 07:32:41.845 3331-3802/myapp D/Persistence: Starting transaction.
01-03 07:32:41.845 3331-3802/myapp D/Persistence: Transaction completed. Elapsed: 1ms
01-03 07:32:45.195 3331-3800/myapp V/FA: Inactivity, disconnecting from the service

Scrolling down the list:

01-03 07:43:22.885 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=7 itemId=-2014191252 layoutPosition=7
01-03 07:43:23.085 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=8 itemId=-1324871589 layoutPosition=8
01-03 07:43:23.305 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=9 itemId=-1044695876 layoutPosition=9
01-03 07:43:23.525 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=10 itemId=-1929196990 layoutPosition=10
01-03 07:43:25.555 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=11 itemId=1608110119 layoutPosition=11
01-03 07:43:25.715 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=12 itemId=1608110150 layoutPosition=12
01-03 07:43:25.905 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=13 itemId=1608110241 layoutPosition=13

Scrolling more and collapsing\expanding first item:

01-03 07:43:55.035 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=4 itemId=258937229 layoutPosition=4
01-03 07:43:55.105 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=3 itemId=-1125319884 layoutPosition=3
01-03 07:43:55.155 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=2 itemId=-891452754 layoutPosition=2
01-03 07:43:55.205 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=1 itemId=-752849351 layoutPosition=1
01-03 07:43:56.045 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=InstitutionViewHolder position=0 itemId=589074116 layoutPosition=0
01-03 07:43:56.985 3331-3331/myapp V/FlexibleAdapter: Request to Collapse on position=0 expanded=true hasSubItemsSelected=false
01-03 07:43:56.985 3331-3331/myapp V/FlexibleAdapter: Collapsed 5 subItems on position 0
01-03 07:43:56.985 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=4 itemId=-1044695876 layoutPosition=4
01-03 07:43:56.985 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=5 itemId=-1929196990 layoutPosition=5
01-03 07:43:58.575 3331-3331/myapp I/FlexibleAdapter: Expanded 5 subItems on position=0
01-03 07:43:58.585 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=1 itemId=-752849351 layoutPosition=1
01-03 07:43:58.585 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=2 itemId=-891452754 layoutPosition=2
01-03 07:43:58.585 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=3 itemId=-1125319884 layoutPosition=3
01-03 07:43:58.585 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=4 itemId=258937229 layoutPosition=4
01-03 07:43:58.585 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=5 itemId=713505744 layoutPosition=5

Scrolling to the end of the list:

01-03 07:45:09.015 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=9 itemId=-1044695876 layoutPosition=9
01-03 07:45:09.035 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=10 itemId=-1929196990 layoutPosition=10
01-03 07:45:09.035 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=11 itemId=1608110119 layoutPosition=11
01-03 07:45:09.055 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=12 itemId=1608110150 layoutPosition=12
01-03 07:45:09.055 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=13 itemId=1608110241 layoutPosition=13
01-03 07:45:09.065 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=InstitutionViewHolder position=14 itemId=-237625622 layoutPosition=14
01-03 07:45:09.075 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=15 itemId=677132851 layoutPosition=15
01-03 07:45:09.085 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=16 itemId=-279772435 layoutPosition=16
01-03 07:45:09.085 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=17 itemId=-1258806414 layoutPosition=17
01-03 07:45:09.105 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=18 itemId=-378189469 layoutPosition=18
01-03 07:45:09.105 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=InstitutionViewHolder position=19 itemId=-1582963889 layoutPosition=19
01-03 07:45:09.115 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=20 itemId=-1672319789 layoutPosition=20
01-03 07:45:09.135 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=21 itemId=-1119645159 layoutPosition=21
01-03 07:45:09.135 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=22 itemId=-1119645128 layoutPosition=22
01-03 07:45:09.145 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=23 itemId=-325540433 layoutPosition=23
01-03 07:45:09.155 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=24 itemId=822543601 layoutPosition=24
01-03 07:45:09.155 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=25 itemId=-811893810 layoutPosition=25
01-03 07:45:09.185 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=InstitutionViewHolder position=26 itemId=-570149228 layoutPosition=26
01-03 07:45:09.185 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=27 itemId=1111863082 layoutPosition=27
01-03 07:45:09.185 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=28 itemId=1756110586 layoutPosition=28
01-03 07:45:09.205 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=29 itemId=-378189557 layoutPosition=29
01-03 07:45:09.205 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=30 itemId=467348617 layoutPosition=30
01-03 07:45:09.215 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=InstitutionViewHolder position=31 itemId=-1552117352 layoutPosition=31
01-03 07:45:09.235 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=32 itemId=-1022740429 layoutPosition=32
01-03 07:45:09.235 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=33 itemId=-1387116413 layoutPosition=33
01-03 07:45:09.255 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=34 itemId=-1600702752 layoutPosition=34
01-03 07:45:09.255 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=35 itemId=1931430869 layoutPosition=35
01-03 07:45:09.265 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=36 itemId=1092534159 layoutPosition=36
01-03 07:45:09.265 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=37 itemId=1167111371 layoutPosition=37
01-03 07:45:09.285 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=38 itemId=1167111402 layoutPosition=38
01-03 07:45:09.285 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=InstitutionViewHolder position=39 itemId=-23046946 layoutPosition=39
01-03 07:45:09.305 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=40 itemId=-1794749561 layoutPosition=40
01-03 07:45:09.325 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=41 itemId=509144223 layoutPosition=41
01-03 07:45:09.325 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=42 itemId=-1130482917 layoutPosition=42
01-03 07:45:09.355 3331-3331/myapp V/FlexibleAdapter: onViewBound    Holder=SubInstitutionViewHolder position=43 itemId=-1130482886 layoutPosition=43

Clicking on last header item that has subitems displayed (expanded):

01-03 07:46:32.695 3331-3331/myapp V/FlexibleAdapter: Request to Collapse on position=39 expanded=true hasSubItemsSelected=false
01-03 07:46:32.695 3331-3331/myapp V/FlexibleAdapter: Collapsed 4 subItems on position 39
01-03 07:47:35.885 10554-10554/myapp D/AndroidRuntime: Shutting down VM
01-03 07:47:35.885 10554-10554/myapp W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x9ccfdb20)
01-03 07:47:35.885 10554-10554/myapp E/UncaughtException: java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder{9e9232a0 position=37 id=1167111371, oldPos=37, pLpos:-1 scrap [attachedScrap] tmpDetached no parent}
                                                                                          at android.support.v7.widget.RecyclerView$Recycler.validateViewHolderForOffsetPosition(RecyclerView.java:5046)
                                                                                          at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5177)
                                                                                          at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5158)
                                                                                          at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2061)
                                                                                          at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1445)
                                                                                          at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1408)
                                                                                          at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:580)
                                                                                          at android.support.v7.widget.RecyclerView.dispatchLayoutStep1(RecyclerView.java:3330)
                                                                                          at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3186)
                                                                                          at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3632)
                                                                                          at android.view.View.layout(View.java:14817)

I tried disabling item decorations (as you indicated that they must only be used with linear layout on model layout, but it did not turn out to be the case.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
davideascommented, Jan 3, 2017

I found it. All the equals methods are wrong implemented (hashcode() too, as a consequence). Please use an unique identifier, use a field named id as Integer or String. You can try your app with the default java implementation: return this == o; but I recommend to use an ID.

I discovered it by collapsing the 3rd section. Then if you scroll you will find already the 5th and 7th collapsed, which were not supposed to be collapsed! If you directly collapse the last section, Java List object finds the items to collapse already at 3rd section so it will crash, of course.

Last thing, if you want to use setAutoScrollOnExpand(true) you should use the internal manager SmoothScrollLinearLayoutManager class.

0reactions
SolidScorpioncommented, Jan 3, 2017

Thank you so much! Yes, it now works properly!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Inconsistency in GL status - SAP Community
1-Safe the GL Data to Excel from FAGLL03 for OIM. 2-Go To FS00 and on Control Tab Select Display Item and Sort Key;...
Read more >
Page Data Inconsistency Error when Creating a Change ...
Dispatch the Purchase Order. Click on the Change Order triangle icon in the status tab of the PO Line, and change the Item...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found