OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 package org.chromium.chrome.browser.photo_picker; | |
6 | |
7 /** | |
8 * A class to keep track of the meta data associated with a an image in the | |
Ted C
2017/04/06 23:52:15
wrap javadoc lines to 100
Finnur
2017/04/07 13:52:21
Done.
| |
9 * photo picker. | |
10 */ | |
11 public class PickerBitmap implements Comparable<PickerBitmap> { | |
12 // The possible types of tiles involved in the viewer. | |
13 public enum TileTypes { PICTURE, CAMERA, GALLERY } | |
Ted C
2017/04/06 23:52:15
We typically try to avoid using enums in java land
Finnur
2017/04/07 13:52:20
Done.
| |
14 | |
15 // The file path to the bitmap to show. | |
16 private String mFilePath; | |
17 | |
18 // When the bitmap was last modified on disk. | |
19 private long mLastModified; | |
20 | |
21 // The type of tile involved. | |
22 private TileTypes mType; | |
23 | |
24 /** | |
25 * The PickerBitmap constructor. | |
26 * @param filePath The file path to the bitmap to show. | |
27 * @param lastModified When the bitmap was last modified on disk. | |
28 * @param type The type of tile involved. | |
29 */ | |
30 public PickerBitmap(String filePath, long lastModified, TileTypes type) { | |
31 mFilePath = filePath; | |
32 mLastModified = lastModified; | |
33 mType = type; | |
34 } | |
35 | |
36 /** | |
37 * Accessor for the filepath. | |
38 * @return The file path for this PickerBitmap object. | |
39 */ | |
40 public String getFilePath() { | |
41 return mFilePath; | |
42 } | |
43 | |
44 /** | |
45 * Accessor for the tile type. | |
46 * @return The type of tile involved for this bitmap object. | |
47 */ | |
48 public TileTypes type() { | |
49 return mType; | |
50 } | |
51 | |
52 /** | |
53 * A comparison function for PickerBitmaps (results in a last-modified first sort). | |
54 * @param other The PickerBitmap to compare it to. | |
55 * @return 0, 1, or -1, depending on which is bigger. | |
56 */ | |
57 @Override | |
58 public int compareTo(PickerBitmap other) { | |
59 if (mLastModified < other.mLastModified) { | |
Ted C
2017/04/06 23:52:15
could this be:
return ApiCompatibilityUtils.compa
Finnur
2017/04/07 13:52:20
Done.
| |
60 return 1; | |
61 } else if (mLastModified > other.mLastModified) { | |
62 return -1; | |
63 } | |
64 return 0; | |
65 } | |
66 | |
67 @Override | |
68 public final int hashCode() { | |
69 return (mFilePath + mLastModified).hashCode(); | |
70 } | |
71 | |
72 @Override | |
73 public boolean equals(Object other) { | |
Ted C
2017/04/06 23:52:15
Hmm...this seems a bit weird to me. Why do you ne
Finnur
2017/04/07 13:52:20
I think I don't need this equals. These objects wi
| |
74 if (other == this) { | |
75 return true; | |
76 } | |
77 if (other instanceof PickerBitmap) { | |
78 return compareTo((PickerBitmap) other) == 0; | |
79 } | |
80 return false; | |
81 } | |
82 } | |
OLD | NEW |