Merge pull request #194 from michaelschattgen/feature-empty-dataset

Add placeholder for empty recyclerview
This commit is contained in:
Alexander Bakker 2019-09-07 11:55:49 +02:00 committed by GitHub
commit e2150e3823
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 1 deletions

View file

@ -8,7 +8,7 @@ import android.view.View;
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;
@ -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;
@ -107,6 +108,8 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
}
});
_emptyStateView = view.findViewById(R.id.vEmptyList);
return view;
}
@ -218,14 +221,17 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
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() {
@ -267,6 +273,16 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
_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);