Faltenreich / SkeletonLayout

Skeleton view pattern for Android
Apache License 2.0
496 stars 65 forks source link

Can it support with GridLayoutManager #1

Closed UltramanTIGA closed 6 years ago

UltramanTIGA commented 6 years ago

Hi! The library you written is very great and simple to use,I'm very like it! I have a question.It works well with LinearLayoutManager,Then can it support the RecyclerView with GridLayoutManager?

Faltenreich commented 6 years ago

Hello @UltramanTIGA, thank you for your positive feedback - it is much appreciated! SkeletonLayout does support the GridLayoutManager and any other LayoutManager, since it reuses the one from the original RecyclerView. :)

UltramanTIGA commented 6 years ago

Thanks for reply! I set GridLayoutManager with 2 column in RecyclerView,And then apply skeleton to show,But the skeleton only show 1 column just same as LinearLayout.Below is my code: ` val imageSize = (ScreenUtils.getScreenWidth() - 4 * SizeUtils.dp2px(8f)) / 2 mAdapter = ImageGridAdapter(imageSize) list.layoutManager = GridLayoutManager(mContext,2) list.adapter = mAdapter skeleton = list.applySkeleton(R.layout.list_item).apply { showSkeleton() } ' Is there any other options should be added in the adapter of RecyclerView ?

Faltenreich commented 6 years ago

Your code seems perfectly fine, as I tried almost the same with the sample app. I simply replaced the LinearLayoutManager in the RecyclerViewFragment with a GridLayoutManager and it showed as many columns as expected. The library's SkeletonRecyclerView then replaces the adapter of the original RecyclerView on showSkeleton(), but the (Grid)LayoutManager stays untouched.

Maybe your ImageGridAdapter is leading to a problem, as you are setting the imageSize according to the screen width? I would recommend to compare your code to the one of the sample app to find any differences that may lead to a problem.

UltramanTIGA commented 6 years ago

Thanks for reply! I have found that the problem come from the ImageGridAdapter,It extends library github.com/CymChad/BaseRecyclerViewAdapterHelper. Maybe it has some code that make the RecyclerView show skeleton incorrectly.

Faltenreich commented 6 years ago

Yes, that may be the case. I assume that the BaseRecyclerViewAdapterHelper does some magic behind the scenes with its underlying RecyclerView.Adapter, but I cannot say for sure, since I did not investigate in its source code. Maybe you could open an issue on their end to get some more information. If there may indeed be a problem or clash with my library, feel free to open a new issue. Until then have a nice day and best regards from Germany!