From baab0e24279100790bf0eccdb9d696ac2ec48684 Mon Sep 17 00:00:00 2001 From: 670637080 <110383438+670637080@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:11:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=85=E4=BE=9B=E9=80=BB=E8=BE=91=E5=8F=82?= =?UTF-8?q?=E8=80=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/tvbox/osc/util/SearchHelper.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/github/tvbox/osc/util/SearchHelper.java b/app/src/main/java/com/github/tvbox/osc/util/SearchHelper.java index 57c9c8c8..3f0f8a60 100644 --- a/app/src/main/java/com/github/tvbox/osc/util/SearchHelper.java +++ b/app/src/main/java/com/github/tvbox/osc/util/SearchHelper.java @@ -8,7 +8,9 @@ import com.orhanobut.hawk.Hawk; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.Map; import java.util.List; +import java.util.Iterator; public class SearchHelper { @@ -22,7 +24,26 @@ public class SearchHelper { } catch (Exception e) { return null; } - if (mCheckSources == null || mCheckSources.isEmpty()) mCheckSources = getSources(); + if (mCheckSources == null || mCheckSources.isEmpty()) { + mCheckSources = getSources(); + } else { + HashMap newSources = getSources(); + for (Map.Entry entry : newSources.entrySet()) { + String newKey = entry.getKey(); + String newValue = entry.getValue(); + if (!mCheckSources.containsKey(newKey)) { + mCheckSources.put(newKey, newValue); + } + } + Iterator> iterator = mCheckSources.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry oldEntry = iterator.next(); + String oldKey = oldEntry.getKey(); + if (!newSources.containsKey(oldKey)) { + iterator.remove(); + } + } + } return mCheckSources; }