FileDocCategorySizeDatePackage
MediaSizeUtils.javaAPI DocAndroid 5.1 API4048Thu Mar 12 22:22:42 GMT 2015com.android.printspooler.util

MediaSizeUtils

public final class MediaSizeUtils extends Object
Utility functions and classes for dealing with media sizes.

Fields Summary
private static Map
sMediaSizeToStandardMap
Constructors Summary
private MediaSizeUtils()

        /* do nothing - hide constructor */
    
Methods Summary
public static android.print.PrintAttributes.MediaSizegetDefault(android.content.Context context)
Gets the default media size for the current locale.

param
context Context for accessing resources.
return
The default media size.

        String mediaSizeId = context.getString(R.string.mediasize_default);
        return MediaSize.getStandardMediaSizeById(mediaSizeId);
    
private static java.lang.StringgetStandardForMediaSize(android.content.Context context, android.print.PrintAttributes.MediaSize mediaSize)

        if (sMediaSizeToStandardMap == null) {
            sMediaSizeToStandardMap = new ArrayMap<MediaSize, String>();
            String[] mediaSizeToStandardMapValues = context.getResources()
                    .getStringArray(R.array.mediasize_to_standard_map);
            final int mediaSizeToStandardCount = mediaSizeToStandardMapValues.length;
            for (int i = 0; i < mediaSizeToStandardCount; i += 2) {
                String mediaSizeId = mediaSizeToStandardMapValues[i];
                MediaSize key = MediaSize.getStandardMediaSizeById(mediaSizeId);
                String value = mediaSizeToStandardMapValues[i + 1];
                sMediaSizeToStandardMap.put(key, value);
            }
        }
        String standard = sMediaSizeToStandardMap.get(mediaSize);
        return (standard != null) ? standard : context.getString(
                R.string.mediasize_standard_iso);