当前位置:网站首页>When the recyclerview plays more videos, the problem of refreshing the current video is solved.
When the recyclerview plays more videos, the problem of refreshing the current video is solved.
2022-06-11 05:36:00 【Cockroach bully BBQ】
The background of the story is like this : What the project does is a short video playback function similar to Tiktok , Click to enter the video details , Play full screen , Then slide up and down to switch video , It's using RecyclerView Combined with Alibaba cloud player Video streaming , Because the background is a paging interface , Therefore, more data needs to be loaded when there is almost no data on the slide . It used to be :
this.list.clear(); // Clear data source
this.list.addAll(list); // Update data source
adapter.notifyDataSetChanged();// Refresh List
Then there is a small problem , Request per page 10 strip , If the home page currently has a total of 10 A video , From the home page, directly click Page 10 individual , That is, currently playing the 10 A video , Then directly request the next page of video data , Using the above code will cause the currently playing video to restart playing , The experience is not very good , And as we all know notifyDataSetChanged() refresh all , Efficiency is the lowest . Just want to use RecyclerView To replace the local refresh , namely
notifyItemRangeChanged(this.list.size()-list.size(),this.list.size()); // Only refresh and load the extra data list
Then run and find no effect , Many data slides do not appear ! Muddled ing... (tip: Before, I usually used RecyclerView Make a list , This is the first time to do this kind of complex video streaming ~)
// Finally, it was changed to this kind of writing , Successfully refresh data , At the same time, the progress of the currently playing video will not be interrupted :
this.list.addAll(list);// Update data source notifyItemRangeInserted(this.list.size()-list.size(),this.list.size());// Update the number of lists notifyItemRangeChanged(this.list.size()-list.size(),this.list.size());// Update list data
seeing the name of a thing one thinks of its function , Insert the number of lists first , Then perform a local refresh operation , Make a note of , Why haven't you seen the source code yet , Let's settle it first ,over.
边栏推荐
- SQLite one line SQL implementation updates if there is one, inserts if there is none, multiple conditions, complex conditions
- Bit operation marks multiple switches with one parameter
- Carrier coordinate system inertial coordinate system world coordinate system
- Exploration of kangaroo cloud data stack on spark SQL optimization based on CBO
- 2021-04-19
- Combination sum Ⅳ -- leetcode exercise
- 【入门级基础】Node基础知识总结
- JS promise, async, await simple notes
- [project - what are the supporting materials in the annexes? (18 kinds of 2000 word summary)] project plan of innovation and entrepreneurship competition and supporting materials of Challenge Cup entr
- NDK learning notes (I)
猜你喜欢

袋鼠雲數棧基於CBO在Spark SQL優化上的探索

SQLite installation and configuration tutorial +navicat operation

Wechat custom component - style - slot

微信小程序text内置组件换行符不换行的原因-wxs处理换行符,正则加段首空格

C (I) C basic grammar all in one

Wechat applet uploads the data obtained from database 1 to database 2

Customize the layout of view Foundation

Recherche sur l'optimisation de Spark SQL basée sur CBO pour kangourou Cloud Stack

Deep learning distributed training

Number of atoms (easy to understand)
随机推荐
Multithreading tutorial (XXIII) thread safety without lock
Vins fusion GPS fusion part
Create cool collectionviewcell conversion animation
Recherche sur l'optimisation de Spark SQL basée sur CBO pour kangourou Cloud Stack
【项目篇- 附件佐证材料放什么?(十八种两千字总结)】创新创业竞赛项目计划书、挑战杯创业计划竞赛佐证材料
JVM tuning 6: GC log analysis and constant pool explanation
ImageView supporting single finger sliding and double finger scaling
Poverty has nothing to do with suffering
Preliminary test of running vins-fusion with zed2 binocular camera
35.搜索插入位置
Traversal of binary tree -- restoring binary tree by two different Traversals
Customize the layout of view Foundation
NDK learning notes (IX) POSIX sockect connection oriented communication
Es IK installation error
创建酷炫的 CollectionViewCell 转换动画
[go deep into kotlin] - get to know flow for the first time
22、生成括号
Multi threading tutorial (XXIV) cas+volatile
Solving graph problems with union search set
WinForm (I) introduction to WinForm and use of basic controls