Last active
February 22, 2018 20:04
-
-
Save neonankiti/9faad768778c234cb57977cb0150e4fb to your computer and use it in GitHub Desktop.
add onScrollStateChanged() for checking if there is an item view inside the screen.
If so, tell the item view(VideoView) that it can start movie.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { | |
@Override | |
public void onScrollStateChanged(RecyclerView recyclerView, int newState) { | |
super.onScrollStateChanged(recyclerView, newState); | |
int firstCompletelyVisibleItemPosition = ((LinearLayoutManager) recyclerView.getLayoutManager()) | |
.findFirstCompletelyVisibleItemPosition(); | |
boolean isVideo = recyclerView.getAdapter() | |
.getItemViewType(firstCompletelyVisibleItemPosition) == TYPE_MOVIE; | |
if (!isVideo) { | |
return; | |
} | |
} | |
@Override | |
public void onScrolled(RecyclerView recyclerView, int dx, int dy) { | |
super.onScrolled(recyclerView, dx, dy); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface OnScreenScopeListener { | |
void getCompletelyVisiblePosition(int firstCompletelyVisibleItemPosition); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment