private void UpdatePagerViewAfterPageRemove(PagerAnimated parentPager, Action <TData> callback) { if (parentPager.CurrentItem < _dataCollection.Count && parentPager.CurrentItem < _fragmentMap.Count) { _fragmentMap.Remove(parentPager.CurrentItem); } var removedItem = _dataCollection[parentPager.CurrentItem]; _dataCollection.RemoveAt(parentPager.CurrentItem); NotifyDataSetChanged(); var position = parentPager.CurrentItem >= _fragmentMap.Count ? parentPager.CurrentItem - 1 : parentPager.CurrentItem; Fragment nextFragment; Fragment prevFragment; if (_fragmentMap.TryGetValue(position + 1, out nextFragment)) { parentPager.PageTransformer?.TransformPage(nextFragment.View, parentPager.AnimationHorizontalPositionOffset + 1); } if (_fragmentMap.TryGetValue(position - 1, out prevFragment)) { parentPager.PageTransformer?.TransformPage(prevFragment.View, parentPager.AnimationHorizontalPositionOffset - 1); } callback?.Invoke(removedItem); }
public void RemoveCurrentPage(PagerAnimated parentPager, Action <TData> callback) { var position = parentPager.CurrentItem; Fragment page; if (!_fragmentMap.TryGetValue(position, out page)) { return; } var fadeoutAnim = new AlphaAnimation(1.0f, 0.0f) { Duration = 300 }; page.View.StartAnimation(fadeoutAnim); page.View.PostDelayed(() => UpdatePagerViewAfterPageRemove(parentPager, callback), 300); }