-
public final class ViewBinderHelperViewBinderHelper provides a quick and easy solution to restore the open/close state of the items in RecyclerView, ListView, GridView or any view that requires its child view to bind the view to a data object.
When you bind you data object to a view, use bind to save and restore the open/close state of the view.
Optionally, if you also want to save and restore the open/close state when the device's orientation is changed, call saveStates in android.app.Activity.onSaveInstanceState and restoreStates in android.app.Activity.onRestoreInstanceState
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classViewBinderHelper.Companion
-
Constructor Summary
Constructors Constructor Description ViewBinderHelper()
-
Method Summary
Modifier and Type Method Description final Unitbind(SwipeRevealLayout swipeLayout, String id)Help to save and restore open/close state of the swipeLayout. final UnitsaveStates(Bundle outState)Call this method in android.app.Activity.onSaveInstanceState only if you need to restore open/close state when the orientation is changed. final UnitrestoreStates(Bundle inState)Call this method in android.app.Activity.onRestoreInstanceState only if you need to restore open/close state when the orientation is changed. final UnitlockSwipe(String id)Lock swipe for some layouts. final UnitunlockSwipe(String id)Unlock swipe for some layouts. final UnitsetOpenOnlyOne(Boolean openOnlyOne)final <ERROR CLASS>openLayout(String id)Open a specific layout. final <ERROR CLASS>closeLayout(String id)Close a specific layout. -
-
Method Detail
-
bind
final Unit bind(SwipeRevealLayout swipeLayout, String id)
Help to save and restore open/close state of the swipeLayout. Call this method when you bind your view holder with the data object.
- Parameters:
swipeLayout- swipeLayout of the current view.id- a string that uniquely defines the data object of the current view.
-
saveStates
final Unit saveStates(Bundle outState)
Call this method in android.app.Activity.onSaveInstanceState only if you need to restore open/close state when the orientation is changed.
-
restoreStates
final Unit restoreStates(Bundle inState)
Call this method in android.app.Activity.onRestoreInstanceState only if you need to restore open/close state when the orientation is changed.
-
lockSwipe
final Unit lockSwipe(String id)
Lock swipe for some layouts.
- Parameters:
id- a string that uniquely defines the data object.
-
unlockSwipe
final Unit unlockSwipe(String id)
Unlock swipe for some layouts.
- Parameters:
id- a string that uniquely defines the data object.
-
setOpenOnlyOne
final Unit setOpenOnlyOne(Boolean openOnlyOne)
- Parameters:
openOnlyOne- If set to true, then only one row can be opened at a time.
-
openLayout
final <ERROR CLASS> openLayout(String id)
Open a specific layout.
- Parameters:
id- unique id which identifies the data object which is bind to the layout.
-
closeLayout
final <ERROR CLASS> closeLayout(String id)
Close a specific layout.
- Parameters:
id- unique id which identifies the data object which is bind to the layout.
-
-
-
-