Skip to content

Commit

Permalink
update meter scanning
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerhard committed Sep 24, 2020
1 parent 46fae9f commit 75c2e2f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion example/RNExampleApp/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ allprojects {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven { url 'https://anylinesdk.blob.core.windows.net/testing/' }
maven { url 'https://anylinesdk.blob.core.windows.net/maven/' }
google()
jcenter()
flatDir {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.os.Handler;


import com.google.firebase.ml.vision.barcode.FirebaseVisionBarcode;

Expand Down Expand Up @@ -64,11 +66,14 @@ public class Anyline4Activity extends AnylineBaseActivity {
private RadioGroup radioGroup;
private AnylineUIConfig anylineUIConfig;
private String cropAndTransformError;
private Boolean isFirstCameraOpen; // only if camera is opened the first time get coordinates of the cutout to avoid flickering when switching between analog and digital

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

isFirstCameraOpen=true;

// init the scan view
anylineScanView = new ScanView(this, null);

Expand Down Expand Up @@ -474,17 +479,22 @@ public void onCameraOpened(CameraController cameraController, int width, int hei
@Override
public void run() {
if (radioGroup != null) {
//orig: Rect rect = anylineScanView.getScanViewPlugin().getCutoutImageOnSurface(); // =cutoutRect.rectOnVisibleView
Rect rect = ((MeterScanViewPlugin) scanViewPlugin).getCutoutRect().rectOnVisibleView;

RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) radioGroup.getLayoutParams();
// lp.setMargins(50 + anylineUIConfig.getOffsetX(), anylineUIConfig.getOffsetY(), 0,
// 0);
orig: lp.setMargins(rect.left + anylineUIConfig.getOffsetX(), rect.top + anylineUIConfig.getOffsetY(), 0,
0);
radioGroup.setLayoutParams(lp);
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
if (isFirstCameraOpen) {
isFirstCameraOpen=false;
Rect rect = ((MeterScanViewPlugin) scanViewPlugin).getCutoutRect().rectOnVisibleView;

RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) radioGroup.getLayoutParams();
lp.setMargins(rect.left + anylineUIConfig.getOffsetX(), rect.top + anylineUIConfig.getOffsetY(), 0, 0);
radioGroup.setLayoutParams(lp);

radioGroup.setVisibility(View.VISIBLE);
}
}
}, 600);

radioGroup.setVisibility(View.VISIBLE);
}
}
});
Expand Down Expand Up @@ -540,6 +550,7 @@ public void onCheckedChanged(RadioGroup group, int checkedId) {
View button = group.findViewById(checkedId);
String mode = modes.get(group.indexOfChild(button));
((MeterScanViewPlugin) scanViewPlugin).setScanMode(MeterScanMode.valueOf(mode));
anylineScanView.releaseCameraInBackground();
anylineScanView.stop();
try {
Thread.sleep(100);
Expand Down

0 comments on commit 75c2e2f

Please sign in to comment.