nhaarman/ListViewAnimations — pull request #23 by maxjspaulding (2013-08-22 05:40:06+00:00)
Title: Updates to ContextualUndoAdapter

Hi Niek,

I am using your Library in a project and have made a few changes to the ContextualUndoAdapter.

1) The first change was I added a check to insure that the view being swiped was an instance of ContextualUndoView. I am using it in a custom adapter that mixes a few adapters into sections. Some of which shouldn't be swipable. The same for the section header items. This check prevents a crash. There might be a better way to do this, and I am not sure if it is required in any other of the Adapters but it meets my needs as is.

2) I added some functionality to the ContextualUndoAdapter. Originally you have to swipe to get the undo view then swipe again to delete or swipe another item. I added two constructors that let you create a ContextualUndoAdapter with a count down timer that will automatically perform the removal after it hits zero. The second constructor works as the first but it has a callback to get a formatted text string which is called on each tick of the timer so it can update a count down in the undo view. I have created two sample activities for this. And tried to follow your formatting in the javadoc for them. The original constructor remains and all existing implementations of ContextualUndoAdapter should continue to function exactly as is.

I have a few more pushes to make in the coming weeks. I'm adding an adapter to sort list items. possibly one that lets you change the value of a list item by swiping left or right. I'd also be happy to have my app listed under Known Applications Using ListViewAnimations once it is in Google Play.

- Max