ContactInfo.java revision 034a2b329e469bf6888fbbcf91992f974015c2a8
1/* 2 * Copyright (C) 2011 The Android Open Source Project 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 17package com.android.dialer.calllog; 18 19import android.net.Uri; 20import android.text.TextUtils; 21 22import com.android.contacts.common.util.UriUtils; 23 24/** 25 * Information for a contact as needed by the Call Log. 26 */ 27public final class ContactInfo { 28 public Uri lookupUri; 29 public String name; 30 public int type; 31 public String label; 32 public String number; 33 public String formattedNumber; 34 public String normalizedNumber; 35 /** The photo for the contact, if available. */ 36 public long photoId; 37 /** The high-res photo for the contact, if available. */ 38 public Uri photoUri; 39 40 public static ContactInfo EMPTY = new ContactInfo(); 41 42 public static String GEOCODE_AS_LABEL = ""; 43 44 @Override 45 public int hashCode() { 46 // Uses only name and contactUri to determine hashcode. 47 // This should be sufficient to have a reasonable distribution of hash codes. 48 // Moreover, there should be no two people with the same lookupUri. 49 final int prime = 31; 50 int result = 1; 51 result = prime * result + ((lookupUri == null) ? 0 : lookupUri.hashCode()); 52 result = prime * result + ((name == null) ? 0 : name.hashCode()); 53 return result; 54 } 55 56 @Override 57 public boolean equals(Object obj) { 58 if (this == obj) return true; 59 if (obj == null) return false; 60 if (getClass() != obj.getClass()) return false; 61 ContactInfo other = (ContactInfo) obj; 62 if (!UriUtils.areEqual(lookupUri, other.lookupUri)) return false; 63 if (!TextUtils.equals(name, other.name)) return false; 64 if (type != other.type) return false; 65 if (!TextUtils.equals(label, other.label)) return false; 66 if (!TextUtils.equals(number, other.number)) return false; 67 if (!TextUtils.equals(formattedNumber, other.formattedNumber)) return false; 68 if (!TextUtils.equals(normalizedNumber, other.normalizedNumber)) return false; 69 if (photoId != other.photoId) return false; 70 if (!UriUtils.areEqual(photoUri, other.photoUri)) return false; 71 return true; 72 } 73} 74