Search in sources :

Example 1 with ListNormalAdapter

use of com.example.gsyvideoplayer.adapter.ListNormalAdapter in project GSYVideoPlayer by CarGuo.

the class ListVideoActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    // 设置一个exit transition
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
        getWindow().setEnterTransition(new Explode());
        getWindow().setExitTransition(new Explode());
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list_video);
    ButterKnife.bind(this);
    final ListNormalAdapter listNormalAdapter = new ListNormalAdapter(this);
    videoList.setAdapter(listNormalAdapter);
    videoList.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            int lastVisibleItem = firstVisibleItem + visibleItemCount;
            //大于0说明有播放
            if (GSYVideoManager.instance().getPlayPosition() >= 0) {
                //当前播放的位置
                int position = GSYVideoManager.instance().getPlayPosition();
                //对应的播放列表TAG
                if (GSYVideoManager.instance().getPlayTag().equals(ListNormalAdapter.TAG) && (position < firstVisibleItem || position > lastVisibleItem)) {
                    //如果滑出去了上面和下面就是否,和今日头条一样
                    GSYVideoPlayer.releaseAllVideos();
                    listNormalAdapter.notifyDataSetChanged();
                }
            }
        }
    });
}
Also used : Explode(android.transition.Explode) ListNormalAdapter(com.example.gsyvideoplayer.adapter.ListNormalAdapter) AbsListView(android.widget.AbsListView)

Aggregations

Explode (android.transition.Explode)1 AbsListView (android.widget.AbsListView)1 ListNormalAdapter (com.example.gsyvideoplayer.adapter.ListNormalAdapter)1