Create custom BriarRecyclerView and use it for the contact list.

It is a common pattern to have a list with an empty view and a progress bar.
This commit introduces a custom BriarRecyclerView and uses it for the
contact list.

No more manually hiding and showing empty views and progress bars is
necessary when using the new BriarRecyclerView instead of RecyclerView.

Please note that this conflicts with !44 at the moment and needs to be
implemented for !36 once merged.

Closes #198
This commit is contained in:
Torsten Grote
2015-12-29 14:23:15 -02:00
parent e17765e80f
commit f309cb36d4
5 changed files with 167 additions and 85 deletions

View File

@@ -1,54 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinatorLayout"
<org.briarproject.android.util.BriarRecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/contactList"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/contactList"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listitem="@layout/list_item_contact"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/addContactFAB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/margin_activity_horizontal"
android:src="@drawable/ic_add_white"
app:fabSize="normal"
app:elevation="4dp"
app:layout_anchor="@id/contactList"
app:layout_anchorGravity="bottom|right|end"
app:layout_behavior="org.briarproject.android.util.HideFabOnScrollBehavior"/>
</android.support.design.widget.CoordinatorLayout>
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleLarge"
<android.support.design.widget.FloatingActionButton
android:id="@+id/addContactFAB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"
android:visibility="gone"/>
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/margin_activity_horizontal"
android:src="@drawable/ic_add_white"
app:fabSize="normal"
app:elevation="4dp"
app:layout_anchor="@id/contactList"
app:layout_anchorGravity="bottom|right|end"
app:layout_behavior="org.briarproject.android.util.HideFabOnScrollBehavior"/>
<TextView
android:id="@+id/emptyView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/text_size_large"
android:text="@string/no_contacts"
android:visibility="gone"/>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
tools:listitem="@layout/list_item_contact"/>
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
<TextView
android:id="@+id/emptyView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textSize="@dimen/text_size_large"
android:text="@string/no_data"/>
</RelativeLayout>

View File

@@ -128,4 +128,5 @@
<string name="dialog_message_lost_password">Password recovery is not possible. Do you wish to delete your user, all contacts, and re-register ?</string>
<string name="dialog_title_delete_contact">Confirm Contact Deletion</string>
<string name="dialog_message_delete_contact">Are you sure that you want to remove this contact and all messages exchanged with this contact?</string>
<string name="no_data">No data</string>
</resources>