public void OnPrimaryClipChanged() { string pastedText = MainActivity.GetBufText(context); if (!sharedPrefs.GetBoolean("pref_monitor", true) || MainActivity.isActive) { return; } int textLen = pastedText.Length; for (int i = 0; i < textLen; i++) { if (pastedText[i] >= '\u25CB' && pastedText[i] <= '\u9FA5') { if (dict == null) { dict = new Dict(); } if (Dict.entries == null) { Dict.LoadDict(context); } List <List <object> > lines = new List <List <object> >(); AnnTask annotateTask = new AnnTask(context, AnnTask.TASK_ANNOTATE, MainActivity.ANNOTATE_BUFFER, 0, 0, 0, 5, 0, lines, new List <object>(), pastedText, pastedText.Length, null, new LineView(context), DisplayNotificationAnnInterface, true, null); annotateTask.Execute(); break; } } }
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(); }); }
public void Annotate(long position) { if (annTask != null) { annTask.Cancel(true); } lines.Clear(); linesAdapter.NotifyDataSetChanged(); linesAdapter.ShowHeader = false; linesAdapter.ShowFooter = true; wPopup.dismiss(); startPos = 0; curPos = 0; endPos = 0; isFirstFileAnnotation = true; if (annoMode == ANNOTATE_FILE) { startPos = Math.Max(0, GetPreferences(FileCreationMode.Private).GetInt(curFilePath, 0)); if (startPos >= textLen) { startPos = 0; } endPos = startPos; mBookmarks = Bookmark.ReadFromFile(curFilePath + ".bookmarks"); mFoundBookmarks.Clear(); } else if (annoMode == ANNOTATE_STARRED) { curFilePath = ""; curSaveName = "ChineseReader_Starred"; } else { curFilePath = ""; curSaveName = ""; } if (position >= 0) { startPos = endPos = position; } if (startPos == 0) { linesAdapter.ShowHeader = false; } //System.Console.WriteLine("THIS IS RIGHT BEFORE EXECUTE!!!!!!!!!!"); 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.ExecuteWrapper(); }
public void SplitAnnotation(int splitLineIndex, int curWidth, List <object> curLine) { if (annTask != null && annTask.status == AsyncTask.Status.Running) { annTask.Cancel(true); } annTask = new AnnTask(this, AnnTask.TASK_SPLIT, annoMode, curPos, startPos, endPos, curWidth, splitLineIndex, lines, curLine, pastedText, textLen, openedFile, testView, UpdateLinesAnnInterface, true, mBookmarks); annTask.ExecuteWrapper(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); System.Console.WriteLine("AnnotationActivity >> OnCreate"); app = this; try { if (FindViewById(Resource.Id.lines) != null) { AnnTask.UpdateVars(this); CheckIsShared(); return; } curFilePath = ""; isFirstAnnotation = true; isFirstFileAnnotation = true; PreferenceManager.SetDefaultValues(this, Resource.Xml.preferences, false); sharedPrefs = PreferenceManager.GetDefaultSharedPreferences(this); SetContentView(Resource.Layout.MainActivity); mToolbar = (Toolbar)FindViewById(Resource.Id.toolbar); // Attaching the layout to the toolbar object SetSupportActionBar(mToolbar); SupportActionBar.SetDisplayShowHomeEnabled(true); SupportActionBar.SetIcon(Resource.Drawable.logo_toolbar); wPopup = new WordPopup(this); testView = new LineView(this); testView.UpdateVars(); lines = new List <List <object> >(); linesRecyclerView = (CustomRecyclerView)FindViewById(Resource.Id.lines); linesRecyclerView.mMainActivity = this; linesLayoutManager = new LinearLayoutManager(this); linesRecyclerView.SetLayoutManager(linesLayoutManager); linesAdapter = new AnnListAdapter(this, this.lines, linesRecyclerView, wPopup); linesRecyclerView.SetAdapter(linesAdapter); defaultItemAnimator = linesRecyclerView.GetItemAnimator(); linesRecyclerView.AddOnScrollListener(new RecyclerViewOnScrollListener(this)); mBookmarks = new List <Bookmark>(); mFoundBookmarks = new List <Bookmark>(); } catch (Exception e) { Toast.MakeText(this, "Error: " + e.Message, ToastLength.Long).Show(); } }
public void DumpBoth(long startPos, long endPos) { AnnTask annTask = new AnnTask(ApplicationContext, AnnTask.TASK_ANNOTATE, annoMode, curPos, startPos, endPos, 5, 0, new List <List <object> >(), new List <object>(), pastedText, textLen, openedFile, testView, DumpBothAnnInterface, true, null); annTask.ExecuteWrapper(); }