From 44ba605a4e850efa757020da5fb4cf02bdf6e3ab Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期一, 08 九月 2025 10:55:18 +0800
Subject: [PATCH] 2025年09月08日10:55:15
---
app/src/main/java/com/hdl/photovoltaic/ui/device/ScanActivity.java | 48 ++++++++++++++++++++++++++++++++++--------------
1 files changed, 34 insertions(+), 14 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/device/ScanActivity.java b/app/src/main/java/com/hdl/photovoltaic/ui/device/ScanActivity.java
index 61fe5f6..463ca7d 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/device/ScanActivity.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/device/ScanActivity.java
@@ -1,5 +1,6 @@
package com.hdl.photovoltaic.ui.device;
+import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
@@ -46,6 +47,7 @@
import com.hdl.photovoltaic.other.HdlCommonLogic;
import com.hdl.photovoltaic.uni.HDLUniMP;
import com.hdl.photovoltaic.utils.LocalManageUtil;
+import com.hdl.photovoltaic.utils.PermissionUtils;
import com.jaeger.library.StatusBarUtil;
import com.zxing.IZxingActivity;
import com.zxing.camera.CameraManager;
@@ -122,7 +124,9 @@
//璁剧疆鏍硅鍥�
View mContentView = LayoutInflater.from(this).inflate(getRootLayoutId(), null);
setContentView(mContentView);
+
afterViewBind(mContentView, savedInstanceState);
+
}
@@ -197,7 +201,9 @@
}
inactivityTimer.onPause();
beepManager.close();
- cameraManager.closeDriver();
+ if (cameraManager != null) {
+ cameraManager.closeDriver();
+ }
if (!isHasSurface) {
scanPreview.getHolder().removeCallback(this);
}
@@ -247,6 +253,15 @@
}
private void initCamera(SurfaceHolder surfaceHolder) {
+// PermissionUtils.requestPermissionsResultCallback(this, Manifest.permission.CAMERA, new PermissionUtils.PermissionState() {
+// @Override
+// public void Success(int value) {
+// if (value == PermissionUtils.STATUS_REFUSE_PERMANENT | value == PermissionUtils.STATUS_REFUSE) {
+//// HdlThreadLogic.toast(_mActivity, R.string.permission_open);
+// Toast.makeText(ScanActivity.this, R.string.capture_no_camera, Toast.LENGTH_SHORT).show();
+// return;
+// }
+
if (surfaceHolder == null) {
throw new IllegalStateException("No SurfaceHolder provided");
}
@@ -259,19 +274,20 @@
// Creating the handler starts the preview, which can also throw a
// RuntimeException.
if (handler == null) {
- handler = new CaptureActivityHandler(this, cameraManager, DecodeThread.ALL_MODE);
+ handler = new CaptureActivityHandler(ScanActivity.this, cameraManager, DecodeThread.ALL_MODE);
}
-
initCrop();
} catch (IOException ioe) {
Log.w(TAG, ioe);
- Toast.makeText(this, R.string.capture_no_camera, Toast.LENGTH_SHORT).show();
+ Toast.makeText(ScanActivity.this, R.string.capture_no_camera, Toast.LENGTH_SHORT).show();
finish();
} catch (RuntimeException e) {
Log.w(TAG, "Unexpected error initializing camera", e);
- Toast.makeText(this, R.string.capture_no_camera, Toast.LENGTH_SHORT).show();
+ Toast.makeText(ScanActivity.this, R.string.capture_no_camera, Toast.LENGTH_SHORT).show();
finish();
}
+// }
+// }, true);
}
public void restartPreviewAfterDelay(long delayMS) {
@@ -342,15 +358,19 @@
if (TextUtils.isEmpty(result)) {
Toast.makeText(this, R.string.capture_no_result, Toast.LENGTH_SHORT).show();
} else {
- Intent intent = new Intent();
- intent.putExtra("data", result);
- setResult(RESULT_OK, intent);
- finish();
- //EventBus浜嬩欢鍒嗗彂
- HdlCommonLogic.getInstance().postEventBusSticky(
- HDLUniMP.UNI_EVENT_REPLY_HOME_ADD,
- HDLUniMP.UNI_EVENT_REPLY_HOME_ADD,
- result);
+ if (result.startsWith("https://") || result.startsWith("http://")) {
+ Intent intent = new Intent();
+ intent.putExtra("data", result);
+ setResult(RESULT_OK, intent);
+ finish();
+ //EventBus浜嬩欢鍒嗗彂
+ HdlCommonLogic.getInstance().postEventBusSticky(
+ HDLUniMP.UNI_EVENT_REPLY_HOME_ADD,
+ HDLUniMP.UNI_EVENT_REPLY_HOME_ADD,
+ result);
+ } else {
+ Toast.makeText(this, R.string.not_delivery_qr_code, Toast.LENGTH_SHORT).show();
+ }
}
}
--
Gitblit v1.8.0