public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { base.OnCreateView(inflater, container, savedInstanceState); _view = this.BindingInflate(Resource.Layout.fragment_favorite_news, container, false); _mRecyclerView = _view.FindViewById <MvxAdvancedNonExpandableRecyclerView>(Resource.Id.favorite_RecyclerView); _mLayoutManager = new LinearLayoutManager(_view.Context, LinearLayoutManager.Vertical, reverseLayout: true) { ReverseLayout = true, }; _mRecyclerView.SetLayoutManager(_mLayoutManager); var dividerItemDecoration = new DividerItemDecoration(_view.Context, _mLayoutManager.Orientation); dividerItemDecoration.SetDrawable(ContextCompat.GetDrawable(_view.Context, Resource.Drawable.recycler_view_divider)); _mRecyclerView.AddItemDecoration(dividerItemDecoration); _mAdapter = _mRecyclerView.AdvancedRecyclerViewAdapter as MvxNonExpandableAdapter; _mAdapter.SwipeItemPinnedStateController.ForLeftSwipe().Pinned += RemoveItem; _mAdapter.MvxViewHolderBound += (args) => { var swipeHolder = args.Holder as MvxAdvancedRecyclerViewHolder; var swipeState = swipeHolder.SwipeStateFlags; swipeHolder.ProportionalSwipeAmountModeEnabled = true; swipeHolder.MaxLeftSwipeAmount = -0.5f; _mAdapter.SwipeItemPinnedStateController.SetPinnedForAllStates(args.DataContext, false); swipeHolder.SwipeItemHorizontalSlideAmount = _mAdapter.SwipeItemPinnedStateController.ForRightSwipe().IsPinned(args.DataContext) ? -0.5f : 0; }; _mAdapter.SwipeBackgroundSet += (args) => { int bgRes = 0; switch (args.Type) { case SwipeableItemConstants.DrawableSwipeNeutralBackground: bgRes = Resource.Drawable.bg_swipe_item_neutral; break; case SwipeableItemConstants.DrawableSwipeLeftBackground: bgRes = Resource.Drawable.bg_item_swiping_right_state; break; } if (bgRes != 0) { args.ViewHolder.ItemView.SetBackgroundResource(bgRes); } }; return(_view); }
protected override void OnCleanUp() { base.OnCleanUp(); _adpater = null; }
public MvxSwipeToDirectionResultAction(MvxNonExpandableAdapter adpater, SwipeDirection swipeDirection, int position) { _adpater = adpater; _swipeDirection = swipeDirection; _position = position; }
public override SwipeResultAction GetUnpinSwipeResultAction(MvxNonExpandableAdapter adapter, int position) { return(new MvxSwipeUnpinResultAction(adapter, position)); }
public override SwipeResultAction GetSwipeLeftResultAction(MvxNonExpandableAdapter adapter, int position) { return(new MvxSwipeToDirectionResultAction(adapter, SwipeDirection.FromRight, position)); }
public NonExpandableSwipeResultActionItemManager(MvxNonExpandableAdapter nonExpandableAdapter, int itemPosition) { _nonExpandableAdapter = nonExpandableAdapter; _itemPosition = itemPosition; }
public virtual SwipeResultAction GetSwipeUpResultAction(MvxNonExpandableAdapter adapter, int position) { return(new SwipeResultActionDoNothing()); }
public MvxSwipeUnpinResultAction(MvxNonExpandableAdapter adapter, int position) { _adapter = adapter; _position = position; }