use of androidx.recyclerview.widget.RecyclerView.Adapter in project briar by briar.
the class BriarRecyclerView method startPeriodicUpdate.
public void startPeriodicUpdate(long interval) {
if (recyclerView == null || recyclerView.getAdapter() == null) {
throw new IllegalStateException("Need to call setAdapter() first!");
}
refresher = () -> {
Adapter adapter = recyclerView.getAdapter();
adapter.notifyItemRangeChanged(0, adapter.getItemCount());
handler.postDelayed(refresher, interval);
};
handler.postDelayed(refresher, interval);
}
use of androidx.recyclerview.widget.RecyclerView.Adapter in project briar by briar.
the class BriarRecyclerView method showData.
public void showData() {
if (recyclerView == null)
initViews();
Adapter adapter = recyclerView.getAdapter();
if (adapter != null) {
if (adapter.getItemCount() == 0) {
emptyImage.setVisibility(VISIBLE);
emptyText.setVisibility(VISIBLE);
emptyAction.setVisibility(VISIBLE);
recyclerView.setVisibility(INVISIBLE);
} else {
emptyImage.setVisibility(INVISIBLE);
emptyText.setVisibility(INVISIBLE);
emptyAction.setVisibility(INVISIBLE);
recyclerView.setVisibility(VISIBLE);
}
progressBar.setVisibility(GONE);
}
}
use of androidx.recyclerview.widget.RecyclerView.Adapter in project briar by briar.
the class BriarRecyclerView method setAdapter.
public void setAdapter(Adapter adapter) {
if (recyclerView == null)
initViews();
Adapter oldAdapter = recyclerView.getAdapter();
if (oldAdapter != null) {
oldAdapter.unregisterAdapterDataObserver(emptyObserver);
}
recyclerView.setAdapter(adapter);
if (adapter != null) {
adapter.registerAdapterDataObserver(emptyObserver);
if (adapter.getItemCount() > 0) {
// only show data if adapter has data already
// otherwise progress bar is shown
emptyObserver.onChanged();
}
}
}
Aggregations