| | |
| | | package com.zxing.qrcode;///*
|
| | |
|
| | | import android.app.Activity;
|
| | | import android.content.Context;
|
| | | import android.content.Intent;
|
| | | import android.database.Cursor;
|
| | | import android.graphics.Rect;
|
| | |
| | | import android.view.animation.Animation;
|
| | | import android.view.animation.TranslateAnimation;
|
| | | import android.widget.ImageView;
|
| | | import android.widget.LinearLayout;
|
| | | import android.widget.RelativeLayout;
|
| | | import android.widget.TextView;
|
| | | import android.widget.Toast;
|
| | |
|
| | | import androidx.appcompat.content.res.AppCompatResources;
|
| | |
|
| | | import com.google.zxing.BinaryBitmap;
|
| | | import com.google.zxing.ChecksumException;
|
| | |
| | | private SurfaceView scanPreview = null;
|
| | | private RelativeLayout scanContainer;
|
| | | private RelativeLayout scanCropView;
|
| | | private LinearLayout backll;
|
| | | private ImageView light_iv;
|
| | | private TextView tvCancel;
|
| | | private Rect mCropRect = null;
|
| | | private boolean isHasSurface = false;
|
| | |
|
| | |
|
| | | @Override
|
| | | public Handler getHandler() {
|
| | |
| | | View mContentView = LayoutInflater.from(this).inflate(getRootLayoutId(), null);
|
| | | setContentView(mContentView);
|
| | | afterViewBind(mContentView, savedInstanceState);
|
| | |
|
| | |
|
| | | }
|
| | |
|
| | | public void afterViewBind(View rootView, Bundle savedInstanceState) {
|
| | |
|
| | | light_iv = findViewById(R.id.light_iv);
|
| | | backll = findViewById(R.id.top_back_ll);
|
| | | backll.setOnClickListener(new View.OnClickListener() {
|
| | | tvCancel = findViewById(R.id.tv_text_cancel);
|
| | | tvCancel.setOnClickListener(new View.OnClickListener() {
|
| | | @Override
|
| | | public void onClick(View v) {
|
| | | finish();
|
| | | // enterGallery();
|
| | | }
|
| | | });
|
| | | scanPreview = findViewById(R.id.capture_preview);
|
| | |
| | | animation.setRepeatCount(-1);
|
| | | animation.setRepeatMode(Animation.RESTART);
|
| | | scanLine.startAnimation(animation);
|
| | | light_iv.setOnClickListener(new View.OnClickListener() {
|
| | | @Override
|
| | | public void onClick(View v) {
|
| | | v.setSelected(!v.isSelected());
|
| | | if (v.isSelected()) {
|
| | | // cameraManager.open();
|
| | | light_iv.setImageDrawable(AppCompatResources.getDrawable(CaptureActivity.this, R.drawable.fast_scan_light_open));
|
| | | } else {
|
| | | // cameraManager.close();
|
| | | light_iv.setImageDrawable(AppCompatResources.getDrawable(CaptureActivity.this, R.drawable.fast_scan_light_close));
|
| | | }
|
| | |
|
| | | }
|
| | | });
|
| | |
|
| | | }
|
| | |
|
| | | public void enterGallery() {
|
| | | // 进入图库
|
| | | Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
| | | intent.addCategory(Intent.CATEGORY_OPENABLE);
|
| | | intent.setType("image/*");
|
| | | intent.putExtra("return-data", true);
|
| | | startActivityForResult(intent, REQUEST_CODE);
|
| | | Intent pickIntent = new Intent(Intent.ACTION_PICK,
|
| | | MediaStore.Images.Media.EXTERNAL_CONTENT_URI);//启动系统相册
|
| | | pickIntent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
|
| | | startActivityForResult(pickIntent, REQUEST_CODE);
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | intent.putExtra("data", result);
|
| | | setResult(RESULT_OK, intent);
|
| | | finish();
|
| | |
|
| | |
|
| | |
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | if (!TextUtils.isEmpty(path)) {
|
| | | handleQRCodeFormPhoto(path);
|
| | | } else {
|
| | | Toast.makeText(this, "图片已损坏,请重新选择!", Toast.LENGTH_SHORT).show();
|
| | | // Toast.makeText(this, R.string.pic_error, Toast.LENGTH_SHORT).show();
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | |
|
| | | } |