bool HandleContextMode(AView view, int position)
        {
            if (view is EditText || view is TextView || view is SearchView)
            {
                return(false);
            }

            Cell cell = GetCellForPosition(position);

            if (cell == null)
            {
                return(false);
            }

            if (_actionMode != null || _supportActionMode != null)
            {
                if (!cell.HasContextActions)
                {
                    CloseContextActions();
                    return(false);
                }

                ActionModeContext = cell;

                if (ActionModeContext.IsContextActionsLegacyModeEnabled == false)
                {
                    _actionModeNeedsUpdates = true;
                }

                _actionMode?.Invalidate();
                _supportActionMode?.Invalidate();
            }
            else
            {
                if (!cell.HasContextActions)
                {
                    return(false);
                }

                ActionModeContext = cell;

                var appCompatActivity = view.Context as AppCompatActivity;
                if (appCompatActivity == null)
                {
                    _actionMode = view.Context.GetActivity().StartActionMode(this);
                }
                else
                {
                    _supportActionMode = appCompatActivity.StartSupportActionMode(this);
                }
            }

            ContextView = view;

            return(true);
        }
Beispiel #2
0
        bool HandleContextMode(AView view, int position)
        {
            if (view is EditText || view is TextView || view is SearchView)
            {
                return(false);
            }

            Cell cell = GetCellForPosition(position);

            if (cell == null)
            {
                return(false);
            }

            if (_actionMode != null || _supportActionMode != null)
            {
                if (!cell.HasContextActions)
                {
                    CloseContextActions();
                    return(false);
                }

                ActionModeContext = cell;

                _actionMode?.Invalidate();
                _supportActionMode?.Invalidate();
            }
            else
            {
                if (!cell.HasContextActions)
                {
                    return(false);
                }

                ActionModeContext = cell;

                var appCompatActivity = Forms.Context as FormsAppCompatActivity;
                if (appCompatActivity == null)
                {
                    _actionMode = ((Activity)Forms.Context).StartActionMode(this);
                }
                else
                {
                    _supportActionMode = appCompatActivity.StartSupportActionMode(this);
                }
            }

            ContextView = view;

            return(true);
        }