mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Add null check
This commit is contained in:
parent
a6b39b728a
commit
a026a49017
1 changed files with 4 additions and 2 deletions
|
|
@ -135,14 +135,17 @@ public class UploadController {
|
||||||
}
|
}
|
||||||
|
|
||||||
String mimeType = (String)contribution.getTag("mimeType");
|
String mimeType = (String)contribution.getTag("mimeType");
|
||||||
|
Boolean imagePrefix = false;
|
||||||
|
|
||||||
if(mimeType == null || TextUtils.isEmpty(mimeType) || mimeType.endsWith("*")) {
|
if(mimeType == null || TextUtils.isEmpty(mimeType) || mimeType.endsWith("*")) {
|
||||||
mimeType = activity.getContentResolver().getType(contribution.getLocalUri());
|
mimeType = activity.getContentResolver().getType(contribution.getLocalUri());
|
||||||
if(mimeType != null) {
|
if(mimeType != null) {
|
||||||
contribution.setTag("mimeType", mimeType);
|
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(),
|
Cursor cursor = activity.getContentResolver().query(contribution.getLocalUri(),
|
||||||
new String[]{MediaStore.Images.ImageColumns.DATE_TAKEN}, null, null, null);
|
new String[]{MediaStore.Images.ImageColumns.DATE_TAKEN}, null, null, null);
|
||||||
if(cursor != null && cursor.getCount() != 0) {
|
if(cursor != null && cursor.getCount() != 0) {
|
||||||
|
|
@ -159,7 +162,6 @@ public class UploadController {
|
||||||
contribution.setDateCreated(new Date());
|
contribution.setDateCreated(new Date());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return contribution;
|
return contribution;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue