-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from RaedGhazal/feature/initial_size_configura…
…tion #17 Feature: configure initial frame size
- Loading branch information
Showing
8 changed files
with
68 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package io.moyuru.cropify | ||
|
||
import androidx.annotation.FloatRange | ||
|
||
sealed interface CropifySize { | ||
|
||
data class PercentageSize( | ||
@FloatRange(0.0, 1.0, fromInclusive = false) | ||
val widthPercentage: Float, | ||
@FloatRange(0.0, 1.0, fromInclusive = false) | ||
val heightPercentage: Float | ||
) : CropifySize { | ||
|
||
constructor( | ||
@FloatRange(0.0, 1.0, fromInclusive = false) | ||
percentage: Float | ||
) : this(percentage, percentage) | ||
|
||
init { | ||
require(widthPercentage > 0f && widthPercentage <= 1f) { "widthPercentage must be more than 0f and less or equal to 1f" } | ||
require(heightPercentage > 0f && heightPercentage <= 1f) { "heightPercentage must be more than 0f and less or equal to 1f" } | ||
} | ||
|
||
companion object { | ||
val FullSize = PercentageSize(1f) | ||
} | ||
|
||
} | ||
|
||
data class FixedAspectRatio(val value: Float) : CropifySize { | ||
constructor(x: Int, y: Int) : this(y / x.toFloat()) | ||
constructor(x: Float, y: Float) : this(y / x) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters