1
1
package com .bumptech .glide .signature ;
2
2
3
+ import android .support .annotation .NonNull ;
4
+ import android .support .annotation .Nullable ;
3
5
import com .bumptech .glide .load .Key ;
4
- import com .bumptech .glide .util .Util ;
5
6
import java .nio .ByteBuffer ;
6
7
import java .security .MessageDigest ;
7
8
10
11
* media store files like edits, rotations, and temporary file replacement.
11
12
*/
12
13
public class MediaStoreSignature implements Key {
13
- private final String mimeType ;
14
+ @ NonNull private final String mimeType ;
14
15
private final long dateModified ;
15
16
private final int orientation ;
16
17
@@ -26,8 +27,8 @@ public class MediaStoreSignature implements Key {
26
27
* @param orientation The orientation of the media store media. Ok to default to 0. See {@link
27
28
* android.provider.MediaStore.Images.ImageColumns#ORIENTATION}.
28
29
*/
29
- public MediaStoreSignature (String mimeType , long dateModified , int orientation ) {
30
- this .mimeType = mimeType ;
30
+ public MediaStoreSignature (@ Nullable String mimeType , long dateModified , int orientation ) {
31
+ this .mimeType = mimeType == null ? "" : mimeType ;
31
32
this .dateModified = dateModified ;
32
33
this .orientation = orientation ;
33
34
}
@@ -50,22 +51,22 @@ public boolean equals(Object o) {
50
51
if (orientation != that .orientation ) {
51
52
return false ;
52
53
}
53
- if (!Util . bothNullOrEqual ( mimeType , that .mimeType )) {
54
+ if (!mimeType . equals ( that .mimeType )) {
54
55
return false ;
55
56
}
56
57
return true ;
57
58
}
58
59
59
60
@ Override
60
61
public int hashCode () {
61
- int result = mimeType != null ? mimeType .hashCode () : 0 ;
62
+ int result = mimeType .hashCode ();
62
63
result = 31 * result + (int ) (dateModified ^ (dateModified >>> 32 ));
63
64
result = 31 * result + orientation ;
64
65
return result ;
65
66
}
66
67
67
68
@ Override
68
- public void updateDiskCacheKey (MessageDigest messageDigest ) {
69
+ public void updateDiskCacheKey (@ NonNull MessageDigest messageDigest ) {
69
70
byte [] data = ByteBuffer .allocate (12 ).putLong (dateModified ).putInt (orientation ).array ();
70
71
messageDigest .update (data );
71
72
messageDigest .update (mimeType .getBytes (CHARSET ));
0 commit comments