srctree

Robin Lindén parent de169aa6 11c02bbd
Display contacts' last seen time

inlinesplit
app/src/main/java/ltd/evilcorp/atox/ContactAdapter.kt added: 34, removed: 17, total 17
@@ -31,6 +31,7 @@ class ContactAdapter(private val context: Context, private val contacts: ArrayLi
 
vh.name.text = contacts[position].name
vh.toxId.text = contacts[position].toxId
vh.lastSeen.text = contacts[position].lastSeen
 
return view!!
}
@@ -38,5 +39,6 @@ class ContactAdapter(private val context: Context, private val contacts: ArrayLi
private class ViewHolder(row: View) {
val name: TextView = row.findViewById(R.id.name) as TextView
val toxId: TextView = row.findViewById(R.id.toxId) as TextView
val lastSeen: TextView = row.findViewById(R.id.lastSeen) as TextView
}
}
 
app/src/main/java/ltd/evilcorp/atox/ContactListActivity.kt added: 34, removed: 17, total 17
@@ -17,13 +17,22 @@ class ContactListActivity : AppCompatActivity() {
contacts.add(
ContactModel(
"EchoBot",
"76518406F6A9F2217E8DC487CC783C25CC16A15EB36FF32E335A235342C48A39218F515C39A6"
"76518406F6A9F2217E8DC487CC783C25CC16A15EB36FF32E335A235342C48A39218F515C39A6",
"18:30"
)
)
contacts.add(
ContactModel(
"Also EchoBot",
"76518406F6A9F2217E8DC487CC783C25CC16A15EB36FF32E335A235342C48A39218F515C39A6"
"76518406F6A9F2217E8DC487CC783C25CC16A15EB36FF32E335A235342C48A39218F515C39A6",
"Dec 31"
)
)
contacts.add(
ContactModel(
"EchoBot 3: Reckoning",
"76518406F6A9F2217E8DC487CC783C25CC16A15EB36FF32E335A235342C48A39218F515C39A6",
"23.09.17"
)
)
listView.adapter = ContactAdapter(this, contacts)
 
app/src/main/java/ltd/evilcorp/atox/ContactModel.kt added: 34, removed: 17, total 17
@@ -1,3 +1,3 @@
package ltd.evilcorp.atox
 
class ContactModel(var name: String, val toxId: String)
class ContactModel(var name: String, val toxId: String, var lastSeen: String)
 
app/src/main/res/layout/contact_list_view_item.xml added: 34, removed: 17, total 17
@@ -2,26 +2,32 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:orientation="vertical"
android:padding="10dp"
android:onClick="openChat">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginStart="10dp"
android:onClick="openChat">
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:gravity="start"
android:layout_weight=".7"
android:textStyle="bold"/>
<TextView
android:id="@+id/toxId"
android:id="@+id/lastSeen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"/>
android:gravity="end"
android:layout_weight=".3"/>
</LinearLayout>
<TextView
android:id="@+id/toxId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"/>
</LinearLayout>