File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
app/src/main/java/org/schabi/newpipe/util Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -426,12 +426,24 @@ private static double round(final double value, final int scale) {
426426 return new BigDecimal (value ).setScale (scale , RoundingMode .HALF_UP ).doubleValue ();
427427 }
428428
429+ /**
430+ * A wrapper around {@code context.getResources().getQuantityString()} with some safeguard.
431+ *
432+ * @param context the Android context
433+ * @param pluralId the ID of the plural resource
434+ * @param zeroCaseStringId the resource ID of the string to use in case {@code count=0},
435+ * or 0 if the plural resource should be used in the zero case too
436+ * @param count the number that should be used to pick the correct plural form
437+ * @param formattedCount the formatting parameter to substitute inside the plural resource,
438+ * ideally just {@code count} converted to string
439+ * @return the formatted string with the correct pluralization
440+ */
429441 private static String getQuantity (@ NonNull final Context context ,
430442 @ PluralsRes final int pluralId ,
431443 @ StringRes final int zeroCaseStringId ,
432444 final long count ,
433445 final String formattedCount ) {
434- if (count == 0 ) {
446+ if (count == 0 && zeroCaseStringId != 0 ) {
435447 return context .getString (zeroCaseStringId );
436448 }
437449
You can’t perform that action at this time.
0 commit comments