Closed AbdulazizRasulbek closed 3 years ago
Hi Abdulaziz. Apparently, the error is providing the value that's corresponding to the index in the indices array to the TabLayout rather than the index itself. This works on the sample provided in the repository, but the one in your use case. Thanks for opening this issue, and sorry for the bug, I'll be providing a fix shortly.
Currently I downloaded the lib and changed not null(!!) to safe operator(?) and works fine. Could you explain the function of this code from line 185 to 190?
I've uploaded the change to this repository, could you use the latest changes?
This piece of code checks for whether you have two items fully visible in the RecyclerView, but only the second last tab will be selected (that's the behavior the library has implemented), but this piece of code checks one more time if you're in the last index and selects the last tab.
Your solution works with no null exceptions for now, and you won't be noticing any problems if your last two indexed items are far from each other and not visible at the same time, but you won't be able to see the last tab selected if both of them are fully visible at the bottom of your RecyclerView.
I'm sorry for not publishing the changes to maven yet, I'm REALLY having trouble with Gradle and pushing to Maven Central.
Please let me know if your problem is fixed using the code in the repo for now.
@AbdulazizRasulbek I've uploaded a new release to MavenCentral with a version of 1.0.1 Make sure you're using this version get your problem fixed.
implementation 'io.github.ahmad-hamwi:tabsync:1.0.1'
For any further problems, please let me know.
@Ahmad-Hamwi I copied code in TabbedListMediator class in repository and everything works fine. Thanks for the update
When I scroll recyclerview, TabbedListMediator class code from line 185 to 190 throws NullPointerException
mIndices[mIndices.size - 1]
is equal to 48 which is index in getTabAt(index) method but Tablayout has only 5 tabs. So getTabAt(48) returns nullLayoutManager GridlayoutManager spanCount = 2