拍照bug修复添加弹框

This commit is contained in:
lijia 2024-01-17 10:39:01 +08:00
parent 2bdf0d45dc
commit edf3f494da

View File

@ -31,23 +31,23 @@ public class GetCarImageAlert {
PopupWindow popupWindow;
ImageView img;
public void showPopueWindow(AppCompatActivity act,boolean key){
View popView = View.inflate(act, R.layout.choice_car_timg,null);
Button btn_xiangce =popView.findViewById(R.id.btn_xiangce);
public void showPopueWindow(AppCompatActivity act, boolean key) {
View popView = View.inflate(act, R.layout.choice_car_timg, null);
Button btn_xiangce = popView.findViewById(R.id.btn_xiangce);
Button btn_paizhao = popView.findViewById(R.id.btn_paizhao);
Button btn_quxiao = popView.findViewById(R.id.btn_quxiao);
View v_1=popView.findViewById(R.id.v_1);
TextView tv_ts=popView.findViewById(R.id.tv_ts);
img=popView.findViewById(R.id.img);
Button btn_quxiao = popView.findViewById(R.id.btn_quxiao);
View v_1 = popView.findViewById(R.id.v_1);
TextView tv_ts = popView.findViewById(R.id.tv_ts);
img = popView.findViewById(R.id.img);
//获取屏幕宽高
int weight =act.getResources().getDisplayMetrics().widthPixels;
int height = act.getResources().getDisplayMetrics().heightPixels*2/3;
popupWindow = new PopupWindow(popView,weight,height);
int weight = act.getResources().getDisplayMetrics().widthPixels;
int height = act.getResources().getDisplayMetrics().heightPixels * 2 / 3;
popupWindow = new PopupWindow(popView, weight, height);
//popupWindow.setAnimationStyle(R.style.anim_popup_dir);
popupWindow.setFocusable(true);
//点击外部popueWindow消失
popupWindow.setOutsideTouchable(true);
if(key){
if (key) {
btn_xiangce.setVisibility(View.VISIBLE);
img.setImageResource(R.drawable.huidan);
tv_ts.setText("请按照如图所示拍摄回单照片,回单照片必须保持清晰完整,能看清具体吨数,便于结算运费时核查,感谢配合。");
@ -55,31 +55,41 @@ public class GetCarImageAlert {
//请按照如图所示拍摄回单照片回单照片必须保持清晰完整能看清具体吨数便于结算运费时核查感谢配合
}
btn_xiangce.setOnClickListener(v -> {
PermissionX.init(act)
.permissions(Manifest.permission.READ_EXTERNAL_STORAGE)
.request((allGranted, grantedList, deniedList) -> {
if (allGranted) {
PicturlUtil.selectPicter(act, new ArrayList<>(), 1);
} else {
Toast.makeText(act.getBaseContext(), "开启权限失败,请手动开启权限", Toast.LENGTH_LONG).show();
}
});
try {
PermissionX.init(act)
.permissions(Manifest.permission.READ_EXTERNAL_STORAGE)
.request((allGranted, grantedList, deniedList) -> {
if (allGranted) {
PicturlUtil.selectPicter(act, new ArrayList<>(), 1);
} else {
Toast.makeText(act.getBaseContext(), "开启权限失败,请手动开启权限", Toast.LENGTH_LONG).show();
}
});
} catch (Exception e) {
Toast.makeText(act.getBaseContext(), "程序出现问题了,请重新登录后重试!!!", Toast.LENGTH_LONG).show();
}
});
btn_paizhao.setOnClickListener(v -> {
PermissionX.init(act)
.permissions(Manifest.permission.CAMERA)
.request((allGranted, grantedList, deniedList) -> {
if (allGranted) {
openCam(act);
try{
PermissionX.init(act)
.permissions(Manifest.permission.CAMERA)
.request((allGranted, grantedList, deniedList) -> {
if (allGranted) {
openCam(act);
// file=ImageGetUtil.createImageFile(act);
// ImageGetUtil.cameraAlbumGetImage(act,file);
} else {
Toast.makeText(act.getBaseContext(), "开启权限失败,请手动开启权限", Toast.LENGTH_LONG).show();
}
});
} else {
Toast.makeText(act.getBaseContext(), "开启权限失败,请手动开启权限", Toast.LENGTH_LONG).show();
}
});
}catch (Exception e){
Toast.makeText(act.getBaseContext(), "程序出现问题了,请重新登录后重试!!!", Toast.LENGTH_LONG).show();
}
});
img.setOnClickListener(v -> {
if (!key){
if (!key) {
PermissionX.init(act)
.permissions(Manifest.permission.CAMERA)
.request((allGranted, grantedList, deniedList) -> {
@ -102,22 +112,22 @@ public class GetCarImageAlert {
WindowManager.LayoutParams lp = act.getWindow().getAttributes();
lp.alpha = 0.5f;
act.getWindow().setAttributes(lp);
popupWindow.showAtLocation(popView, Gravity.BOTTOM,0,50);
popupWindow.showAtLocation(popView, Gravity.BOTTOM, 0, 50);
}
public File getFile() {
return file;
}
public void dis(){
public void dis() {
popupWindow.dismiss();
}
private void openCam(AppCompatActivity act){
file=ImageGetUtil.createImageFile(act);
if (file!=null){
ImageGetUtil.cameraAlbumGetImage(act,file);
}else{
private void openCam(AppCompatActivity act) {
file = ImageGetUtil.createImageFile(act);
if (file != null) {
ImageGetUtil.cameraAlbumGetImage(act, file);
} else {
Toast.makeText(act.getBaseContext(), "路径创建失败,请清除缓存后重试", Toast.LENGTH_LONG).show();
}
}