Skip to content

Commit

Permalink
Merge pull request #194 from michaelschattgen/feature-empty-dataset
Browse files Browse the repository at this point in the history
Add placeholder for empty recyclerview
  • Loading branch information
alexbakker authored Sep 7, 2019
2 parents 95df2ce + 6480fef commit e2150e3
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import android.view.animation.LayoutAnimationController;
import android.widget.Toast;
import android.widget.LinearLayout;

import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.SortCategory;
Expand Down Expand Up @@ -47,6 +47,7 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
private PeriodProgressBar _progressBar;
private boolean _showProgress;
private ViewMode _viewMode;
private LinearLayout _emptyStateView;

private UiRefresher _refresher;

Expand Down Expand Up @@ -107,6 +108,8 @@ public long getMillisTillNextRefresh() {
}
});

_emptyStateView = view.findViewById(R.id.vEmptyList);

return view;
}

Expand Down Expand Up @@ -218,14 +221,17 @@ public void setTapToRevealTime(int number) {

public void addEntry(DatabaseEntry entry) {
_adapter.addEntry(entry);
updateEmptyState();
}

public void addEntries(List<DatabaseEntry> entries) {
_adapter.addEntries(entries);
updateEmptyState();
}

public void removeEntry(DatabaseEntry entry) {
_adapter.removeEntry(entry);
updateEmptyState();
}

public void clearEntries() {
Expand Down Expand Up @@ -267,6 +273,16 @@ private void updateDividerDecoration() {
_recyclerView.addItemDecoration(_dividerDecoration);
}

private void updateEmptyState() {
if (_adapter.getItemCount() > 0) {
_recyclerView.setVisibility(View.VISIBLE);
_emptyStateView.setVisibility(View.GONE);
} else {
_recyclerView.setVisibility(View.GONE);
_emptyStateView.setVisibility(View.VISIBLE);
}
}

public interface Listener {
void onEntryClick(DatabaseEntry entry);
void onEntryMove(DatabaseEntry entry1, DatabaseEntry entry2);
Expand Down
43 changes: 43 additions & 0 deletions app/src/main/res/layout/fragment_entry_list_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,47 @@
android:id="@+id/rvKeyProfiles"
android:layoutAnimation="@anim/layout_animation_fall_down"
android:layout_weight="1"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center|fill_vertical"
android:id="@+id/vEmptyList"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="150dp">

<ImageView
android:id="@+id/imageView"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/ic_qrcode_scan"
android:tint="?attr/primaryText" />

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/empty_list_title"
android:paddingTop="17dp"
android:textColor="?attr/primaryText"
android:textSize="18sp" />

<TextView
android:id="@+id/textView5"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:lineSpacingExtra="5dp"
android:paddingTop="7dp"
android:text="@string/empty_list"
android:textAlignment="center" />
</LinearLayout>

</LinearLayout>
</LinearLayout>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,6 @@
<string name="channel_name_lock_status">Lock status</string>
<string name="channel_description_lock_status">Aegis can create a persistent notification to notify you when the vault is locked</string>
<string name="vault_unlocked_state">Vault is unlocked. Tap here to lock.</string>
<string name="empty_list">There are no codes to be shown. Start adding entries by tapping the plus sign in the bottom right corner</string>
<string name="empty_list_title">No entries found</string>
</resources>

0 comments on commit e2150e3

Please sign in to comment.