|
@@ -4,9 +4,12 @@ package com.fxy.mine;
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
|
+import android.os.Vibrator;
|
|
import android.support.v7.widget.RecyclerView;
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
|
|
|
|
|
|
|
|
|
+import com.elvishew.xlog.XLog;
|
|
|
|
+import com.luck.picture.lib.PictureSelector;
|
|
import com.luck.picture.lib.config.PictureConfig;
|
|
import com.luck.picture.lib.config.PictureConfig;
|
|
import com.luck.picture.lib.entity.LocalMedia;
|
|
import com.luck.picture.lib.entity.LocalMedia;
|
|
import com.fxy.baselibrary.base.BaseActivity;
|
|
import com.fxy.baselibrary.base.BaseActivity;
|
|
@@ -16,12 +19,23 @@ import com.fxy.common.PictureSelectorUpload;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
+import cn.bingoogolapple.qrcode.core.BarcodeType;
|
|
|
|
+import cn.bingoogolapple.qrcode.core.QRCodeView;
|
|
|
|
+import cn.bingoogolapple.qrcode.zbar.BarcodeFormat;
|
|
|
|
+import cn.bingoogolapple.qrcode.zbar.ZBarView;
|
|
|
|
|
|
-public class PictureSelectorActivity extends BaseActivity {
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+public class PictureSelectorActivity extends BaseActivity implements QRCodeView.Delegate {
|
|
private Context mContext=this;
|
|
private Context mContext=this;
|
|
private List<LocalMedia> selectList = new ArrayList<>();
|
|
private List<LocalMedia> selectList = new ArrayList<>();
|
|
private RecyclerView mRecyclerView;
|
|
private RecyclerView mRecyclerView;
|
|
|
|
|
|
|
|
+ private static final String TAG = PictureSelectorActivity.class.getSimpleName();
|
|
|
|
+ private static final int REQUEST_CODE_CHOOSE_QRCODE_FROM_GALLERY = 666;
|
|
|
|
+
|
|
|
|
+ private ZBarView mZBarView;
|
|
|
|
+
|
|
private PictureSelectorUpload pictureSelectorUpload;
|
|
private PictureSelectorUpload pictureSelectorUpload;
|
|
|
|
|
|
|
|
|
|
@@ -45,6 +59,14 @@ public class PictureSelectorActivity extends BaseActivity {
|
|
mRecyclerView = findViewById(R.id.recycler);
|
|
mRecyclerView = findViewById(R.id.recycler);
|
|
|
|
|
|
pictureSelectorUpload = new PictureSelectorUpload(PictureSelectorActivity.this,mRecyclerView,"tally");
|
|
pictureSelectorUpload = new PictureSelectorUpload(PictureSelectorActivity.this,mRecyclerView,"tally");
|
|
|
|
+
|
|
|
|
+ mZBarView = findViewById(R.id.zbarview);
|
|
|
|
+ mZBarView.setDelegate(PictureSelectorActivity.this);
|
|
|
|
+
|
|
|
|
+ mZBarView.startCamera(); // 打开后置摄像头开始预览,但是并未开始识别
|
|
|
|
+// mZBarView.startCamera(Camera.CameraInfo.CAMERA_FACING_FRONT); // 打开前置摄像头开始预览,但是并未开始识别
|
|
|
|
+
|
|
|
|
+// mZBarView.startSpotAndShowRect(); // 显示扫描框,并开始识别
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -63,8 +85,36 @@ public class PictureSelectorActivity extends BaseActivity {
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
if (resultCode == RESULT_OK) {
|
|
if (resultCode == RESULT_OK) {
|
|
if (requestCode == PictureConfig.CHOOSE_REQUEST) {// 图片选择结果回调
|
|
if (requestCode == PictureConfig.CHOOSE_REQUEST) {// 图片选择结果回调
|
|
- pictureSelectorUpload.getSelectImg(data);
|
|
|
|
|
|
+ //pictureSelectorUpload.getSelectImg(data);
|
|
|
|
+ try {
|
|
|
|
+ mZBarView.startSpot();
|
|
|
|
+ List<LocalMedia> images = PictureSelector.obtainMultipleResult(data);
|
|
|
|
+ final String picturePath = images.get(0).getPath();
|
|
|
|
+ mZBarView.decodeQRCode(picturePath);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ XLog.e(e.getMessage());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onScanQRCodeSuccess(String result) {
|
|
|
|
+ XLog.i(TAG, "result:" + result);
|
|
|
|
+ XLog.e("扫描结果为:" + result);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onCameraAmbientBrightnessChanged(boolean isDark) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onScanQRCodeOpenCameraError() {
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|