Beispiel #1
0
        private void setLockSwipe(bool lockSwipe, params string[] ids)
        {
            if (ids == null || ids.Length == 0)
            {
                return;
            }

            if (lockSwipe)
            {
                foreach (var item in ids)
                {
                    lockedSwipeSet.TryAdd(item, 0);
                }
            }
            else
            {
                foreach (var item in ids)
                {
                    byte ignore = 0;
                    lockedSwipeSet.TryRemove(item, out ignore);
                }
            }

            foreach (string item in ids)
            {
                SwipeRevealLayout layout = mapLayouts.get(item);
                if (layout != null)
                {
                    layout.setLockDrag(lockSwipe);
                }
            }
        }
Beispiel #2
0
        /**
         * Help to save and restore open/close state of the swipeLayout. Call this method
         * when you bind your view holder with the data object.
         *
         * @param swipeLayout swipeLayout of the current view.
         * @param id a string that uniquely defines the data object of the current view.
         */
        public void bind(SwipeRevealLayout swipeLayout, string id)
        {
            base.ExecuteMethod("bind", delegate()
            {
                if (swipeLayout.shouldRequestLayout())
                {
                    swipeLayout.RequestLayout();
                }

                mapLayouts.removeAllWithValue(swipeLayout);
                mapLayouts.put(id, swipeLayout);

                swipeLayout.abort();

                swipeLayout.setDragStateChangeListener(new CustomListener(this, swipeLayout, id));


                // first time binding.
                if (!mapStates.ContainsKey(id))
                {
                    mapStates.put(id, SwipeRevealLayout.STATE_CLOSE);
                    swipeLayout.close(false);
                }

                // not the first time, then close or open depends on the current state.
                else
                {
                    int state = mapStates.get(id);

                    if (state == SwipeRevealLayout.STATE_CLOSE || state == SwipeRevealLayout.STATE_CLOSING ||
                        state == SwipeRevealLayout.STATE_DRAGGING)
                    {
                        swipeLayout.close(false);
                    }
                    else
                    {
                        swipeLayout.open(false);
                    }
                }

                // set lock swipe
                swipeLayout.setLockDrag(lockedSwipeSet.ContainsKey(id));
            });
        }