public static Pair < Integer , Integer > parseResolution ( @ NonNull final Context context , @ NonNull final String resolution ) { Condition . INSTANCE . ensureNotNull ( context , "The context may not be null" ) ; Condition . INSTANCE . ensureNotNull ( resolution , "The resolution may not be null" ) ; Condition . INSTANCE . ensureNotEmpty ( resolution , "The resolution may not be empty" ) ; String separator = context . getString ( R . string . resolution_preference_separator ) ; String [ ] dimensions = resolution . split ( separator ) ; if ( dimensions . length != 2 ) { throw new IllegalArgumentException ( "Malformed resolution: " + resolution ) ; } try { int width = Integer . parseInt ( dimensions [ 0 ] ) ; int height = Integer . parseInt ( dimensions [ 1 ] ) ; return Pair . create ( width , height ) ; } catch ( NumberFormatException e ) { throw new IllegalArgumentException ( "Resolution contains invalid dimension: " + resolution , e ) ; } }
Parses a specific textual representation of a resolution and returns its dimensions .