From 5ca35cdd35721c2c87611edfa1fc2416dc6879d9 Mon Sep 17 00:00:00 2001 From: android-dataticket Date: Fri, 10 Mar 2017 10:03:01 -0800 Subject: [PATCH 1/2] Update PreviewImpl.java --- .../com/flurgle/camerakit/PreviewImpl.java | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/camerakit/src/main/base/com/flurgle/camerakit/PreviewImpl.java b/camerakit/src/main/base/com/flurgle/camerakit/PreviewImpl.java index 789f04b6..f594555f 100644 --- a/camerakit/src/main/base/com/flurgle/camerakit/PreviewImpl.java +++ b/camerakit/src/main/base/com/flurgle/camerakit/PreviewImpl.java @@ -61,28 +61,32 @@ abstract class PreviewImpl { return mHeight; } - void setTruePreviewSize(int width, int height) { + void setTruePreviewSize(final int width, final int height) { this.mTrueWidth = width; this.mTrueHeight = height; - - if (width != 0 && height != 0) { - AspectRatio aspectRatio = AspectRatio.of(width, height); - int targetHeight = (int) (getView().getWidth() * aspectRatio.toFloat()); - float scaleY; - if (getView().getHeight() > 0) { - scaleY = (float) targetHeight / (float) getView().getHeight(); - } else { - scaleY = 1; - } - - if (scaleY > 1) { - getView().setScaleX(1); - getView().setScaleY(scaleY); - } else { - getView().setScaleX(1 / scaleY); - getView().setScaleY(1); + ((Activity) getView().getContext()).runOnUiThread(new Runnable() { + @Override + public void run() { + if (width != 0 && height != 0) { + AspectRatio aspectRatio = AspectRatio.of(width, height); + int targetHeight = (int) (getView().getWidth() * aspectRatio.toFloat()); + float scaleY; + if (getView().getHeight() > 0) { + scaleY = (float) targetHeight / (float) getView().getHeight(); + } else { + scaleY = 1; + } + + if (scaleY > 1) { + getView().setScaleX(1); + getView().setScaleY(scaleY); + } else { + getView().setScaleX(1 / scaleY); + getView().setScaleY(1); + } + } } - } + }); } int getTrueWidth() { From b9533ba2896a63d6a06216e0c8b50f14874530da Mon Sep 17 00:00:00 2001 From: android-dataticket Date: Fri, 10 Mar 2017 10:22:03 -0800 Subject: [PATCH 2/2] Update PreviewImpl.java --- camerakit/src/main/base/com/flurgle/camerakit/PreviewImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/camerakit/src/main/base/com/flurgle/camerakit/PreviewImpl.java b/camerakit/src/main/base/com/flurgle/camerakit/PreviewImpl.java index f594555f..6afcb182 100644 --- a/camerakit/src/main/base/com/flurgle/camerakit/PreviewImpl.java +++ b/camerakit/src/main/base/com/flurgle/camerakit/PreviewImpl.java @@ -64,7 +64,7 @@ abstract class PreviewImpl { void setTruePreviewSize(final int width, final int height) { this.mTrueWidth = width; this.mTrueHeight = height; - ((Activity) getView().getContext()).runOnUiThread(new Runnable() { + getView().post(new Runnable() { @Override public void run() { if (width != 0 && height != 0) {