FileDocCategorySizeDatePackage
Size.javaAPI DocAndroid 5.1 API4838Thu Mar 12 22:22:48 GMT 2015com.android.ex.camera2.portability

Size

public class Size extends Object
An immutable simple size container.

Fields Summary
public static final String
DELIMITER
private final android.graphics.Point
val
Constructors Summary
public Size(int width, int height)
Constructor.

        val = new Point(width, height);
    
public Size(Size other)
Copy constructor.

        if (other == null) {
            val = new Point(0, 0);
        } else {
            val = new Point(other.width(), other.height());
        }
    
public Size(Camera.Size other)
Constructor from a source {@link android.hardware.Camera.Size}.

param
other The source size.

        if (other == null) {
            val = new Point(0, 0);
        } else {
            val = new Point(other.width, other.height);
        }
    
public Size(android.util.Size other)
Constructor from a source {@link android.util.Size}.

param
other The source size.

        if (other == null) {
            val = new Point(0, 0);
        } else {
            val = new Point(other.getWidth(), other.getHeight());
        }
    
public Size(android.graphics.Point p)
Constructor from a source {@link android.graphics.Point}.

param
p The source size.

        if (p == null) {
            val = new Point(0, 0);
        } else {
            val = new Point(p);
        }
    
Methods Summary
public static java.util.ListbuildListFromAndroidSizes(java.util.List androidSizes)
A helper method to build a list of this class from a list of {@link android.util.Size}.

param
cameraSizes Source.
return
The built list.

        ArrayList<Size> list = new ArrayList<Size>(androidSizes.size());
        for (android.util.Size androidSize : androidSizes) {
            list.add(new Size(androidSize));
        }
        return list;
    
public static java.util.ListbuildListFromCameraSizes(java.util.List cameraSizes)
An helper method to build a list of this class from a list of {@link android.hardware.Camera.Size}.

param
cameraSizes Source.
return
The built list.


                                
         
        ArrayList<Size> list = new ArrayList<Size>(cameraSizes.size());
        for (Camera.Size cameraSize : cameraSizes) {
            list.add(new Size(cameraSize));
        }
        return list;
    
public booleanequals(java.lang.Object o)

        if (o instanceof Size) {
            Size other = (Size) o;
            return val.equals(other.val);
        }
        return false;
    
public inthashCode()

        return val.hashCode();
    
public intheight()

        return val.y;
    
public static java.lang.StringlistToString(java.util.List sizes)
Encode List of this class as comma-separated list of integers.

param
sizes List of this class to encode.
return
encoded string.

        ArrayList<Integer> flatSizes = new ArrayList<>();
        for (Size s : sizes) {
            flatSizes.add(s.width());
            flatSizes.add(s.height());
        }
        return TextUtils.join(DELIMITER, flatSizes);
    
public static java.util.ListstringToList(java.lang.String encodedSizes)
Decode comma-separated even-length list of integers into a List of this class.

param
encodedSizes encoded string.
return
List of this class.

        String[] flatSizes = TextUtils.split(encodedSizes, DELIMITER);
        ArrayList<Size> list = new ArrayList<>();
        for (int i = 0; i < flatSizes.length; i += 2) {
            int width = Integer.parseInt(flatSizes[i]);
            int height = Integer.parseInt(flatSizes[i + 1]);
            list.add(new Size(width,height));
        }
        return list;
    
public java.lang.StringtoString()

        return "Size: (" + this.width() + " x " + this.height() + ")";
    
public intwidth()

        return val.x;