mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2026-02-28 21:09:44 +00:00
Merge pull request #13293 from TeamNewPipe/getQuantity-inconsistency
Fix inconsistency in getQuantity and add docs
This commit is contained in:
@@ -426,12 +426,24 @@ public final class Localization {
|
||||
return new BigDecimal(value).setScale(scale, RoundingMode.HALF_UP).doubleValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* A wrapper around {@code context.getResources().getQuantityString()} with some safeguard.
|
||||
*
|
||||
* @param context the Android context
|
||||
* @param pluralId the ID of the plural resource
|
||||
* @param zeroCaseStringId the resource ID of the string to use in case {@code count=0},
|
||||
* or 0 if the plural resource should be used in the zero case too
|
||||
* @param count the number that should be used to pick the correct plural form
|
||||
* @param formattedCount the formatting parameter to substitute inside the plural resource,
|
||||
* ideally just {@code count} converted to string
|
||||
* @return the formatted string with the correct pluralization
|
||||
*/
|
||||
private static String getQuantity(@NonNull final Context context,
|
||||
@PluralsRes final int pluralId,
|
||||
@StringRes final int zeroCaseStringId,
|
||||
final long count,
|
||||
final String formattedCount) {
|
||||
if (count == 0) {
|
||||
if (count == 0 && zeroCaseStringId != 0) {
|
||||
return context.getString(zeroCaseStringId);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user