Compare commits
No commits in common. "c64516693c84d500dca6673e7085ab27340019bb" and "bf122db919945335f2c12871291cd0fe71a52f40" have entirely different histories.
c64516693c
...
bf122db919
@ -1,7 +1,6 @@
|
|||||||
package com.mrousavy.camera.core
|
package com.mrousavy.camera.core
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.res.Configuration
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Point
|
import android.graphics.Point
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
@ -98,14 +97,22 @@ class PreviewView(context: Context, callback: SurfaceHolder.Callback) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getSize(contentSize: Size, containerSize: Size, resizeMode: ResizeMode): Size {
|
override fun requestLayout() {
|
||||||
var contentSize = contentSize
|
super.requestLayout()
|
||||||
var androidOrientation = context.getResources().getConfiguration().orientation;
|
// Manually trigger measure & layout, as RN on Android skips those.
|
||||||
|
// See this issue: https://github.com/facebook/react-native/issues/17968#issuecomment-721958427
|
||||||
if (androidOrientation == Configuration.ORIENTATION_LANDSCAPE) {
|
post {
|
||||||
contentSize = Size(contentSize.height, contentSize.width)
|
measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY))
|
||||||
|
layout(left, top, right, bottom)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getSize(contentSize: Size, containerSize: Size, resizeMode: ResizeMode): Size {
|
||||||
|
var contentSize = contentSize
|
||||||
|
// Swap dimensions if orientation is landscape
|
||||||
|
if (orientation.isLandscape()) {
|
||||||
|
contentSize = Size(contentSize.height, contentSize.width)
|
||||||
|
}
|
||||||
val contentAspectRatio = contentSize.width.toDouble() / contentSize.height
|
val contentAspectRatio = contentSize.width.toDouble() / contentSize.height
|
||||||
val containerAspectRatio = containerSize.width.toDouble() / containerSize.height
|
val containerAspectRatio = containerSize.width.toDouble() / containerSize.height
|
||||||
if (!(contentAspectRatio > 0 && containerAspectRatio > 0)) {
|
if (!(contentAspectRatio > 0 && containerAspectRatio > 0)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user