diff --git a/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailView.kt b/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailView.kt index 1c0f1df045ac95c3d68b080e155b7d492a738015..0d252376ae65a59eb99764d7dbd4b10462d8d018 100644 --- a/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailView.kt +++ b/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailView.kt @@ -859,11 +859,11 @@ class VideoDetailView : ConstraintLayout { private val _historyIndexLock = Mutex(false); - suspend fun getHistoryIndex(video: IPlatformVideo): DBHistory.Index = withContext(Dispatchers.IO){ + suspend fun getHistoryIndex(video: IPlatformVideo): DBHistory.Index? = withContext(Dispatchers.IO){ _historyIndexLock.withLock { val current = _historyIndex; if(current == null || current.url != video.url) { - val index = StateHistory.instance.getHistoryByVideo(video, true)!!; + val index = StateHistory.instance.getHistoryByVideo(video, true); _historyIndex = index; return@withContext index; } @@ -1390,7 +1390,7 @@ class VideoDetailView : ConstraintLayout { if (video !is TutorialFragment.TutorialVideo) { fragment.lifecycleScope.launch(Dispatchers.IO) { - val historyItem = getHistoryIndex(videoDetail); + val historyItem = getHistoryIndex(videoDetail) ?: return@launch; withContext(Dispatchers.Main) { _historicalPosition = StateHistory.instance.updateHistoryPosition(video, historyItem,false, (toResume.toFloat() / 1000.0f).toLong()); @@ -2252,7 +2252,7 @@ class VideoDetailView : ConstraintLayout { if (updateHistory && (_lastPositionSaveTime == -1L || currentTime - _lastPositionSaveTime > 5000)) { if (v !is TutorialFragment.TutorialVideo) { fragment.lifecycleScope.launch(Dispatchers.IO) { - val history = getHistoryIndex(v); + val history = getHistoryIndex(v) ?: return@launch; StateHistory.instance.updateHistoryPosition(v, history, true, (positionMilliseconds.toFloat() / 1000.0f).toLong()); } } diff --git a/app/src/main/java/com/futo/platformplayer/states/StateHistory.kt b/app/src/main/java/com/futo/platformplayer/states/StateHistory.kt index 2beaf40a834558ba42e772d48cd268ce1db24b6f..9f9ef81ffcc86ff22be67f4b49ab50a78cefd5a4 100644 --- a/app/src/main/java/com/futo/platformplayer/states/StateHistory.kt +++ b/app/src/main/java/com/futo/platformplayer/states/StateHistory.kt @@ -106,7 +106,7 @@ class StateHistory { if(result == null) UIDialogs.toast("History creation failed?\nNo history tracking.."); } - return null; + return result; } fun removeHistory(url: String) {