Skip to content

Commit 8df0cb5

Browse files
authored
Merge pull request #527 from yands11/master
Apply space convention after 'if'
2 parents 09d992d + 7e5bbd2 commit 8df0cb5

17 files changed

+57
-57
lines changed

zxing-android-embedded/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ project.afterEvaluate {
9797
// To release, place bintray_user and bintray_key properties in ~/.gradle/gradle.properties,
9898
// and run ./gradlew clean assembleRelease bintrayUpload
9999

100-
if(project.hasProperty('bintray_user') && project.hasProperty('bintray_key')) {
100+
if (project.hasProperty('bintray_user') && project.hasProperty('bintray_key')) {
101101
bintray {
102102
user = bintray_user
103103
key = bintray_key

zxing-android-embedded/src/com/journeyapps/barcodescanner/CameraPreview.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public boolean handleMessage(Message message) {
209209
pause();
210210
fireState.cameraError(error);
211211
}
212-
} else if(message.what == R.id.zxing_camera_closed) {
212+
} else if (message.what == R.id.zxing_camera_closed) {
213213
fireState.cameraClosed();
214214
}
215215
return false;
@@ -280,11 +280,11 @@ protected void initializeAttributes(AttributeSet attrs) {
280280

281281
// See zxing_attrs.xml for the enum values
282282
int scalingStrategyNumber = styledAttributes.getInteger(R.styleable.zxing_camera_preview_zxing_preview_scaling_strategy, -1);
283-
if(scalingStrategyNumber == 1) {
283+
if (scalingStrategyNumber == 1) {
284284
previewScalingStrategy = new CenterCropStrategy();
285-
} else if(scalingStrategyNumber == 2) {
285+
} else if (scalingStrategyNumber == 2) {
286286
previewScalingStrategy = new FitCenterStrategy();
287-
} else if(scalingStrategyNumber == 3) {
287+
} else if (scalingStrategyNumber == 3) {
288288
previewScalingStrategy = new FitXYStrategy();
289289
}
290290

@@ -293,14 +293,14 @@ protected void initializeAttributes(AttributeSet attrs) {
293293

294294
private void rotationChanged() {
295295
// Confirm that it did actually change
296-
if(isActive() && getDisplayRotation() != openedOrientation) {
296+
if (isActive() && getDisplayRotation() != openedOrientation) {
297297
pause();
298298
resume();
299299
}
300300
}
301301

302302
private void setupSurfaceView() {
303-
if(useTextureView) {
303+
if (useTextureView) {
304304
textureView = new TextureView(getContext());
305305
textureView.setSurfaceTextureListener(surfaceTextureListener());
306306
addView(textureView);
@@ -431,7 +431,7 @@ private void containerSized(Size containerSize) {
431431
displayConfiguration.setPreviewScalingStrategy(getPreviewScalingStrategy());
432432
cameraInstance.setDisplayConfiguration(displayConfiguration);
433433
cameraInstance.configureCamera();
434-
if(torchOn) {
434+
if (torchOn) {
435435
cameraInstance.setTorch(torchOn);
436436
}
437437
}
@@ -451,14 +451,14 @@ public void setPreviewScalingStrategy(PreviewScalingStrategy previewScalingStrat
451451
* Override this to specify a different preview scaling strategy.
452452
*/
453453
public PreviewScalingStrategy getPreviewScalingStrategy() {
454-
if(previewScalingStrategy != null) {
454+
if (previewScalingStrategy != null) {
455455
return previewScalingStrategy;
456456
}
457457

458458
// If we are using SurfaceTexture, it is safe to use centerCrop.
459459
// For SurfaceView, it's better to use fitCenter, otherwise the preview may overlap to
460460
// other views.
461-
if(textureView != null) {
461+
if (textureView != null) {
462462
return new CenterCropStrategy();
463463
} else {
464464
return new FitCenterStrategy();
@@ -521,8 +521,8 @@ private void startPreviewIfReady() {
521521
if (currentSurfaceSize != null && previewSize != null && surfaceRect != null) {
522522
if (surfaceView != null && currentSurfaceSize.equals(new Size(surfaceRect.width(), surfaceRect.height()))) {
523523
startCameraPreview(new CameraSurface(surfaceView.getHolder()));
524-
} else if(textureView != null && textureView.getSurfaceTexture() != null) {
525-
if(previewSize != null) {
524+
} else if (textureView != null && textureView.getSurfaceTexture() != null) {
525+
if (previewSize != null) {
526526
Matrix transform = calculateTextureTransform(new Size(textureView.getWidth(), textureView.getHeight()), previewSize);
527527
textureView.setTransform(transform);
528528
}
@@ -539,15 +539,15 @@ private void startPreviewIfReady() {
539539
protected void onLayout(boolean changed, int l, int t, int r, int b) {
540540
containerSized(new Size(r - l, b - t));
541541

542-
if(surfaceView != null) {
542+
if (surfaceView != null) {
543543
if (surfaceRect == null) {
544544
// Match the container, to reduce the risk of issues. The preview should never be drawn
545545
// while the surface has this size.
546546
surfaceView.layout(0, 0, getWidth(), getHeight());
547547
} else {
548548
surfaceView.layout(surfaceRect.left, surfaceRect.top, surfaceRect.right, surfaceRect.bottom);
549549
}
550-
} else if(textureView != null) {
550+
} else if (textureView != null) {
551551
textureView.layout(0, 0, getWidth(), getHeight());
552552
}
553553
}
@@ -617,11 +617,11 @@ public void resume() {
617617
// The activity was paused but not stopped, so the surface still exists. Therefore
618618
// surfaceCreated() won't be called, so init the camera here.
619619
startPreviewIfReady();
620-
} else if(surfaceView != null) {
620+
} else if (surfaceView != null) {
621621
// Install the callback and wait for surfaceCreated() to init the camera.
622622
surfaceView.getHolder().addCallback(surfaceCallback);
623-
} else if(textureView != null) {
624-
if(textureView.isAvailable()) {
623+
} else if (textureView != null) {
624+
if (textureView.isAvailable()) {
625625
surfaceTextureListener().onSurfaceTextureAvailable(textureView.getSurfaceTexture(), textureView.getWidth(), textureView.getHeight());
626626
} else {
627627
textureView.setSurfaceTextureListener(surfaceTextureListener());
@@ -656,7 +656,7 @@ public void pause() {
656656
SurfaceHolder surfaceHolder = surfaceView.getHolder();
657657
surfaceHolder.removeCallback(surfaceCallback);
658658
}
659-
if(currentSurfaceSize == null && textureView != null) {
659+
if (currentSurfaceSize == null && textureView != null) {
660660
textureView.setSurfaceTextureListener(null);
661661
}
662662

@@ -678,7 +678,7 @@ public void pauseAndWait() {
678678
pause();
679679
long startTime = System.nanoTime();
680680
while(instance != null && !instance.isCameraClosed()) {
681-
if(System.nanoTime() - startTime > 2000000000) {
681+
if (System.nanoTime() - startTime > 2000000000) {
682682
// Don't wait for longer than 2 seconds
683683
break;
684684
}
@@ -714,7 +714,7 @@ public double getMarginFraction() {
714714
* @param marginFraction the fraction
715715
*/
716716
public void setMarginFraction(double marginFraction) {
717-
if(marginFraction >= 0.5d) {
717+
if (marginFraction >= 0.5d) {
718718
throw new IllegalArgumentException("The margin fraction must be less than 0.5");
719719
}
720720
this.marginFraction = marginFraction;
@@ -835,7 +835,7 @@ protected Rect calculateFramingRect(Rect container, Rect surface) {
835835
Rect intersection = new Rect(container);
836836
boolean intersects = intersection.intersect(surface);
837837

838-
if(framingRectSize != null) {
838+
if (framingRectSize != null) {
839839
// Specific size is specified. Make sure it's not larger than the container or surface.
840840
int horizontalMargin = Math.max(0, (intersection.width() - framingRectSize.width) / 2);
841841
int verticalMargin = Math.max(0, (intersection.height() - framingRectSize.height) / 2);
@@ -864,7 +864,7 @@ protected Parcelable onSaveInstanceState() {
864864

865865
@Override
866866
protected void onRestoreInstanceState(Parcelable state) {
867-
if(!(state instanceof Bundle)) {
867+
if (!(state instanceof Bundle)) {
868868
super.onRestoreInstanceState(state);
869869
return;
870870
}

zxing-android-embedded/src/com/journeyapps/barcodescanner/CaptureManager.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void cameraError(Exception error) {
108108

109109
@Override
110110
public void cameraClosed() {
111-
if(finishWhenClosed) {
111+
if (finishWhenClosed) {
112112
Log.d(TAG, "Camera closed; finishing activity");
113113
finish();
114114
}
@@ -147,7 +147,7 @@ public void initializeFromIntent(Intent intent, Bundle savedInstanceState) {
147147
this.orientationLock = savedInstanceState.getInt(SAVED_ORIENTATION_LOCK, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
148148
}
149149

150-
if(intent != null) {
150+
if (intent != null) {
151151
// Only lock the orientation if it's not locked to something else yet
152152
boolean orientationLocked = intent.getBooleanExtra(Intents.Scan.ORIENTATION_LOCKED, true);
153153
if (orientationLocked) {
@@ -214,7 +214,7 @@ public void decode() {
214214
* Call from Activity#onResume().
215215
*/
216216
public void onResume() {
217-
if(Build.VERSION.SDK_INT >= 23) {
217+
if (Build.VERSION.SDK_INT >= 23) {
218218
openCameraWithPermission();
219219
} else {
220220
barcodeView.resume();
@@ -229,7 +229,7 @@ private void openCameraWithPermission() {
229229
if (ContextCompat.checkSelfPermission(this.activity, Manifest.permission.CAMERA)
230230
== PackageManager.PERMISSION_GRANTED) {
231231
barcodeView.resume();
232-
} else if(!askedPermission) {
232+
} else if (!askedPermission) {
233233
ActivityCompat.requestPermissions(this.activity,
234234
new String[]{Manifest.permission.CAMERA},
235235
cameraPermissionReqCode);
@@ -248,7 +248,7 @@ private void openCameraWithPermission() {
248248
* or {@link android.content.pm.PackageManager#PERMISSION_DENIED}. Never null.
249249
*/
250250
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
251-
if(requestCode == cameraPermissionReqCode) {
251+
if (requestCode == cameraPermissionReqCode) {
252252
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
253253
// permission was granted
254254
barcodeView.resume();
@@ -359,7 +359,7 @@ private void finish() {
359359
}
360360

361361
protected void closeAndFinish() {
362-
if(barcodeView.getBarcodeView().isCameraClosed()) {
362+
if (barcodeView.getBarcodeView().isCameraClosed()) {
363363
finish();
364364
} else {
365365
finishWhenClosed = true;

zxing-android-embedded/src/com/journeyapps/barcodescanner/DecoderResultPointCallback.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void setDecoder(Decoder decoder) {
2626

2727
@Override
2828
public void foundPossibleResultPoint(ResultPoint point) {
29-
if(decoder != null) {
29+
if (decoder != null) {
3030
decoder.foundPossibleResultPoint(point);
3131
}
3232
}

zxing-android-embedded/src/com/journeyapps/barcodescanner/DecoderThread.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class DecoderThread {
3636
public boolean handleMessage(Message message) {
3737
if (message.what == R.id.zxing_decode) {
3838
decode((SourceData) message.obj);
39-
} else if(message.what == R.id.zxing_preview_failed) {
39+
} else if (message.what == R.id.zxing_preview_failed) {
4040
// Error already logged. Try again.
4141
requestNextPreview();
4242
}
@@ -142,7 +142,7 @@ private void decode(SourceData sourceData) {
142142
sourceData.setCropRect(cropRect);
143143
LuminanceSource source = createSource(sourceData);
144144

145-
if(source != null) {
145+
if (source != null) {
146146
rawResult = decoder.decode(source);
147147
}
148148

zxing-android-embedded/src/com/journeyapps/barcodescanner/DecoratedBarcodeView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public void initializeFromIntent(Intent intent) {
143143
}
144144

145145
if (intent.hasExtra(Intents.Scan.TORCH_ENABLED)) {
146-
if(intent.getBooleanExtra(Intents.Scan.TORCH_ENABLED, false)) {
146+
if (intent.getBooleanExtra(Intents.Scan.TORCH_ENABLED, false)) {
147147
this.setTorchOn();
148148
}
149149
}
@@ -183,7 +183,7 @@ public CameraSettings getCameraSettings() {
183183

184184
public void setStatusText(String text) {
185185
// statusView is optional when using a custom layout
186-
if(statusView != null) {
186+
if (statusView != null) {
187187
statusView.setText(text);
188188
}
189189
}

zxing-android-embedded/src/com/journeyapps/barcodescanner/DefaultDecoderFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ public Decoder createDecoder(Map<DecodeHintType, ?> baseHints) {
3939

4040
hints.putAll(baseHints);
4141

42-
if(this.hints != null) {
42+
if (this.hints != null) {
4343
hints.putAll(this.hints);
4444
}
4545

46-
if(this.decodeFormats != null) {
46+
if (this.decodeFormats != null) {
4747
hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);
4848
}
4949

zxing-android-embedded/src/com/journeyapps/barcodescanner/RotationListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void listen(Context context, RotationCallback callback) {
4040
public void onOrientationChanged(int orientation) {
4141
WindowManager localWindowManager = windowManager;
4242
RotationCallback localCallback = RotationListener.this.callback;
43-
if(windowManager != null && localCallback != null) {
43+
if (windowManager != null && localCallback != null) {
4444
int newRotation = localWindowManager.getDefaultDisplay().getRotation();
4545
if (newRotation != lastRotation) {
4646
lastRotation = newRotation;
@@ -57,7 +57,7 @@ public void onOrientationChanged(int orientation) {
5757
public void stop() {
5858
// To reduce the effect of possible leaks, we clear any references we have to external
5959
// objects.
60-
if(this.orientationEventListener != null) {
60+
if (this.orientationEventListener != null) {
6161
this.orientationEventListener.disable();
6262
}
6363
this.orientationEventListener = null;

zxing-android-embedded/src/com/journeyapps/barcodescanner/Size.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public Size scale(int n, int d) {
4343
* @return the scaled size
4444
*/
4545
public Size scaleFit(Size into) {
46-
if(width * into.height >= into.width * height) {
46+
if (width * into.height >= into.width * height) {
4747
// match width
4848
return new Size(into.width, height * into.width / width);
4949
} else {
@@ -59,7 +59,7 @@ public Size scaleFit(Size into) {
5959
* @return the scaled size
6060
*/
6161
public Size scaleCrop(Size into) {
62-
if(width * into.height <= into.width * height) {
62+
if (width * into.height <= into.width * height) {
6363
// match width
6464
return new Size(into.width, height * into.width / width);
6565
} else {

zxing-android-embedded/src/com/journeyapps/barcodescanner/SourceData.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public SourceData(byte[] data, int dataWidth, int dataHeight, int imageFormat, i
4545
this.data = new RawImageData(data, dataWidth, dataHeight);
4646
this.rotation = rotation;
4747
this.imageFormat = imageFormat;
48-
if(dataWidth * dataHeight > data.length) {
48+
if (dataWidth * dataHeight > data.length) {
4949
throw new IllegalArgumentException("Image data does not match the resolution. " + dataWidth + "x" + dataHeight + " > " + data.length);
5050
}
5151
}
@@ -150,7 +150,7 @@ public Bitmap getBitmap(int scaleFactor) {
150150
public Bitmap getBitmap(Rect cropRect, int scaleFactor) {
151151
if (cropRect == null) {
152152
cropRect = new Rect(0, 0, data.getWidth(), data.getHeight());
153-
} else if(isRotated()) {
153+
} else if (isRotated()) {
154154
//noinspection SuspiciousNameCombination
155155
cropRect = new Rect(cropRect.top, cropRect.left, cropRect.bottom, cropRect.right);
156156
}

0 commit comments

Comments
 (0)