All Projects → mazenrashed → RxPagination

mazenrashed / RxPagination

Licence: Apache-2.0 license
Implement pagination in just few lines with RxPagination

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to RxPagination

Rxbiometric
☝️ RxJava and RxKotlin bindings for Biometric Prompt (Fingerprint Scanner) on Android
Stars: ✭ 295 (+1375%)
Mutual labels:  rxandroid, rxjava2, rxkotlin
Aic Mobile Android
Art Institute of Chicago Official Mobile App - Android
Stars: ✭ 31 (+55%)
Mutual labels:  rx, rxjava2, rxkotlin
Freezer
A simple & fluent Android ORM, how can it be easier ? RxJava2 compatible
Stars: ✭ 326 (+1530%)
Mutual labels:  rxandroid, rx, rxjava2
Poolakey
Android In-App Billing SDK for Cafe Bazaar App Store
Stars: ✭ 60 (+200%)
Mutual labels:  rxandroid, rxjava2, rxkotlin
Rxbluetooth
Android reactive bluetooth
Stars: ✭ 405 (+1925%)
Mutual labels:  rxandroid, rx, rxjava2
InfiniteScroll
You can do a Endless scroll in ListView or RecyclerView with simple steps, with a listener for do request to your web service.
Stars: ✭ 28 (+40%)
Mutual labels:  pagination, recyclerview
Android Pagination With Recyclerview
Pagination (Endless or Infinite Scrolling) using RecyclerView's onScrollListener
Stars: ✭ 269 (+1245%)
Mutual labels:  pagination, recyclerview
Nopaginate
Android pagination library (updated 01.05.2018)
Stars: ✭ 180 (+800%)
Mutual labels:  pagination, recyclerview
FastWaiMai
仿写美团外卖电商项目
Stars: ✭ 123 (+515%)
Mutual labels:  recyclerview, rxandroid
Androidproject
Android 技术中台,但愿人长久,搬砖不再有
Stars: ✭ 4,398 (+21890%)
Mutual labels:  recyclerview, rxjava2
kotlin-maze
🚂 A simple way to implement applications using observable streams
Stars: ✭ 56 (+180%)
Mutual labels:  rxandroid, rxjava2
Android
Step by step guide for various components in android
Stars: ✭ 32 (+60%)
Mutual labels:  recyclerview, rxjava2
QueryMovies
This repository shows a Android project with Clean Architecture, Functional Reactive Programming and MVP+Dagger
Stars: ✭ 16 (-20%)
Mutual labels:  pagination, rxandroid
Featureadapter
FeatureAdapter (FA) is an Android Library providing an optimized way to display complex screens on Android.
Stars: ✭ 112 (+460%)
Mutual labels:  recyclerview, rxjava2
Elements
⚒ Modular components for RecyclerView development enforcing clean, reusable and testable code, with built-in support for paging and complex hierarchies of data.
Stars: ✭ 75 (+275%)
Mutual labels:  pagination, recyclerview
Base Mvvm
App built to showcase basic Android View components like ViewPager, RecyclerView(homogeneous and heterogeneous items), NavigationDrawer, Animated Vector Drawables, Collapsing Toolbar Layout etc. housed in a MVVM architecture
Stars: ✭ 18 (-10%)
Mutual labels:  recyclerview, rxjava2
Android-Starter-Kit
This is up-to-date android studio project for native android application, that is using modern tools and libraries.
Stars: ✭ 16 (-20%)
Mutual labels:  rxandroid, rxjava2
AndroidVIP
Android project to experiment the VIPER approach using mosby, RxJava and dagger2
Stars: ✭ 21 (+5%)
Mutual labels:  rxandroid, rxjava2
RxLogs
An Android & Kotlin Reactive Advanced Logging Framework.
Stars: ✭ 12 (-40%)
Mutual labels:  rxandroid, rxjava2
ParkingDemo
Taipei City Parking Lot Information Query System Demo
Stars: ✭ 18 (-10%)
Mutual labels:  recyclerview, rxkotlin

RxPagination

Implement the pagination in a few lines,

Add the JitPack repository to your build file

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Add dependency

dependencies {
    implementation 'com.github.mazenrashed:RxPagination:${LAST_VERSION}'
}

Usage

We will use the car example,

In Your repository

Jest implement ListRepository<T>

class CarRepository : ListRepository<Car>{
...
}

Then, you need to override getDataList(page: Int, pageSize : Int) inside the repository

class CarRepository : ListRepository<Car> {  
  
    override fun getDataList(page: Int, pageSize : Int): Single<ArrayList<Car>> {  
        return endPoints.getCars(pageSize, page) //For Example (You need to return your data source here)
    }  
      
}

In The View Model

Inehet from RxPagination<T>

class CarsViewModel(carsRepository: CarRepository) :  
    RxPagination<CarRepository>(carsRepository, PAGE_SIZE, FIRST_PAGE) {  
      
    init {  
        loadDataList()  
    }
    
 }

Then, you need to override onFetchDataListSubscribed, onFetchDataListError and onFetchDataListSuccess

class CarsViewModel(carsRepository: CarRepository) :  
    RxPagination<CarRepository>(carsRepository, PAGE_SIZE, FIRST_PAGE) {  
      
    init {  
        loadDataList()  
    }
    
    override fun onFetchDataListSubscribed() {  
	   //Start fetching data
    }  
  
    override fun onFetchDataListError(throwable: Throwable) {  
	   
    }  
  
    override fun onFetchDataListSuccess(lastLoadedList: ArrayList<GithubRepository>) {  
	  //You don't need to handle the data, but if you need it, it's available
	  //This lastLoadedList is the new loaded part.
    }
 }

In the UI (Activity or Fragment)

To observe the data list, use viewModel.dataList, dataList is a BehaviorRelay<ArrayList<T>>

viewModel  
  .dataList  
  .observeOn(AndroidSchedulers.mainThread())  
  .subscribe { dataList ->  
	// notify your list adapter here 
    }

Load and reload data

viewModel.loadDataList() //To load the more data

viewModel.reloadDataList() //To reload the data

Access page informations

To access cerrent page

viewModel.page.value //Int

To check if you reach the last page

viewModel.isLastPage.value //Boolean

Contributing

We welcome contributions !

  • ⇄ Pull requests and ★ Stars are always welcome.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].