Skip to content

Instantly share code, notes, and snippets.

@hitherejoe
Created December 31, 2015 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hitherejoe/e9696af7c95caca977ac to your computer and use it in GitHub Desktop.
Save hitherejoe/e9696af7c95caca977ac to your computer and use it in GitHub Desktop.
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