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 17 package com.android.contacts.calllog; 18 19 import com.android.contacts.util.UriUtils; 20 21 import android.net.Uri; 22 import android.text.TextUtils; 23 24 /** 25 * Information for a contact as needed by the Call Log. 26 */ 27 public 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 @Override 43 public int hashCode() { 44 // Uses only name and contactUri to determine hashcode. 45 // This should be sufficient to have a reasonable distribution of hash codes. 46 // Moreover, there should be no two people with the same lookupUri. 47 final int prime = 31; 48 int result = 1; 49 result = prime * result + ((lookupUri == null) ? 0 : lookupUri.hashCode()); 50 result = prime * result + ((name == null) ? 0 : name.hashCode()); 51 return result; 52 } 53 54 @Override 55 public boolean equals(Object obj) { 56 if (this == obj) return true; 57 if (obj == null) return false; 58 if (getClass() != obj.getClass()) return false; 59 ContactInfo other = (ContactInfo) obj; 60 if (!UriUtils.areEqual(lookupUri, other.lookupUri)) return false; 61 if (!TextUtils.equals(name, other.name)) return false; 62 if (type != other.type) return false; 63 if (!TextUtils.equals(label, other.label)) return false; 64 if (!TextUtils.equals(number, other.number)) return false; 65 if (!TextUtils.equals(formattedNumber, other.formattedNumber)) return false; 66 if (!TextUtils.equals(normalizedNumber, other.normalizedNumber)) return false; 67 if (photoId != other.photoId) return false; 68 if (!UriUtils.areEqual(photoUri, other.photoUri)) return false; 69 return true; 70 } 71 } 72