掘金 | 公众号 | 简书 |
---|---|---|
点我 | 九心说 | 点我 |
- 🙋🏻 Android 程序员,懂一点 Android Jetpack \ Flutter
- 🏀 运动爱好者,游戏爱好者
- 📫 [email protected]
Above are the last 3 pictures posted by @jiuxin98!
🌠 一个支持多视图和碰撞检测的弹幕库
掘金 | 公众号 | 简书 |
---|---|---|
点我 | 九心说 | 点我 |
Above are the last 3 pictures posted by @jiuxin98!
如果每条弹幕长度不一样 会出现重叠问题
首先非常感谢作者的开源库,很好。
我现在碰到一个需求是,类似9宫格相册,点击预览大图,大图上面有弹幕。但是每个图片的对应的弹幕不同,并且我每次滑动一下都要从新取下数据,再从新展示弹幕。
我在ViewPager的onPageSelect中,destroy了前一个pager的弹幕,但是当我滑动回来从新赋值数据,弹幕就不展示了。
怎么办呢,谢谢
Task java.util.concurrent.FutureTask@1bb4925 rejected from java.util.concurrent.ThreadPoolExecutor@4a59afa[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0]
com.orient.tea.barragephoto.adapter.BarrageAdapter.add(BarrageAdapter.java:170)
bugly统计的项目崩掉了,在add弹幕的时候,希望可以解决一下~
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int value = (int) animation.getAnimatedValue();
//Log.e(TAG, "value:" + value);
if(cancel){
valueAnimator.cancel();
BarrageView.this.removeView(view);
}
view.layout(value, line * (singleLineHeight + barrageDistance) + barrageDistance / 2, value + itemWidth, line * (singleLineHeight + barrageDistance) + barrageDistance / 2 + itemHeight);
}
});
看int value = (int) animation.getAnimatedValue();
, 由于Integer的缓存池是-128-127,所以内存大量重复创建Integer对象,是否能优化下呢?我目前优化的方案是:
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float value = animation.getAnimatedFraction();
//Log.e(TAG, "value:" + value);
if (cancel) {
valueAnimator.cancel();
BarrageView.this.removeView(view);
}
view.layout((int) (width - (width + itemWidth) * value), line * (singleLineHeight + barrageDistance) + barrageDistance / 2, (int) (width - (width + itemWidth) * value) + itemWidth, line * (singleLineHeight + barrageDistance) + barrageDistance / 2 + itemHeight);
}
});
把内容添加上去的时候有点卡顿 请问是什么问题引起的???
如果把控件放入adapter中的itemView,就无法实现动态控制
BarrageView被销毁,该Log还在打印,说明某些资源还没有被关闭,我采用在BarrageAdapter的destroy方法中将mHandler置空,然后在mHandler发送消息和移除消息的都做了是否为空的判断解决了这个问题。还请原作者再检查一下代码,如有更好的解决方法,还麻烦原作者告知,以求共同进步,谢谢。
弹幕文本内容超过屏幕宽度就会换行显示,弹幕只显示单行显示不全,应该加个类似textview singline这样的属性,
//设置弹幕数据
List dataList = new LinkedList<>();
for (int i = 0; i < content.length; i++) {
dataList.add(new BarrageData(content[i], 0,i));
}
mAdapter.addList(dataList);
这样添加数据会经常角标越界
异常日志
java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
at com.orient.tea.barragephoto.ui.BarrageView.getSpeed(BarrageView.java:314)
at com.orient.tea.barragephoto.ui.BarrageView.addBarrageItem(BarrageView.java:263)
at com.orient.tea.barragephoto.adapter.BarrageAdapter.createItemView(BarrageAdapter.java:101)
at com.orient.tea.barragephoto.adapter.BarrageAdapter.access$500(BarrageAdapter.java:31)
at com.orient.tea.barragephoto.adapter.BarrageAdapter$BarrageAdapterHandler.handleMessage(BarrageAdapter.java:275)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.