feat(Friends): Accessors

parent a36505eb
package fr.plnech.dunbar
import android.graphics.Bitmap
import android.provider.ContactsContract
import android.provider.ContactsContract.Contacts
data class Friend(val map: MutableMap<String, String?>, 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
......@@ -30,21 +30,37 @@
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:focusable="false"
android:focusableInTouchMode="false"
android:layout_marginEnd="15dp"
android:gravity="end"
android:maxLines="3"
android:maxLines="2"
android:textAppearance="@style/TextAppearance.AppCompat.Title"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="@id/metadata"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toRightOf="@id/pic"
app:layout_constraintRight_toLeftOf="@id/name"
app:layout_constraintTop_toTopOf="parent"
tools:text="@tools:sample/full_names" />
<TextView
android:id="@+id/metadata"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:layout_marginEnd="15dp"
android:focusable="false"
android:focusableInTouchMode="false"
android:gravity="end"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toRightOf="@id/pic"
app:layout_constraintRight_toLeftOf="@id/name"
app:layout_constraintTop_toBottomOf="@id/name"
tools:text="@tools:sample/full_names" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment