fix crash Android 8-13 NoSuchMethodError, prevent crash for missing card

This commit is contained in:
Anthony Calosa
2025-09-13 09:09:04 +08:00
parent b61044abb5
commit 02b7e408dc
4 changed files with 8 additions and 8 deletions

View File

@@ -878,7 +878,7 @@ public class StaticData {
}
}
}
// stream().toList() causes crash on Android, use Collectors.toList()
// stream().toList() causes crash on Android 8-13, use Collectors.toList()
List<String> NIF = new ArrayList<>(NIF_Q).stream().sorted().collect(Collectors.toList());
List<String> CNI = new ArrayList<>(CNI_Q).stream().sorted().collect(Collectors.toList());
List<String> TOK = new ArrayList<>(TOKEN_Q).stream().sorted().collect(Collectors.toList());

View File

@@ -367,7 +367,7 @@ public class CardState extends GameObject implements IHasSVars, ITranslatable {
public final FCollectionView<SpellAbility> getManaAbilities() {
FCollection<SpellAbility> newCol = new FCollection<>();
updateSpellAbilities(newCol, true);
// stream().toList() causes crash on Android, use Collectors.toList()
// stream().toList() causes crash on Android 8-13, use Collectors.toList()
newCol.addAll(abilities.stream().filter(SpellAbility::isManaAbility).collect(Collectors.toList()));
card.updateSpellAbilities(newCol, this, true);
return newCol;
@@ -375,7 +375,7 @@ public class CardState extends GameObject implements IHasSVars, ITranslatable {
public final FCollectionView<SpellAbility> getNonManaAbilities() {
FCollection<SpellAbility> newCol = new FCollection<>();
updateSpellAbilities(newCol, false);
// stream().toList() causes crash on Android, use Collectors.toList()
// stream().toList() causes crash on Android 8-13, use Collectors.toList()
newCol.addAll(abilities.stream().filter(Predicate.not(SpellAbility::isManaAbility)).collect(Collectors.toList()));
card.updateSpellAbilities(newCol, this, false);
return newCol;
@@ -390,7 +390,7 @@ public class CardState extends GameObject implements IHasSVars, ITranslatable {
if (null != mana) {
leftAbilities = leftAbilities.stream()
.filter(mana ? SpellAbility::isManaAbility : Predicate.not(SpellAbility::isManaAbility))
// stream().toList() causes crash on Android, use Collectors.toList()
// stream().toList() causes crash on Android 8-13, use Collectors.toList()
.collect(Collectors.toList());
}
newCol.addAll(leftAbilities);
@@ -402,7 +402,7 @@ public class CardState extends GameObject implements IHasSVars, ITranslatable {
if (null != mana) {
rightAbilities = rightAbilities.stream()
.filter(mana ? SpellAbility::isManaAbility : Predicate.not(SpellAbility::isManaAbility))
// stream().toList() causes crash on Android, use Collectors.toList()
// stream().toList() causes crash on Android 8-13, use Collectors.toList()
.collect(Collectors.toList());
}
newCol.addAll(rightAbilities);

View File

@@ -517,8 +517,8 @@ public class DeckImportController {
PaperCard card = token.getCard();
String cardName = card.getName();
CardPool substitutes = availableInventory.getFilteredPool(c -> c.getName().equals(cardName));
// Stream.toList() is only supported on Android 14 and above ref: https://developer.android.com/reference/java/util/stream/Stream#toList()
// use Collectors.toList() to support Android 8 to 13....
// stream().toList() causes crash on Android 8-13, use Collectors.toList()
// ref: https://developer.android.com/reference/java/util/stream/Stream#toList()
List<Map.Entry<PaperCard, Integer>> sortedSubstitutes = StreamUtil.stream(substitutes).sorted(Comparator.comparingInt(Map.Entry::getValue)).collect(Collectors.toList());
int neededQuantity = token.getQuantity();
for(Token found : replacementList) {

View File

@@ -437,7 +437,7 @@ public class BoosterDraft implements IBoosterDraft {
CompletableFuture.allOf(futuresArray).join();
futures.clear();
}
// stream().toList() causes crash on Android, use Collectors.toList()
// stream().toList() causes crash on Android 8-13, use Collectors.toList()
customs.addAll(queue.stream().collect(Collectors.toList()));
}
return customs;