Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using this library with RecyclerView having layout as StaggeredGridLayout #63

Closed
ankesh4040 opened this issue Aug 20, 2016 · 17 comments
Closed

Comments

@ankesh4040
Copy link

Developer , I really liked your MaterialScrollBar library. Only issue I have is using this in StaggeredGridLayout. I am developing a gallery application and in that I use RecyclerView layout manager StaggeredGridLayout.

I Forked your library and tried changing ScrollingUtilities.java file, and was able to use the scrollbar but Scrollbar height and scroll computation is not correctly in sync.

Please help me as to how can I incorporate this library with my project.

Thanks

@turing-tech
Copy link
Owner

You should probably incorporate ICustomScroller. For getDepthForItem() return the sum of the height of all of the views in the first column from the top to the first visible item. For getItemIndexForScroll() follow the instructions. Same for getTotalDepth().

@ankesh4040
Copy link
Author

ankesh4040 commented Aug 29, 2016

return the sum of the height of all of the views in the first column from the top to the first visible item.

Is it from the top to the first visible item or from the top of the frst visible item ?

Also that will getDepthForItem , getItemIndexForScroll() and getTotalDepth() return same value ??

@turing-tech
Copy link
Owner

From the to of the list, including the elements that are off screen, to the top of the first visible item. And no, they would all return different values.

@ankesh4040
Copy link
Author

Please as per the image attached tell the value of all three. This would be a great help.

screenshot-photo-gallery-5eea63177ce849319c2622fbd69b5469

@ankesh4040
Copy link
Author

ankesh4040 commented Aug 29, 2016

From the name what I understod is :-

a) getDepthForItem(int index) -- > This is height of each row so I return x (height of each item being same)

b) getItemIndexForScroll(float progress) -- > This is that , according to progress where should we scroll to position. So I am return progress_7_3 (7 is number of rows and 3 no. of item in a row)

c) getTotalDepth() -- > This is total height of all rows . So I return 7*x (7 being no. of rows and x being height of each row)

Please correct me where I am wrong in this.

Thanks

@turing-tech
Copy link
Owner

Assuming that you haven't scrolled down any the values would be:

getDepthForItem(7 [for example]) = 2x
getItemIndexForScroll(.5) = the item halfway down the list
getTotalDepth() = x * the number if visible and nonvisible items.

@turing-tech
Copy link
Owner

Actually that would return those values regardless of scroll.

@ankesh4040
Copy link
Author

So getTotalDepth() is ok

@ankesh4040
Copy link
Author

Why is this 2x for getDepthForItem(int index)

@ankesh4040
Copy link
Author

As I have all my items uniform and height of all items is same. So getDepthForItem(int index) would always return 2x irrespective of indxe
?

@turing-tech
Copy link
Owner

getDepthForItem(int index) returns the depth of the item provided. Because item at index 7 is in the third row, it had two rows above it and therefore is 2 rows down from the top, where a row is x pixles tall.

Suppose I gave item 0, the depth would be zero. If I gave item 3, that would be at depth x, since item 3 is in the second row.

@ankesh4040
Copy link
Author

ok got it.
only thing left is getItemIndexForScroll(float progress)

@turing-tech
Copy link
Owner

So here it wants the item at the given progress. So if I give .5, I want the index halfway down the list (this means the list of items off screen). Si if there are 100 items which can be presented in the list, assuming they all have the same height, .5 should return item 50. .25 should return item 25, etc.

@turing-tech
Copy link
Owner

Sorry, I should have said: this means the list of items on and off screen.

@ankesh4040
Copy link
Author

ankesh4040 commented Aug 29, 2016

So if there are 153 items and in a row there are three items then with progress of 0.5 I should return 76 .

Am I right?

@turing-tech
Copy link
Owner

Yes.

@ankesh4040
Copy link
Author

Ok, Thanks a lot for help. Will try this in my project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants