https://github.com/tbrand/oneitem
Simple implementation for one item selected RecyclerView. This makes it easier to use arbitrary VideoView (such as MediaPlayer) in RecyclerView. This library includes RecyclerView.LayoutManager and Recyclerview.OnScrollListener.
https://github.com/tbrand/oneitem
android linearlayoutmanager recyclerview recyclerview-adapter
Last synced: 7 months ago
JSON representation
Simple implementation for one item selected RecyclerView. This makes it easier to use arbitrary VideoView (such as MediaPlayer) in RecyclerView. This library includes RecyclerView.LayoutManager and Recyclerview.OnScrollListener.
- Host: GitHub
- URL: https://github.com/tbrand/oneitem
- Owner: tbrand
- Created: 2017-02-26T03:33:05.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-26T04:06:19.000Z (over 9 years ago)
- Last Synced: 2025-07-08T01:56:46.922Z (11 months ago)
- Topics: android, linearlayoutmanager, recyclerview, recyclerview-adapter
- Language: Java
- Homepage: https://bintray.com/tbrandlib/maven/oneitem
- Size: 127 KB
- Stars: 17
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## OneItem
Simple implementation for one item selected RecyclerView.
This makes it easier to use arbitrary VideoView (such as MediaPlayer) in RecyclerView.
This library includes RecyclerView.LayoutManager and Recyclerview.OnScrollListener.
You can realize auto-playing Video View like Facebook, Instagram, Twitter or other famous single column SNS by this library.
## Sample

## Usage
### Install
In your top level `build.gradle`, add
```
allprojects {
repositories {
...
maven { url "http://tbrandlib.bintray.com/maven" }
}
}
```
In your application level `build.gradle`, add
```
dependencies {
compile 'com.tbrandlib.oneitem:oneitem:0.1.0'
}
```
### In java code
Implement `OneItemListener` in you RecyclerView.Adapter.
```java
MainAdapter extends RecyclerView.Adapter implements OneItemListener{
/// This method is called when the item at the position is selected as the one item
@Override
public void selectItemAt(int position) {
}
// This method is called when the item at the position is unselected
@Override
public void unSelectItemAt(int position) {
}
}
```
Setup OneItem with your RecyclerView.
```java
//MainAdapter implements OneItemListener
MainAdapter adapter = new MainAdapter(this);
RecyclerView recyclerView = (RecyclerView)findViewById(R.id.main_recycler_view);
recyclerView.setAdapter(adapter);
//You can setup one item manager like this
OneItemManager.setup(this, adapter, recyclerView);
```
Now you can get callback from OneItem to `#selectItemAt` and `#unSelectItemAt`.