ui / winkit.android.ui / PaginatedRecyclerView / <init>
<init>
PaginatedRecyclerView(context:
Context
, attrs:
AttributeSet
? = null, defStyleAttr:
Int
= 0)
An helpful View that implement a RecyclerView with pullToRefresh and Loadmore feature. This recyclerView ask in a callback the pages and allow to implement the “no data” and “error” state.
paginatedRecycler.getPageListener = getPage@{ index: Int ->
getHttpData(index) { data -> // connection error on data == null
if (data != null) {
adapter.append(data)
paginatedRecycler.haveMore = data.size < TOTAL_SIZE
adapter.notifyDataSetChanged()
} else {
if(index == 0)
adapter.showError("Connection error on first page")
else {
paginatedRecycler.haveMore = false
Toast.makeText(this, "Connection error", Toast.LENGTH_SHORT).show()
}
}
}
}
paginatedRecycler.requestFirstPage()
Attr ref R.styleable#PaginatedRecyclerView