Skip to content

Instantly share code, notes, and snippets.

@hitherejoe
Created Dec 31, 2015
Embed
What would you like to do?
private void checkPostsDisplayOnGridView(List<Post> postsToCheck, int position) {
int columnCount = 5;
int size = postsToCheck.size() + position;
int pos = 0;
for (int i = position; i < size; i++) {
// The first item starts as selected, clicking on this would open the Playback Activity
checkItemAtPosition(i, postsToCheck.get(pos));
// If we get to the end of the current row then we need to go down to the next one
if (((i + 1) % columnCount) == 0) {
int nextRowStart = i + columnCount;
int nextRowEnd = nextRowStart - columnCount + 1;
for (int n = nextRowStart; n >= nextRowEnd; n--) {
checkItemAtPosition(n, postsToCheck.get(n - position));
}
// Set i to the start of the row beneath the one we've just checked
i = i + columnCount;
}
pos++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment