Class PagedLiveData<T>
java.lang.Object
androidx.lifecycle.LiveData<T>
androidx.lifecycle.MutableLiveData<T>
com.abubusoft.kripton.androidx.livedata.KriptonXLiveData<T>
com.abubusoft.kripton.androidx.livedata.PagedLiveData<T>
- Type Parameters:
T- the generic type
- All Implemented Interfaces:
PagedResult,PageNavigator,PageRequest
public abstract class PagedLiveData<T> extends KriptonXLiveData<T> implements PagedResult
The paged version of KriptonLiveData.
- Author:
- Francesco Benincasa (info@abubusoft.com)
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classPagedLiveData.PageRequestBuilderThis builder allows you to manipulate page request object, changing some its attributes and invoke an unique update to live date. -
Constructor Summary
Constructors Constructor Description PagedLiveData(Paginator<T> pageRequest, KriptonXPagedLiveDataHandlerImpl<T> handler) -
Method Summary
Modifier and Type Method Description PagedLiveData.PageRequestBuildercreatePageRequestBuilder()Allows to create a builder for a page request.voidfirstPage()Navigate to the first page.PageRequestExecutor<T>getExecutor()intgetOffset()Set the current offset from start of dataset.intgetPageNumber()Current pageintgetPageSize()Page size used to navigateintgetTotalElements()Returns the total amount of elements.intgetTotalPages()Returns the number of total pages.booleanhasNext()booleanhasPrevious()booleanisFirst()booleanisLast()voidlastPage()Navigate to last pagevoidnextPage()Navigates to next page.voidpreviousPage()Navigates to previous page.voidsetOffset(int offset)Navigates to the offset.voidsetPage(int page)Navigates to the page.voidsetPageSize(int pageSize)Set page sizeMethods inherited from class androidx.lifecycle.LiveData
getValue, hasActiveObservers, hasObservers, observe, observeForever, onActive, onInactive, removeObserver, removeObservers
-
Constructor Details
-
Method Details
-
createPageRequestBuilder
Allows to create a builder for a page request. This builder is usefully when you need to modify different parameter of page request and you want to make only a page request.- Returns:
-
getExecutor
-
getPageNumber
public int getPageNumber()Description copied from interface:PageRequestCurrent page- Specified by:
getPageNumberin interfacePageRequest- Returns:
- Current page
-
getPageSize
public int getPageSize()Description copied from interface:PageRequestPage size used to navigate- Specified by:
getPageSizein interfacePageRequest- Returns:
- Page size used to navigate
-
setPage
public void setPage(int page)Description copied from interface:PageNavigatorNavigates to the page. This method is an alternative to offset.- Specified by:
setPagein interfacePageNavigator
-
nextPage
public void nextPage()Description copied from interface:PageNavigatorNavigates to next page.- Specified by:
nextPagein interfacePageNavigator
-
setOffset
public void setOffset(int offset)Description copied from interface:PageNavigatorNavigates to the offset. This method is an alternative to page.- Specified by:
setOffsetin interfacePageNavigator
-
previousPage
public void previousPage()Description copied from interface:PageNavigatorNavigates to previous page.- Specified by:
previousPagein interfacePageNavigator
-
firstPage
public void firstPage()Description copied from interface:PageNavigatorNavigate to the first page.- Specified by:
firstPagein interfacePageNavigator
-
getOffset
public int getOffset()Description copied from interface:PageRequestSet the current offset from start of dataset.- Specified by:
getOffsetin interfacePageRequest- Returns:
-
setPageSize
public void setPageSize(int pageSize)Description copied from interface:PageNavigatorSet page size- Specified by:
setPageSizein interfacePageNavigator
-
getTotalElements
public int getTotalElements()Description copied from interface:PagedResultReturns the total amount of elements.- Specified by:
getTotalElementsin interfacePagedResult- Returns:
- the total amount of elements
-
lastPage
public void lastPage()Description copied from interface:PageNavigatorNavigate to last page- Specified by:
lastPagein interfacePageNavigator
-
getTotalPages
public int getTotalPages()Description copied from interface:PagedResultReturns the number of total pages.- Specified by:
getTotalPagesin interfacePagedResult- Returns:
- the number of total pages
-
isLast
public boolean isLast()- Specified by:
isLastin interfacePagedResult
-
isFirst
public boolean isFirst()- Specified by:
isFirstin interfacePagedResult
-
hasNext
public boolean hasNext()- Specified by:
hasNextin interfacePagedResult
-
hasPrevious
public boolean hasPrevious()- Specified by:
hasPreviousin interfacePagedResult
-