Show message when no search results are found.

Fixes #1117.
This commit is contained in:
Peter Serwylo 2017-08-08 11:35:23 +10:00
parent a71eb243fa
commit 0f8bec59e1
3 changed files with 39 additions and 8 deletions

View File

@ -34,6 +34,7 @@ public class AppListActivity extends AppCompatActivity implements LoaderManager.
private AppListAdapter appAdapter;
private String category;
private String searchTerms;
private TextView emptyState;
private EditText searchInput;
@Override
@ -61,6 +62,8 @@ public class AppListActivity extends AppCompatActivity implements LoaderManager.
}
});
emptyState = (TextView) findViewById(R.id.empty_state);
View backButton = findViewById(R.id.back);
backButton.setOnClickListener(new View.OnClickListener() {
@Override
@ -132,6 +135,13 @@ public class AppListActivity extends AppCompatActivity implements LoaderManager.
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
appAdapter.setAppCursor(cursor);
if (cursor.getCount() > 0) {
emptyState.setVisibility(View.GONE);
appView.setVisibility(View.VISIBLE);
} else {
emptyState.setVisibility(View.VISIBLE);
appView.setVisibility(View.GONE);
}
}
@Override

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.constraint.ConstraintLayout 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:orientation="vertical"
@ -7,9 +7,13 @@
android:layout_height="match_parent">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:id="@+id/search_card"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="12dp">
android:layout_margin="12dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
@ -59,14 +63,29 @@
</android.support.v7.widget.CardView>
<!-- Don't center, only show it at the top because a keyboard will usually be shown at the bottom of the screen,
covering most of this layout. -->
<TextView
android:id="@+id/empty_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/search_card"
android:visibility="gone"
style="@style/AppListEmptyText"
android:text="@string/empty_search_available_app_list"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/app_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_height="0dp"
tools:listitem="@layout/app_list_item"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/search_card"
android:visibility="visible"
android:scrollbars="vertical" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>

View File

@ -323,6 +323,8 @@
</string>
<string name="empty_can_update_app_list">Congratulations! Your apps are up to date.</string>
<string name="empty_search_available_app_list">No matching applications available.</string>
<string name="requesting_root_access_body">Requesting root access…</string>
<string name="root_access_denied_title">Root access denied</string>
<string name="root_access_denied_body">Either your Android device is not rooted or you have denied root access for