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.
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'
}
Implement OneItemListener in you RecyclerView.Adapter.
MainAdapterextendsRecyclerView.AdapterimplementsOneItemListener{
/// This method is called when the item at the position is selected as the one item@OverridepublicvoidselectItemAt(intposition) {
}
// This method is called when the item at the position is unselected@OverridepublicvoidunSelectItemAt(intposition) {
}
}Setup OneItem with your RecyclerView.
//MainAdapter implements OneItemListenerMainAdapteradapter = newMainAdapter(this);
RecyclerViewrecyclerView = (RecyclerView)findViewById(R.id.main_recycler_view);
recyclerView.setAdapter(adapter);
//You can setup one item manager like thisOneItemManager.setup(this, adapter, recyclerView);Now you can get callback from OneItem to #selectItemAt and #unSelectItemAt.
