Search in sources :

Example 1 with Adapter

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);
}
Also used : Adapter(androidx.recyclerview.widget.RecyclerView.Adapter)

Example 2 with Adapter

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);
    }
}
Also used : Adapter(androidx.recyclerview.widget.RecyclerView.Adapter)

Example 3 with Adapter

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();
        }
    }
}
Also used : Adapter(androidx.recyclerview.widget.RecyclerView.Adapter)

Aggregations

Adapter (androidx.recyclerview.widget.RecyclerView.Adapter)3