1/** 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import Contact from '../entity/Contact'; 17import { Contacts } from '../contract/Contacts'; 18import { RawContacts } from '../contract/RawContacts'; 19import ContactBuilder from '../entity/ContactBuilder'; 20 21export default class ContactListItem { 22 static readonly COLUMNS: string[] = [Contacts.ID, Contacts.QUICK_SEARCH_KEY, RawContacts.DISPLAY_NAME, 23 RawContacts.SORT_FIRST_LETTER, RawContacts.PHOTO_FIRST_NAME, Contacts.COMPANY, Contacts.POSITION, RawContacts.FAVORITE_ORDER]; 24 readonly id: number; 25 readonly displayName: string; 26 readonly sortFirstLetter: string; 27 readonly photoFirstName: string; 28 readonly quickSearchKey: string; 29 readonly company: string; 30 readonly position: string; 31 readonly favoriteOrder: string; 32 phoneNumbers: [] = []; 33 34 constructor(resultSet: any) { 35 this.id = resultSet.getLong(resultSet.getColumnIndex(Contacts.ID)); 36 this.displayName = resultSet.getString(resultSet.getColumnIndex(RawContacts.DISPLAY_NAME)); 37 this.sortFirstLetter = resultSet.getString(resultSet.getColumnIndex(RawContacts.SORT_FIRST_LETTER)); 38 this.photoFirstName = resultSet.getString(resultSet.getColumnIndex(RawContacts.PHOTO_FIRST_NAME)); 39 this.quickSearchKey = resultSet.getString(resultSet.getColumnIndex(Contacts.QUICK_SEARCH_KEY)); 40 this.company = resultSet.getString(resultSet.getColumnIndex(Contacts.COMPANY)); 41 this.position = resultSet.getString(resultSet.getColumnIndex(Contacts.POSITION)); 42 this.favoriteOrder = resultSet.getString(resultSet.getColumnIndex(RawContacts.FAVORITE_ORDER)); 43 } 44 45 createContact() { 46 return new Contact(new ContactBuilder(this.id)); 47 } 48}