fix(android): replace assertion with a null check (#2194)

some android cleanup
This commit is contained in:
Daniil Ovoshchnikov 2019-04-07 19:33:09 +02:00 committed by Sibelius Seraphini
parent b6a85d9f72
commit 47469e7305
7 changed files with 22 additions and 21 deletions

View File

@ -481,19 +481,19 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.3.1'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion safeExtGet('compileSdkVersion', 26)
buildToolsVersion safeExtGet('buildToolsVersion', '26.0.2')
compileSdkVersion safeExtGet('compileSdkVersion', 28)
buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3')
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 16)
targetSdkVersion safeExtGet('targetSdkVersion', 26)
targetSdkVersion safeExtGet('targetSdkVersion', 28)
}
flavorDimensions "react-native-camera"
@ -527,7 +527,7 @@ android {
repositories {
google()
mavenCentral()
jcenter()
maven {
url 'https://maven.google.com'
}
@ -539,16 +539,17 @@ repositories {
}
dependencies {
compileOnly 'com.facebook.react:react-native:+'
compileOnly 'com.facebook.infer.annotation:infer-annotation:+'
implementation "com.google.zxing:core:3.3.0"
implementation "com.drewnoakes:metadata-extractor:2.9.1"
generalImplementation "com.google.android.gms:play-services-vision:${safeExtGet('google-services', '17.0.2')}"
implementation "com.android.support:exifinterface:${safeExtGet('supportLibVersion', '27.1.0')}"
implementation "com.android.support:support-annotations:${safeExtGet('supportLibVersion', '27.1.0')}"
implementation "com.android.support:support-v4:${safeExtGet('supportLibVersion', '27.1.0')}"
mlkitImplementation "com.google.firebase:firebase-ml-vision:${safeExtGet('firebase-ml-vision', '18.0.2')}"
mlkitImplementation "com.google.firebase:firebase-ml-vision-face-model:17.0.2"
def googlePlayServicesVisionVersion = safeExtGet('googlePlayServicesVisionVersion', safeExtGet('googlePlayServicesVersion', '17.0.2'))
implementation 'com.facebook.react:react-native:+'
implementation "com.google.zxing:core:3.3.3"
implementation "com.drewnoakes:metadata-extractor:2.11.0"
generalImplementation "com.google.android.gms:play-services-vision:$googlePlayServicesVisionVersion"
implementation "com.android.support:exifinterface:${safeExtGet('supportLibVersion', '28.0.0')}"
implementation "com.android.support:support-annotations:${safeExtGet('supportLibVersion', '28.0.0')}"
implementation "com.android.support:support-v4:${safeExtGet('supportLibVersion', '28.0.0')}"
mlkitImplementation "com.google.firebase:firebase-ml-vision:${safeExtGet('firebase-ml-vision', '19.0.3')}"
mlkitImplementation "com.google.firebase:firebase-ml-vision-face-model:${safeExtGet('firebase-ml-vision-face-model', '17.0.2')}"
}
```

View File

@ -73,7 +73,6 @@ dependencies {
def googlePlayServicesVisionVersion = safeExtGet('googlePlayServicesVisionVersion', safeExtGet('googlePlayServicesVersion', '17.0.2'))
implementation 'com.facebook.react:react-native:+'
implementation 'com.facebook.infer.annotation:infer-annotation:+'
implementation "com.google.zxing:core:3.3.3"
implementation "com.drewnoakes:metadata-extractor:2.11.0"
generalImplementation "com.google.android.gms:play-services-vision:$googlePlayServicesVisionVersion"

View File

@ -12,6 +12,7 @@ public class RNBarcodeDetector {
public static int NORMAL_MODE = 0;
public static int ALTERNATE_MODE = 1;
public static int INVERTED_MODE = 2;
public static int ALL_FORMATS = Barcode.ALL_FORMATS;
private BarcodeDetector mBarcodeDetector = null;
private ImageDimensions mPreviousDimensions;

View File

@ -2,7 +2,6 @@ package com.lwansbrough.RCTCamera;
import android.support.annotation.Nullable;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.common.MapBuilder;
import com.facebook.react.uimanager.*;
@ -39,7 +38,9 @@ public class RCTCameraViewManager extends ViewGroupManager<RCTCameraView> {
@Override
public void receiveCommand(RCTCameraView view, int commandType, @Nullable ReadableArray args) {
Assertions.assertNotNull(view);
if (view == null) {
throw new AssertionError();
}
switch (commandType) {
case COMMAND_STOP_PREVIEW: {
view.stopPreview();

View File

@ -13,7 +13,6 @@ import android.os.AsyncTask;
import com.facebook.react.bridge.*;
import com.facebook.react.uimanager.ThemedReactContext;
import com.google.android.cameraview.CameraView;
import com.google.android.gms.vision.barcode.Barcode;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.DecodeHintType;
import com.google.zxing.MultiFormatReader;
@ -62,7 +61,7 @@ public class RNCameraView extends CameraView implements LifecycleEventListener,
private int mFaceDetectorMode = RNFaceDetector.FAST_MODE;
private int mFaceDetectionLandmarks = RNFaceDetector.NO_LANDMARKS;
private int mFaceDetectionClassifications = RNFaceDetector.NO_CLASSIFICATIONS;
private int mGoogleVisionBarCodeType = Barcode.ALL_FORMATS;
private int mGoogleVisionBarCodeType = RNBarcodeDetector.ALL_FORMATS;
private int mGoogleVisionBarCodeMode = RNBarcodeDetector.NORMAL_MODE;
private int mPaddingX;
private int mPaddingY;

View File

@ -14,6 +14,7 @@ public class RNBarcodeDetector {
public static int NORMAL_MODE = 0;
public static int ALTERNATE_MODE = 1;
public static int INVERTED_MODE = 2;
public static int ALL_FORMATS = FirebaseVisionBarcode.FORMAT_ALL_FORMATS;
private FirebaseVisionBarcodeDetector mBarcodeDetector = null;
private FirebaseVisionBarcodeDetectorOptions.Builder mBuilder;

View File

@ -16,4 +16,3 @@ org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=1g -XX:+HeapDumpOnOutOfMemoryError -Df
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.enableAapt2=false