<commit_before>InfiniteScrollListView
======================

Simple infinite scrolling ListView for Android.

### InfiniteScrollListView
The simple ListView.

### InfiniteScrollOnScrollListener
The implementation of OnScrollListener that detects whether the ListView is close to its end.

### IInfiniteScrollListener
Contains the method called by the InfiniteScrollOnScrollListener when the end is reached. Can be implemented by an Activity or Fragment.

### InfiniteScrollAdapter
Abstract adapter which determines which view to show (the real view or the loading placeholder view). Implementations must specify the underlying Collection of items and the views to display.<commit_msg>Update README.md with implementation details<commit_after>InfiniteScrollListView
======================

Simple infinite scrolling ListView for Android. For a technical explanation of how this works, refer to [this blog post](http://sandersdenardi.com/infinite-scrolling-in-android/). Included is a working example that demonstrates how to use the API.

API
---
### InfiniteScrollAdapter
```java
public abstract class InfiniteScrollAdapter extends BaseAdapter {
    Collection getItems();
    void addItems(Collection items);
    Object getRealItem(int position);
    View getRealView(LayoutInflater inflater, int position, View convertView, ViewGroup parent);
    View getLoadingView(LayoutInflater inflater, ViewGroup parent);
}
```
`getItems()` must expose the underlying data as a collection. 
`addItems()` takes in a collection and, depending on whether the collection is empty, either adds the items to the underlying data or sets the internal `doneLoading` flag to `true`. The implementation must also call `notifyDataSetChanged()` at the end of the method.
`getRealItem()` returns the object represented by that position. You can assume the position is within the bounds of whatever collection you expose via `getItems()`.
`getRealView()` works just like `getView()` in a regular `ListAdapter`, returning a view for the particular position.
`getLoadingView()` also works like a regular `ListAdapter`, but returns a view that indicates that data is being loaded in the background.

### InfiniteScrollOnScrollListener
The implementation of OnScrollListener that detects whether the ListView is close to its end.

### IInfiniteScrollListener
```java
public interface IInfiniteScrollListener {
    public void endIsNear();
}
```
`endIsNear()` is called when the ListView reaches near the end of the list, and should initiate fetching of new data. Note this this will be called on every scroll that is near the end, which can be several dozens of times a second, so the implementation of this should set a flag once loading is started to prevent loading multiple times.

Example
-------
The included example is a simple implementation. The application is a single activity that creates an `InfiniteScrollListView` and an implementation of the `InfiniteScrollAdapter` using an `ArrayList` of trivial objects. It populates the list with an amount of items that does not extend beyond the view port, causing the immediate retrieval of data. Data fetching is simulated via an `AsyncTask` with a `sleep()` delay. It will load a maximum of 40 items, then return an empty collection to signify that no more data is available.

License
-------
The MIT License (MIT)

Copyright (c) 2014 <NAME>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
{'fraction_non_alphanumeric': 0.06187443130118289, 'fraction_numerical': 0.001364877161055505, 'mean_word_length': 5.219236209335219, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '157081', 'n_tokens_mistral': 1038, 'n_tokens_neox': 982, 'n_words': 594}