mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Merge pull request #208 from misaochan/uploadcontroller-exception
Add check for NPE at UploadController
This commit is contained in:
commit
a785187942
1 changed files with 9 additions and 5 deletions
|
|
@ -135,14 +135,19 @@ 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) {
|
|
||||||
contribution.setTag("mimeType", mimeType);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mimeType.startsWith("image/") && contribution.getDateCreated() == null) {
|
if(mimeType != null) {
|
||||||
|
contribution.setTag("mimeType", mimeType);
|
||||||
|
imagePrefix = mimeType.startsWith("image/");
|
||||||
|
Log.d("UploadController", "MimeType is: " + mimeType);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 +164,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