Пример #1
0
        public void Redraw()
        {
            if (annTask != null && annTask.status == AsyncTask.Status.Running)
            {
                return;
            }

            settingsChanged = false;
            AnnTask.UpdateVars(this);
            int currentTop = linesRecyclerView.GetChildAt(0).Top;

            annTask = new AnnTask(this, AnnTask.TASK_ANNOTATE, annoMode, curPos, startPos, endPos, 5, 0, lines, new List <object>(), pastedText, textLen, openedFile, testView, UpdateLinesAnnInterface, true, mBookmarks);
            annTask.RedrawLines(linesRecyclerView);
            startPos = annTask.startPos;
            endPos   = annTask.endPos;

            linesAdapter.NotifyDataSetChanged();

            if (startPos > 0)
            {
                linesAdapter.ShowHeader = true;
            }

            RecyclerView ll = linesRecyclerView;

            ll.ClearFocus();
            ll.Post(() =>
            {
                ll.RequestFocusFromTouch();
                ((LinearLayoutManager)ll.GetLayoutManager()).ScrollToPositionWithOffset(1, currentTop);
                ll.RequestFocus();
            });
        }
Пример #2
0
        private async Task Init()
        {
            WordLogic = new WordLogic(new PersistentWordManager <Word>(new FileHelper().GetLocalFilePath("WordMemo.db")));

            await WordLogic.UpdateWordList();

            _mWords = WordLogic.WordList;

            _mWordsAdapter = new WordsAdapter(this, _mWords);

            _mRecyclerView.SetAdapter(_mWordsAdapter);

            _mRecyclerView.LayoutChange += (sender, args) =>
            {
                bottomPosition = args.Bottom;
            };

            var fab = FindViewById <FloatingActionButton>(Resource.Id.fab);

            fab.Click += (sender, args) =>
            {
                Word newWord = new Word();
                _mWordsAdapter.AddWord(newWord);
                _mWordsAdapter.NotifyItemInserted(_mWordsAdapter.ItemCount - 1);

                HideKeyboard();

                _mRecyclerView.SmoothScrollToPosition(bottomPosition);
            };

            _mRecyclerView.ChildViewAttachedToWindow += (sender, args) =>
            {
                View lastRow = _mRecyclerView.GetLayoutManager().GetChildAt(_mWordsAdapter.ItemCount - 1);

                if (lastRow != null && args.View == lastRow)
                {
                    lastRow.RequestFocus();
                }
            };

            _mRecyclerView.SetItemAnimator(new DefaultItemAnimator());

            ItemTouchHelper.Callback callback        = new RecyclerItemTouchHelper(this);
            ItemTouchHelper          itemTouchHelper = new ItemTouchHelper(callback);

            itemTouchHelper.AttachToRecyclerView(_mRecyclerView);

            _mRecyclerView.ClearFocus();
            HideKeyboard();
        }