mac
2024-06-25 7562541202056446945028026f1cbc64bb2407db
third-zxing/src/main/java/com/zxing/qrcode/CaptureActivity.java
@@ -1,6 +1,7 @@
package com.zxing.qrcode;///*
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Rect;
@@ -19,11 +20,9 @@
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;
@@ -60,10 +59,10 @@
    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() {
@@ -93,18 +92,15 @@
        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_btn);
        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);
@@ -121,30 +117,15 @@
        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
@@ -319,6 +300,9 @@
            intent.putExtra("data", result);
            setResult(RESULT_OK, intent);
            finish();
        }
    }
@@ -341,7 +325,7 @@
                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();
                }
            }
        }
@@ -393,6 +377,4 @@
            }
        });
    }
}