我想检查是否在imageview
中选择了图像是否已经使用了
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode==REQUEST_PICK_IMAGE && resultCode==RESULT_OK){
path = data.getStringExtra(Constants.path);
isImageSet=true;
File imgFile=new File(path);
path =imgFile.getPath();
Glide.clear(ivIdProof);
bitmap = BitmapFactory.decodeFile(path);
bitmap= ImageHandling.loadBitmapFromFile(this, path,400,400);
ivIdProof.setImageBitmap(bitmap);
}
super.onActivityResult(requestCode, resultCode, data);
}
非常棒的验证码
awesomeValidation.addValidation(this, R.id.etIdentity, "^[A-Za-z\\s]{1,}[\\.]{0,1}[A-Za-z\\s]{0,}$", R.string.error_id1);
awesomeValidation.addValidation(this, R.id.etIdentityNumber, "^[A-Za-z0-9\\s]{1,}[\\.]{0,1}[A-Za-z0-9\\s]{0,}$", R.string.error_id2);
并检查
if(awesomeValidation.validate() && path!=null){
.....
}
awesomeValidation.validate()
用于验证其他字段。
如何使用awesome验证检查path!=null
并显示错误消息
答案 0 :(得分:0)
试试这个:
'file' => 'required|max:5128'; // max file size: 5M
答案 1 :(得分:0)
您可以尝试以下操作:
rstrip()
现在来自您的代码:
private boolean isImagePathValid(String path) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds =true;
Bitmap bitmap = BitmapFactory.decodeFile(path, options);
if(options.outWidth !=-1&&options.outHeight !=-1)
{
return true;
}
else
{
return false;
}
}
..... }