Package com.stripe.android.camera.framework.util

Types

Link copied to clipboard
abstract class FrameSaver<Identifier, Frame, MetaData>

Save data frames for later retrieval.

Link copied to clipboard
class UnexpectedRetryException : Exception

This exception should never be thrown.

Functions

Link copied to clipboard
fun adjustSizeToAspectRatio(area: Size, aspectRatio: Float): Size

Given a size and an aspect ratio, resize the area to fit that aspect ratio. If the desired aspect ratio is smaller than the one of the provided size, the size will be cropped to match. If the desired aspect ratio is larger than the that of the provided size, then the size will be expanded to match.

Link copied to clipboard
fun Size.aspectRatio(): Float

Determine the aspect ratio of a Size.

fun SizeF.aspectRatio(): Float

Determine the aspect ratio of a SizeF.

Link copied to clipboard
fun <Result> () -> Result.cachedFirstResult(): () -> Result
fun <Input, Result> (Input) -> Result.cachedFirstResult(): (Input) -> Result
fun <Input1, Input2, Result> (Input1, Input2) -> Result.cachedFirstResult(): (Input1, Input2) -> Result
fun <Input1, Input2, Input3, Result> (Input1, Input2, Input3) -> Result.cachedFirstResult(): (Input1, Input2, Input3) -> Result
Link copied to clipboard
fun <Result> suspend () -> Result.cachedFirstResultSuspend(): suspend () -> Result
fun <Input, Result> suspend (Input) -> Result.cachedFirstResultSuspend(): suspend (Input) -> Result
fun <Input1, Input2, Result> suspend (Input1, Input2) -> Result.cachedFirstResultSuspend(): suspend (Input1, Input2) -> Result
fun <Input1, Input2, Input3, Result> suspend (Input1, Input2, Input3) -> Result.cachedFirstResultSuspend(): suspend (Input1, Input2, Input3) -> Result
Link copied to clipboard
fun <Result> cacheFirstResult(f: () -> Result): () -> Result
fun <Input, Result> cacheFirstResult(f: (Input) -> Result): (Input) -> Result
fun <Input1, Input2, Result> cacheFirstResult(f: (Input1, Input2) -> Result): (Input1, Input2) -> Result
fun <Input1, Input2, Input3, Result> cacheFirstResult(f: (Input1, Input2, Input3) -> Result): (Input1, Input2, Input3) -> Result
Link copied to clipboard
fun <Result> cacheFirstResultSuspend(f: suspend () -> Result): suspend () -> Result
fun <Input, Result> cacheFirstResultSuspend(f: suspend (Input) -> Result): suspend (Input) -> Result
fun <Input1, Input2, Result> cacheFirstResultSuspend(f: suspend (Input1, Input2) -> Result): suspend (Input1, Input2) -> Result
fun <Input1, Input2, Input3, Result> cacheFirstResultSuspend(f: suspend (Input1, Input2, Input3) -> Result): suspend (Input1, Input2, Input3) -> Result
Link copied to clipboard
fun Size.centerOn(rect: Rect): Rect

Center a size on a given rectangle. The size may be larger or smaller than the rect.

Link copied to clipboard
fun Rect.centerScaled(scaleX: Float, scaleY: Float): Rect

fun RectF.centerScaled(scaleX: Float, scaleY: Float): RectF

Scale a Rect to have a size equivalent to the scaledSize. This will maintain the center position of the Rect.

Link copied to clipboard
fun Rect.intersectionWith(rect: Rect): Rect

Return a rect that is the intersection of two other rects

Link copied to clipboard
fun maxAspectRatioInSize(area: Size, aspectRatio: Float): Size

Determine the maximum size of rectangle with a given aspect ratio (X/Y) that can fit inside the specified area.

