1 package com.android.gallery3d.ingest.data;
2 
3 import android.annotation.TargetApi;
4 import android.os.Build;
5 
6 /**
7  * Date bucket for {@link MtpDeviceIndex}.
8  * See {@link MtpDeviceIndexRunnable} for implementation notes.
9  */
10 @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
11 class DateBucket implements Comparable<DateBucket> {
12   final SimpleDate date;
13   final int unifiedStartIndex;
14   final int unifiedEndIndex;
15   final int itemsStartIndex;
16   final int numItems;
17 
DateBucket(SimpleDate date, int unifiedStartIndex, int unifiedEndIndex, int itemsStartIndex, int numItems)18   public DateBucket(SimpleDate date, int unifiedStartIndex, int unifiedEndIndex,
19       int itemsStartIndex, int numItems) {
20     this.date = date;
21     this.unifiedStartIndex = unifiedStartIndex;
22     this.unifiedEndIndex = unifiedEndIndex;
23     this.itemsStartIndex = itemsStartIndex;
24     this.numItems = numItems;
25   }
26 
27   @Override
toString()28   public String toString() {
29     return date.toString();
30   }
31 
32   @Override
hashCode()33   public int hashCode() {
34     return date.hashCode();
35   }
36 
37   @Override
equals(Object obj)38   public boolean equals(Object obj) {
39     if (this == obj) {
40       return true;
41     }
42     if (obj == null) {
43       return false;
44     }
45     if (!(obj instanceof DateBucket)) {
46       return false;
47     }
48     DateBucket other = (DateBucket) obj;
49     if (date == null) {
50       if (other.date != null) {
51         return false;
52       }
53     } else if (!date.equals(other.date)) {
54       return false;
55     }
56     return true;
57   }
58 
59   @Override
compareTo(DateBucket another)60   public int compareTo(DateBucket another) {
61     return this.date.compareTo(another.date);
62   }
63 }