@@ -94,7 +94,7 @@ public class CameraView extends FrameLayout {
94
94
public @interface Flash {
95
95
}
96
96
97
- protected Handler hand = new Handler (Looper .getMainLooper ());
97
+ protected Handler mainHand = new Handler (Looper .getMainLooper ());
98
98
99
99
CameraViewImpl mImpl ;
100
100
@@ -185,46 +185,46 @@ protected void onDetachedFromWindow() {
185
185
186
186
RectF r = new RectF ();
187
187
188
-
189
188
@ Override
190
189
protected void onMeasure (int widthMeasureSpec , int heightMeasureSpec ) {
191
- if (isInEditMode ()) {
192
- super .onMeasure (widthMeasureSpec , heightMeasureSpec );
193
- return ;
194
- }
190
+ // if (isInEditMode()) {
191
+ // super.onMeasure(widthMeasureSpec, heightMeasureSpec);
192
+ // return;
193
+ // }
195
194
// Handle android:adjustViewBounds
196
- if (mAdjustViewBounds ) {
197
- if (!isCameraOpened ()) {
198
- mCallbacks .reserveRequestLayoutOnOpen ();
199
- super .onMeasure (widthMeasureSpec , heightMeasureSpec );
200
- return ;
201
- }
202
- final int widthMode = MeasureSpec .getMode (widthMeasureSpec );
203
- final int heightMode = MeasureSpec .getMode (heightMeasureSpec );
204
- if (widthMode == MeasureSpec .EXACTLY && heightMode != MeasureSpec .EXACTLY ) {
205
- final AspectRatio ratio = getAspectRatio ();
206
- assert ratio != null ;
207
- int height = (int ) (MeasureSpec .getSize (widthMeasureSpec ) * ratio .toFloat ());
208
- if (heightMode == MeasureSpec .AT_MOST ) {
209
- height = Math .min (height , MeasureSpec .getSize (heightMeasureSpec ));
210
- }
211
- super .onMeasure (widthMeasureSpec ,
212
- MeasureSpec .makeMeasureSpec (height , MeasureSpec .EXACTLY ));
213
- } else if (widthMode != MeasureSpec .EXACTLY && heightMode == MeasureSpec .EXACTLY ) {
214
- final AspectRatio ratio = getAspectRatio ();
215
- assert ratio != null ;
216
- int width = (int ) (MeasureSpec .getSize (heightMeasureSpec ) * ratio .toFloat ());
217
- if (widthMode == MeasureSpec .AT_MOST ) {
218
- width = Math .min (width , MeasureSpec .getSize (widthMeasureSpec ));
219
- }
220
- super .onMeasure (MeasureSpec .makeMeasureSpec (width , MeasureSpec .EXACTLY ),
221
- heightMeasureSpec );
222
- } else {
223
- super .onMeasure (widthMeasureSpec , heightMeasureSpec );
224
- }
225
- } else {
226
- super .onMeasure (widthMeasureSpec , heightMeasureSpec );
227
- }
195
+ // if (mAdjustViewBounds) {
196
+ // if (!isCameraOpened()) {
197
+ // mCallbacks.reserveRequestLayoutOnOpen();
198
+ // super.onMeasure(widthMeasureSpec, heightMeasureSpec);
199
+ // return;
200
+ // }
201
+ // final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
202
+ // final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
203
+ // if (widthMode == MeasureSpec.EXACTLY && heightMode != MeasureSpec.EXACTLY) {
204
+ // final AspectRatio ratio = getAspectRatio();
205
+ // assert ratio != null;
206
+ // int height = (int) (MeasureSpec.getSize(widthMeasureSpec) * ratio.toFloat());
207
+ // if (heightMode == MeasureSpec.AT_MOST) {
208
+ // height = Math.min(height, MeasureSpec.getSize(heightMeasureSpec));
209
+ // }
210
+ // super.onMeasure(widthMeasureSpec,
211
+ // MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
212
+ // } else if (widthMode != MeasureSpec.EXACTLY && heightMode == MeasureSpec.EXACTLY) {
213
+ // final AspectRatio ratio = getAspectRatio();
214
+ // assert ratio != null;
215
+ // int width = (int) (MeasureSpec.getSize(heightMeasureSpec) * ratio.toFloat());
216
+ // if (widthMode == MeasureSpec.AT_MOST) {
217
+ // width = Math.min(width, MeasureSpec.getSize(widthMeasureSpec));
218
+ // }
219
+ // super.onMeasure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
220
+ // heightMeasureSpec);
221
+ // } else {
222
+ // super.onMeasure(widthMeasureSpec, heightMeasureSpec);
223
+ // }
224
+ // } else {
225
+ // super.onMeasure(widthMeasureSpec, heightMeasureSpec);
226
+ // }
227
+ super .onMeasure (widthMeasureSpec , heightMeasureSpec );
228
228
// Measure the TextureView
229
229
int width = getMeasuredWidth ();
230
230
int height = getMeasuredHeight ();
@@ -415,7 +415,7 @@ public Set<AspectRatio> getSupportedAspectRatios() {
415
415
*/
416
416
public void setAspectRatio (@ NonNull AspectRatio ratio ) {
417
417
if (mImpl .setAspectRatio (ratio )) {
418
- hand .post (this ::requestLayout );
418
+ mainHand .post (this ::requestLayout );
419
419
}
420
420
}
421
421
0 commit comments