blob: 83cc2f11b3b53072585d42e1cc882aeea4ec3f20 [file] [log] [blame]
package com.example.android.camera2basic
import android.util.Size
import java.lang.Long.signum
import java.util.Comparator
/**
* Compares two `Size`s based on their areas.
*/
internal class CompareSizesByArea : Comparator<Size> {
// We cast here to ensure the multiplications won't overflow
override fun compare(lhs: Size, rhs: Size) =
signum(lhs.width.toLong() * lhs.height - rhs.width.toLong() * rhs.height)
}