Add null check

This commit is contained in:
misaochan 2016-07-26 15:54:09 +12:00
parent a6b39b728a
commit a026a49017

View file

@ -135,14 +135,17 @@ public class UploadController {
}
String mimeType = (String)contribution.getTag("mimeType");
Boolean imagePrefix = false;
if(mimeType == null || TextUtils.isEmpty(mimeType) || mimeType.endsWith("*")) {
mimeType = activity.getContentResolver().getType(contribution.getLocalUri());
if(mimeType != null) {
contribution.setTag("mimeType", mimeType);
imagePrefix = mimeType.startsWith("image/");
}
}
if(mimeType.startsWith("image/") && contribution.getDateCreated() == null) {
if(imagePrefix && contribution.getDateCreated() == null) {
Cursor cursor = activity.getContentResolver().query(contribution.getLocalUri(),
new String[]{MediaStore.Images.ImageColumns.DATE_TAKEN}, null, null, null);
if(cursor != null && cursor.getCount() != 0) {
@ -159,7 +162,6 @@ public class UploadController {
contribution.setDateCreated(new Date());
}
}
return contribution;
}