https://github.com/coder966/android-adapterx
A RecyclerView adapter that features load more feature.
https://github.com/coder966/android-adapterx
adapter android recyclerview recyclerview-adapter
Last synced: 2 months ago
JSON representation
A RecyclerView adapter that features load more feature.
- Host: GitHub
- URL: https://github.com/coder966/android-adapterx
- Owner: coder966
- Created: 2018-08-27T23:09:36.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-05-06T15:13:18.000Z (about 6 years ago)
- Last Synced: 2025-01-17T14:18:35.472Z (4 months ago)
- Topics: adapter, android, recyclerview, recyclerview-adapter
- Language: Java
- Size: 83 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# AdapterX
An Android RecyclerView Adapter that adds the feature "Load More".
Installation
---
Please use whatever last version is.
```gradle
implementation 'net.coder966.android:adapterx:0.3.2'
```Usage
---
For a full working example, see the demo module.* Extend `AdapterX`. `T` is the type of individual items in your list.
* To enable "Load More" feature, you must set the `OnLoadMoreListener`.```java
// NOTE: this must be done before setting the adapter to the recycler view.// optional but mandatory if you want to enable "Load More" feature.
adapter.setOnLoadMoreListener((adapterx, lastItem) -> {
/*
Perform DB/API call to get more items.
IF YOU NEED, you can use the provided reference "lastItem" to determine which items to load.
*/// when you get your new list of items, call load method
adapterx.load(moreDataList);
});// The above segment of code uses Java's Lambda Expressions. If you are not familiar with JDK8 new features, you can always use the old style.
```More optional settings
---
* AdapterX can pre-fetch data to improve user experience. The default pre-fetch distance is 5 items.```java
adapter.setPrefetchThreshold(10);
```* To set a custom loading view
```java
adapter.setLoadingView(R.layout.loading);
```License
---
```
Copyright 2018 Khalid H. AlharisiLicensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```