RecyclerView rv_featureList;
private View currentFocusedLayout, oldFocusedLayout;
@Override
public void onCreate(Bundle instanceState) {
rv_featuredList.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView,
int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (newState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) {
int positionView = ((LinearLayoutManager) rv_featuredList.getLayoutManager()).findFirstCompletelyVisibleItemPosition();
Log.i("VISISBLE", positionView + "");
if (positionView >= 0) {
if (oldFocusedLayout != null) {
VideoView vv_dashboard = (VideoView) oldFocusedLayout.findViewById(R.id.vv_dashboard);
vv_dashboard.stopPlayback();
}
currentFocusedLayout = ((LinearLayoutManager) rv_featuredList.getLayoutManager()).findViewByPosition(positionView);
VideoView vv_dashboard = (VideoView) currentFocusedLayout.findViewById(R.id.vv_dashboard);
playVideo(videosData.get(positionView));
oldFocusedLayout = currentFocusedLayout;
}
}
}
});
}
source
share