Skip to content

Commit

Permalink
fix NPE caused by null mime type
Browse files Browse the repository at this point in the history
  • Loading branch information
gejiaheng committed Nov 23, 2017
1 parent 2cd432e commit 4ee4547
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public boolean isCapture() {
}

public boolean isImage() {
if (mimeType == null) return false;
return mimeType.equals(MimeType.JPEG.toString())
|| mimeType.equals(MimeType.PNG.toString())
|| mimeType.equals(MimeType.GIF.toString())
Expand All @@ -110,10 +111,12 @@ public boolean isImage() {
}

public boolean isGif() {
if (mimeType == null) return false;
return mimeType.equals(MimeType.GIF.toString());
}

public boolean isVideo() {
if (mimeType == null) return false;
return mimeType.equals(MimeType.MPEG.toString())
|| mimeType.equals(MimeType.MP4.toString())
|| mimeType.equals(MimeType.QUICKTIME.toString())
Expand Down Expand Up @@ -145,7 +148,9 @@ public boolean equals(Object obj) {
public int hashCode() {
int result = 1;
result = 31 * result + Long.valueOf(id).hashCode();
result = 31 * result + mimeType.hashCode();
if (mimeType != null) {
result = 31 * result + mimeType.hashCode();
}
result = 31 * result + uri.hashCode();
result = 31 * result + Long.valueOf(size).hashCode();
result = 31 * result + Long.valueOf(duration).hashCode();
Expand Down

0 comments on commit 4ee4547

Please sign in to comment.