Merge pull request #142 from 670637080/patch-2

修搜索bug by 670637080
pull/144/head
jun yu 1 year ago committed by GitHub
commit bb1658f8ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 23
      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<String, String> newSources = getSources();
for (Map.Entry<String, String> entry : newSources.entrySet()) {
String newKey = entry.getKey();
String newValue = entry.getValue();
if (!mCheckSources.containsKey(newKey)) {
mCheckSources.put(newKey, newValue);
}
}
Iterator<Map.Entry<String, String>> iterator = mCheckSources.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, String> oldEntry = iterator.next();
String oldKey = oldEntry.getKey();
if (!newSources.containsKey(oldKey)) {
iterator.remove();
}
}
}
return mCheckSources;
}

Loading…
Cancel
Save