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