Link copied to clipboard
fun <Result> memoize(f: () -> Result): () -> Result
fun <Input, Result> memoize(f: (Input) -> Result): (Input) -> Result
fun <Input1, Input2, Result> memoize(f: (Input1, Input2) -> Result): (Input1, Input2) -> Result
fun <Input1, Input2, Input3, Result> memoize(f: (Input1, Input2, Input3) -> Result): (Input1, Input2, Input3) -> Result
fun <Result> memoize(validFor: Duration, f: () -> Result): () -> Result
fun <Input, Result> memoize(validFor: Duration, f: (Input) -> Result): (Input) -> Result
fun <Input1, Input2, Result> memoize(validFor: Duration, f: (Input1, Input2) -> Result): (Input1, Input2) -> Result
fun <Input1, Input2, Input3, Result> memoize(validFor: Duration, f: (Input1, Input2, Input3) -> Result): (Input1, Input2, Input3) -> Result
Link copied to clipboard
fun <Result> () -> Result.memoized(): () -> Result
fun <Input, Result> (Input) -> Result.memoized(): (Input) -> Result
fun <Input1, Input2, Result> (Input1, Input2) -> Result.memoized(): (Input1, Input2) -> Result
fun <Input1, Input2, Input3, Result> (Input1, Input2, Input3) -> Result.memoized(): (Input1, Input2, Input3) -> Result
fun <Result> () -> Result.memoized(validFor: Duration): () -> Result
fun <Input, Result> (Input) -> Result.memoized(validFor: Duration): (Input) -> Result
fun <Input1, Input2, Result> (Input1, Input2) -> Result.memoized(validFor: Duration): (Input1, Input2) -> Result
fun <Input1, Input2, Input3, Result> (Input1, Input2, Input3) -> Result.memoized(validFor: Duration): (Input1, Input2, Input3) -> Result
Link copied to clipboard
fun <Result> suspend () -> Result.memoizedSuspend(): suspend () -> Result
fun <Input, Result> suspend (Input) -> Result.memoizedSuspend(): suspend (Input) -> Result
fun <Input1, Input2, Result> suspend (Input1, Input2) -> Result.memoizedSuspend(): suspend (Input1, Input2) -> Result
fun <Input1, Input2, Input3, Result> suspend (Input1, Input2, Input3) -> Result.memoizedSuspend(): suspend (Input1, Input2, Input3) -> Result
fun <Result> suspend () -> Result.memoizedSuspend(validFor: Duration): suspend () -> Result
fun <Input, Result> suspend (Input) -> Result.memoizedSuspend(validFor: Duration): suspend (Input) -> Result
fun <Input1, Input2, Result> suspend (Input1, Input2) -> Result.memoizedSuspend(validFor: Duration): suspend (Input1, Input2) -> Result
fun <Input1, Input2, Input3, Result> suspend (Input1, Input2, Input3) -> Result.memoizedSuspend(validFor: Duration): suspend (Input1, Input2, Input3) -> Result
Link copied to clipboard
fun <Result> memoizeSuspend(f: suspend () -> Result): suspend () -> Result
fun <Input, Result> memoizeSuspend(f: suspend (Input) -> Result): suspend (Input) -> Result
fun <Input1, Input2, Result> memoizeSuspend(f: suspend (Input1, Input2) -> Result): suspend (Input1, Input2) -> Result
fun <Input1, Input2, Input3, Result> memoizeSuspend(f: suspend (Input1, Input2, Input3) -> Result): suspend (Input1, Input2, Input3) -> Result
fun <Result> memoizeSuspend(validFor: Duration, f: suspend () -> Result): suspend () -> Result
fun <Input, Result> memoizeSuspend(validFor: Duration, f: suspend (Input) -> Result): suspend (Input) -> Result
fun <Input1, Input2, Result> memoizeSuspend(validFor: Duration, f: suspend (Input1, Input2) -> Result): suspend (Input1, Input2) -> Result
fun <Input1, Input2, Input3, Result> memoizeSuspend(validFor: Duration, f: suspend (Input1, Input2, Input3) -> Result): suspend (Input1, Input2, Input3) -> Result
Link copied to clipboard
fun minAspectRatioSurroundingSize(area: Size, aspectRatio: Float): Size

Determine the minimum size of rectangle with a given aspect ratio (X/Y) that a specified area can fit inside.

Link copied to clipboard
fun Rect.move(relativeX: Int, relativeY: Int): Rect
fun RectF.move(relativeX: Float, relativeY: Float): RectF

Move relative to its current position

Link copied to clipboard
fun Rect.projectRegionOfInterest(toRect: Rect, regionOfInterest: Rect): Rect
fun RectF.projectRegionOfInterest(toRect: RectF, regionOfInterest: RectF): RectF

Project a region of interest from one Rect to another. For example, given the rect and region of interest:

fun Rect.projectRegionOfInterest(toSize: Size, regionOfInterest: Rect): Rect
fun RectF.projectRegionOfInterest(toSize: SizeF, regionOfInterest: RectF): RectF

fun Size.projectRegionOfInterest(toSize: Size, regionOfInterest: Rect): Rect
fun SizeF.projectRegionOfInterest(toSize: SizeF, regionOfInterest: RectF): RectF

Takes a relation between a region of interest and a size and projects the region of interest to that new location

Link copied to clipboard
fun Size.resizeRegion(    originalRegion: Rect,     newRegion: Rect,     newSize: Size): Map<Rect, Rect>

This method allows relocating and resizing a portion of a Size. It returns the required translations required to achieve this relocation. This is useful for zooming in on sections of an image.

Link copied to clipboard
fun Size.scale(scale: Float): Size
fun SizeF.scale(scale: Float): SizeF

Calculate the new size based on a percentage scale.

fun Size.scale(x: Float, y: Float): Size
fun SizeF.scale(x: Float, y: Float): SizeF

Calculate the new size based on percentage scale values.

Link copied to clipboard
fun Size.scaleAndCenterSurrounding(surroundedSize: Size): Rect

Calculate the position of the Size surrounding the surroundedSize. This makes a few assumptions:

Link copied to clipboard
fun Size.scaleAndCenterWithin(containingRect: Rect): Rect

fun Size.scaleAndCenterWithin(containingSize: Size): Rect

Scale up a Size so that it fills a containingSize while maintaining its original aspect ratio.

Link copied to clipboard
fun Size.scaleCentered(x: Float, y: Float): Rect

Scale a size based on percentage scale values, and keep track of its position.

Link copied to clipboard
fun RectF.scaled(scaledSize: Size): RectF

Scale a Rect to have a size equivalent to the scaledSize. This will also scale the position of the Rect.

Link copied to clipboard
fun Rect.size(): Size

Determine the size of a Rect.

fun RectF.size(): SizeF

Determine the size of a RectF.

fun View.size(): Size

Determine the size of a View.

Link copied to clipboard
fun RectF.toRect(): Rect

fun Size.toRect(): Rect

Converts a size to rectangle with the top left corner at 0,0

Link copied to clipboard
fun Rect.toRectF(): RectF
fun Size.toRectF(): RectF
Link copied to clipboard
fun SizeF.toSize(): Size
Link copied to clipboard
fun Size.toSizeF(): SizeF
Link copied to clipboard
fun Size.transpose(): Size

Transpose a size's width and height.