在获取弹幕时抛异常后尝试关闭数据库
This commit is contained in:
parent
52e4312a32
commit
3f10e19e50
@ -89,6 +89,7 @@ public class LiveDanmuService {
|
|||||||
public LiveVideoDanmu getDanmu(String roomId, String videoId, int page) {
|
public LiveVideoDanmu getDanmu(String roomId, String videoId, int page) {
|
||||||
LiveVideoDanmu danmus = new LiveVideoDanmu();
|
LiveVideoDanmu danmus = new LiveVideoDanmu();
|
||||||
BiliLiveDatabase liveDatabase = new BiliLiveDatabase(LiveRoomConfig.buildConfig(roomId));
|
BiliLiveDatabase liveDatabase = new BiliLiveDatabase(LiveRoomConfig.buildConfig(roomId));
|
||||||
|
try {
|
||||||
LiveVideoDatabaseBean videoBean = liveDatabase.getVideo(videoId);
|
LiveVideoDatabaseBean videoBean = liveDatabase.getVideo(videoId);
|
||||||
if (videoBean == null) {
|
if (videoBean == null) {
|
||||||
return new LiveVideoDanmu();
|
return new LiveVideoDanmu();
|
||||||
@ -104,7 +105,7 @@ public class LiveDanmuService {
|
|||||||
List<LiveVideoDanmu.Danmu> danmuList = liveDatabase.getOfTime(startTime, endTime, page, pageSize, LiveDanmuDatabaseBean.class)
|
List<LiveVideoDanmu.Danmu> danmuList = liveDatabase.getOfTime(startTime, endTime, page, pageSize, LiveDanmuDatabaseBean.class)
|
||||||
.stream()
|
.stream()
|
||||||
.map(item -> createDanmu(item, startTime))
|
.map(item -> createDanmu(item, startTime))
|
||||||
.filter(item-> item.getTime()>=0)
|
.filter(item -> item.getTime() >= 0)
|
||||||
.toList();
|
.toList();
|
||||||
danmus.getDanmu().addAll(danmuList);
|
danmus.getDanmu().addAll(danmuList);
|
||||||
danmus.setDanmuCount(count);
|
danmus.setDanmuCount(count);
|
||||||
@ -118,7 +119,12 @@ public class LiveDanmuService {
|
|||||||
danmus.getSuperChat().add(superChat);
|
danmus.getSuperChat().add(superChat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(e);
|
||||||
|
} finally {
|
||||||
liveDatabase.close();
|
liveDatabase.close();
|
||||||
|
}
|
||||||
|
|
||||||
return danmus;
|
return danmus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user