fix: 1358 - rolled back to old-fashioned Collections.sort for android 23 (#1595)

cf. https://developer.android.com/reference/java/util/List#sort(java.util.Comparator%3C?%20super%20E%3E), "added in API level 24"
This commit is contained in:
monsieurtanuki 2023-03-23 18:48:54 +01:00 committed by GitHub
parent 40fc4d545d
commit f3c2b44e35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,6 +25,7 @@ import com.google.zxing.common.BitMatrix;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
@ -628,7 +629,10 @@ public class FinderPatternFinder {
}
}
possibleCenters.sort(moduleComparator);
// A more up-to-date version would be "possibleCenters.sort(moduleComparator);"
// But we need this old syntax for android API 23 (Marshmallow) and below
// cf. https://github.com/zxing/zxing/issues/1358
Collections.sort(possibleCenters, moduleComparator);
double distortion = Double.MAX_VALUE;
FinderPattern[] bestPatterns = new FinderPattern[3];