From 2e335df3f93d668e5cdc80099c0e95764a43dab3 Mon Sep 17 00:00:00 2001 From: Paul-Louis NECH Date: Sat, 2 Nov 2019 15:14:51 +0100 Subject: [PATCH] feat(Friends): Accessors --- app/src/main/java/fr/plnech/dunbar/Friend.kt | 20 ++++++++++---------- app/src/main/res/layout/contact.xml | 26 +++++++++++++++++++++----- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/fr/plnech/dunbar/Friend.kt b/app/src/main/java/fr/plnech/dunbar/Friend.kt index f6c6a28..35b547f 100644 --- a/app/src/main/java/fr/plnech/dunbar/Friend.kt +++ b/app/src/main/java/fr/plnech/dunbar/Friend.kt @@ -1,26 +1,26 @@ package fr.plnech.dunbar import android.graphics.Bitmap -import android.provider.ContactsContract +import android.provider.ContactsContract.Contacts data class Friend(val map: MutableMap, val photo: Bitmap?) { - override fun toString(): String = "$id: $name ($timesContacted times, last $lastTime)" + override fun toString(): String = "$name" val name: String? - get() = map[ContactsContract.Contacts.DISPLAY_NAME] + get() = map[Contacts.DISPLAY_NAME] - val id: String - get() = map[ContactsContract.Contacts._ID]!! + val id: Int + get() = map[Contacts._ID]!!.toInt() val lastTime: String? - get() = map[ContactsContract.Contacts.LAST_TIME_CONTACTED] + get() = map[Contacts.LAST_TIME_CONTACTED] - val timesContacted: String? - get() = map[ContactsContract.Contacts.TIMES_CONTACTED] + val timesContacted: Int + get() = map[Contacts.TIMES_CONTACTED]?.toInt() ?: 0 val isYou: String? - get() = map[ContactsContract.Contacts.IS_USER_PROFILE] + get() = map[Contacts.IS_USER_PROFILE] val visibleOutsideSearch: String? - get() = map[ContactsContract.Contacts.IN_DEFAULT_DIRECTORY] + get() = map[Contacts.IN_DEFAULT_DIRECTORY] } \ No newline at end of file diff --git a/app/src/main/res/layout/contact.xml b/app/src/main/res/layout/contact.xml index bf8fbe4..3a7ee55 100644 --- a/app/src/main/res/layout/contact.xml +++ b/app/src/main/res/layout/contact.xml @@ -30,21 +30,37 @@ + + -- libgit2 0.27.0