Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bce3d611 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Annotate SafeVarargs to formatString"

parents 7fe07bdd d2b63667
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -25,10 +25,12 @@ import androidx.annotation.StringRes
import java.util.Locale

@RequiresApi(Build.VERSION_CODES.N)
@SafeVarargs
fun Context.formatString(@StringRes resId: Int, vararg arguments: Pair<String, Any>): String =
    resources.formatString(resId, *arguments)

@RequiresApi(Build.VERSION_CODES.N)
@SafeVarargs
fun Resources.formatString(@StringRes resId: Int, vararg arguments: Pair<String, Any>): String =
    MessageFormat(getString(resId), Locale.getDefault(Locale.Category.FORMAT))
        .format(mapOf(*arguments))