Size.java revision e3dfd5a433e39d76578b379fe1539864cf924cee
1/* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.camera.util; 18 19/** 20 * Simple size class until we are 'L' only and can use android.util.Size. 21 */ 22public class Size { 23 private final int width; 24 private final int height; 25 26 public static Size[] convert(android.util.Size[] sizes) { 27 Size[] converted = new Size[sizes.length]; 28 for (int i = 0; i < sizes.length; ++i) { 29 converted[i] = new Size(sizes[i].getWidth(), sizes[i].getHeight()); 30 } 31 return converted; 32 } 33 34 public Size(android.util.Size size) { 35 this.width = size.getWidth(); 36 this.height = size.getHeight(); 37 } 38 39 public Size(int width, int height) { 40 this.width = width; 41 this.height = height; 42 } 43 44 public int getWidth() { 45 return width; 46 } 47 48 public int getHeight() { 49 return height; 50 } 51 52 @Override 53 public String toString() { 54 return width + " x " + height; 55 } 56 57 @Override 58 public boolean equals(Object other) { 59 if (!(other instanceof Size)) { 60 return false; 61 } 62 63 Size otherSize = (Size) other; 64 return otherSize.width == this.width && otherSize.height == this.height; 65 } 66} 67