[feat] Fix local detection logic defects

This commit is contained in:
acite
2025-09-27 15:59:39 +08:00
parent 584fc1f785
commit ba1a7c9a92
4 changed files with 18 additions and 10 deletions

View File

@@ -72,7 +72,8 @@ class MediaManager @Inject constructor(
it.extras.getString("class", "") == klass it.extras.getString("class", "") == klass
} }
if(downloaded.all{ it.status == Status.COMPLETED }) if(downloaded.any{ it.status == Status.COMPLETED }
&& downloaded.all{ it.status == Status.COMPLETED || it.extras.getString("type", "") == "subtitle" })
{ {
val jsonString = File( val jsonString = File(
context.getExternalFilesDir(null), context.getExternalFilesDir(null),
@@ -98,10 +99,14 @@ class MediaManager @Inject constructor(
val remoteIds = mutableListOf<String>() val remoteIds = mutableListOf<String>()
for (videoId in id) { for (videoId in id) {
if (downloads.filter { val o = downloads.filter {
it.extras.getString("id", "") == videoId && it.extras.getString("id", "") == videoId &&
it.extras.getString("class", "") == klass it.extras.getString("class", "") == klass
}.all{ it.status == Status.COMPLETED} ) { }
if (o.any{ it.status == Status.COMPLETED }
&& o.all{ it.status == Status.COMPLETED || it.extras.getString("type", "") == "subtitle" })
{
localIds.add(videoId) localIds.add(videoId)
} else { } else {
remoteIds.add(videoId) remoteIds.add(videoId)

View File

@@ -227,7 +227,7 @@ class TransmissionScreenViewModel @Inject constructor(
downloads.clear() downloads.clear()
idToState.clear() idToState.clear()
downloaded.sortedWith(compareBy(naturalOrder()) { it.extras.getString("name", "") }) downloaded.filter { it.extras.getString("type", "") == "main" }.sortedWith(compareBy(naturalOrder()) { it.extras.getString("name", "") })
.forEach { d -> .forEach { d ->
val s = downloadToState(d) val s = downloadToState(d)
downloads.add(s) downloads.add(s)

View File

@@ -110,6 +110,8 @@ class VideoPlayerViewModel @Inject constructor(
{ {
vs = oId.split("|")[0].split(",").map { it.split("/") }.toMutableList() vs = oId.split("|")[0].split(",").map { it.split("/") }.toMutableList()
spec = oId.split("|")[1] spec = oId.split("|")[1]
}else{
vs = oId.split(",").map { it.split("/") }.toMutableList()
} }
imageLoader = ImageLoader.Builder(context) imageLoader = ImageLoader.Builder(context)

View File

@@ -71,8 +71,9 @@ class VideoScreenViewModel @Inject constructor(
if (vl != null) { if (vl != null) {
val r = vl.sortedWith(compareBy(naturalOrder()) { it.video.name }) val r = vl.sortedWith(compareBy(naturalOrder()) { it.video.name })
videoLibrary.classesMap[videoLibrary.classes[0]]?.addAll(r) val existsId = videoLibrary.classesMap[videoLibrary.classes[0]]?.map { it.id }
videoLibrary.classesMap[videoLibrary.classes[0]]?.distinctBy { it.id }
videoLibrary.classesMap[videoLibrary.classes[0]]?.addAll(r.filter { existsId == null || it.id !in existsId })
} }
} }
else { else {
@@ -110,8 +111,8 @@ class VideoScreenViewModel @Inject constructor(
if (vl != null) { if (vl != null) {
val r = vl.sortedWith(compareBy(naturalOrder()) { it.video.name }) val r = vl.sortedWith(compareBy(naturalOrder()) { it.video.name })
videoLibrary.classesMap[videoLibrary.classes[index]]?.addAll(r) val existsId = videoLibrary.classesMap[videoLibrary.classes[index]]?.map { it.id }
videoLibrary.classesMap[videoLibrary.classes[index]]?.distinctBy { it.id } videoLibrary.classesMap[videoLibrary.classes[index]]?.addAll(r.filter { existsId == null || it.id !in existsId })
} }
} }
} }