Android Example ULV - combining drag/drop and swipe to delete with a hierarchical data structure

The attached example presents the user with a two-level hierarchical view of data and uses ULV to implement the following:
  • Showing the hierarchy using indentation of sub-items
  • Drag/Drop reordering of items in the hierarchy
  • Swipe left/right to delete items
It's a combination of a couple of different examples provided by Informatix, applied to a two-level hierarchy of data where the data contains "branches" and "leaf nodes". The hierarchy allows for leaf nodes to be at the top level or within a branch but does not allow branches to be within branches.

It solves two issues with presenting the data while allowing the user to drag/drop to reposition items and swipe to delete items:
  1. How to enforce the hierarchy constraints without frustrating the user. As the user drags an items up and down the list, the item is shown at the current position either shaded or colored red, the red indicating that the item cannot be dropped at that position.
  2. How to allow the user to drag a leaf to a specific position inside or outside of a branch. In particular, how to allow the user to drop a leaf at the end of a set of leaf nodes inside a branch or to drop a leaf just past the end of the leaf nodes within a branch - the drop position in both cases is the same! The implemented solution is to add an "end of group" item which marks the end of a group of leaf nodes within a branch, making it part of the drag/drop operation but not able to be otherwise manipulated. The user can then drop before the "end of group" to add the leaf to a branch, or can drop after the "end of group" to add the leaf at the top level positioned after the leaf nodes within the branch.
Dependencies: ULV, Animation, AnimationPlus (all three are by Informatix), SQL, MapList (for underlying data storage), Reflection (to generate UUIDs).
 

Attachments

  • ULV_Hierarchy_DragDrop_SwipeDelete.zip
    26.5 KB · Views: 409
Top