1 /*
2  * Copyright (C) 2014 Google Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.example.android.wearable.speedtracker.common;
18 
19 import java.util.Calendar;
20 
21 /**
22  * A class that models a GPS location point with additional information about the time that the data
23  * was obtained.
24  */
25 public class LocationEntry {
26 
27     public double latitude;
28     public double longitude;
29     public Calendar calendar;
30     public String day;
31 
LocationEntry(Calendar calendar, double latitude, double longitude)32     public LocationEntry(Calendar calendar, double latitude, double longitude) {
33         this.calendar = calendar;
34         this.latitude = latitude;
35         this.longitude = longitude;
36         this.day = Utils.getHashedDay(calendar);
37     }
38 
39     @Override
equals(Object o)40     public boolean equals(Object o) {
41         if (this == o) {
42             return true;
43         }
44         if (o == null || getClass() != o.getClass()) {
45             return false;
46         }
47 
48         LocationEntry that = (LocationEntry) o;
49 
50         if (calendar.getTimeInMillis() != that.calendar.getTimeInMillis()) {
51             return false;
52         }
53 
54         return true;
55     }
56 
57     @Override
hashCode()58     public int hashCode() {
59         return calendar.hashCode();
60     }
61 }