예제 #1
0
        public NoteScripture FormatScriptureHeading(List<BibleVerse> verses)
        {
            NoteScripture scripture = new NoteScripture();

            string tstring = "";

            string scriptureHeading = "";
            string scriptureText = "";

            List<string> temp = new List<string>();

            // Number of selected verses
            int num = verses.Count;

            if (num > 0)
            {
                foreach (var i in verses)
                {
                    temp.Add(i.VerseNumber);
                    scriptureText += i.VerseNumber + " " + i.Scripture + " ";
                }

                if (num >= 1)
                {
                    tstring = "";

                    List<string> group = new List<string>();

                    for (var j = 0; j < temp.Count; j++)
                    {
                        int current = int.Parse(temp[j]);
                        int next;
                        int space;

                        if (temp.Count == 1)
                        {
                            space = 0;
                        }
                        else
                        {
                            // If there is a next
                            next = j + 1;
                            if (next < temp.Count)
                            {
                                space = System.Math.Abs(int.Parse(temp[j + 1]) - current);
                            }
                            else
                            {
                                space = 0;
                            }

                        }

                        // If there is a break between selection
                        if (space >= 2)
                        {
                            group.Add(temp[j]);

                            if (group.Count == 2)
                            {
                                tstring += group[0] + ", " + group[group.Count - 1] + ", ";
                            }
                            else if (group.Count >= 3)
                            {
                                tstring += group[0] + "-" + group[group.Count - 1] + ", ";
                            }
                            else
                            {
                                tstring += temp[j] + ", ";
                            }
                            group = new List<string>();
                        }
                        // If there is not a break between selection
                        else if (space == 1)
                        {
                            group.Add(temp[j]);
                        }
                        // If there are no verses after the current selection
                        else
                        {
                            if (num == 1)
                            {
                                tstring += temp[j];
                            }
                            else
                            {
                                group.Add(temp[j]);

                                if (group.Count == 2)
                                {
                                    tstring += group[0] + ", " + group[group.Count - 1];
                                }
                                else if (group.Count >= 3)
                                {
                                    tstring += group[0] + "-" + group[group.Count - 1];
                                }
                                else
                                {
                                    tstring += temp[j];
                                }
                                group = new List<string>();
                            }
                        }
                    }
                }

                scriptureHeading = selectedBook.Title.ToUpper() + " " + selectedChapter.ChapterNumber + ":" + tstring;

                scripture.Title = scriptureHeading;
                scripture.Scripture = scriptureText;
            }
            else
            {
                scripture = null;
            }

            return scripture;
        }
예제 #2
0
        void lookup_Click(object sender, EventArgs e)
        {
            ThisApp.doHighlight = true;

            ThisApp.ReaderKind = ReaderKind.BibleReader;

            NoteScripture n = new NoteScripture()
            {
                Id = 0,
                ScriptureForHighlight = ThisApp.selectedBook.Name + "," + (chapter.SelectedItemPosition + 1).ToString() + "," + (verse.SelectedItemPosition + 1).ToString()
            };
            ThisApp.selectedNote = n;

            //Intent intent = new Intent(Activity, ThisApp.MainReader.Class);
            //Activity.StartActivity(intent);
        }
예제 #3
0
        public void DeleteNoteFromParse(NoteScripture note)
        {
            if (!ConnectedToNetwork(context))
            {
                return;
            }

            // Initialize Parse
            Parse.Initialize(context, "scBTJphDK8yVGGtNhcL9cYee89GbEKuRkygGYXKa", "wlXg6dWeJBCxD3uNbnoCTnnZlpSvvZWOdfyoeREZ");

            ParseQuery notes = new ParseQuery("Note");
            notes.GetInBackground(note.NWTId, new MyGetCallback(note, "delete"));
        }
예제 #4
0
        public MySaveCallback(ParseObject testObject, NoteScripture n, Context context)
        {
            _testObject = testObject;
            _n = n;

            dbHelper = new NotesDbAdapter(context);
            dbHelper.Open();
        }
예제 #5
0
 public MyGetCallback(NoteScripture n, string operation)
 {
     _n = n;
     _operation = operation;
 }
예제 #6
0
        public override void Done(IList<ParseObject> list, Xamarin.Parse.ParseException e)
        {
            _notesActivity.dbHelper.DeleteAllNotes();

            for (var i = 0; i < list.Count; i++)
            {
                ParseObject item = list[i];

                NoteScripture note = new NoteScripture()
                {
                    NoteBody = item.GetString("note"),
                    NoteTitle = item.GetString("title") ?? "",
                    NWTId = item.ObjectId,
                    Scripture = item.GetString("text"),
                    ScriptureForHighlight = item.GetString("bookName") + "," + item.GetString("chapter") + "," + item.GetString("verse"),
                    Title = ThisApp.FormatScriptureHeading(item.GetString("bookName"), item.GetString("chapter"), item.GetString("verse").Split(','))
                };

                long id = _notesActivity.dbHelper.CreateNote(note);
            }

            // Update my notes list
            _notesActivity.FillData();

            ThisApp.AlertBox(_notesActivity, "SUCCESS", "Your notes are synced!\n\n" + list.Count + " notes downloaded.");
        }
예제 #7
0
        public NoteScripture GetNoteByParseId(long rowId)
        {
            NotesDbAdapter dbHelper;
            dbHelper = new NotesDbAdapter(context);
            dbHelper.Open();

            ICursor note = dbHelper.FetchNote(rowId);

            NoteScripture n = new NoteScripture()
            {
                Id = int.Parse(note.GetString(note.GetColumnIndex(NotesDbAdapter.KeyRowId))),
                Title = note.GetString(note.GetColumnIndex(NotesDbAdapter.KeyScriptureTitle)),
                Scripture = note.GetString(note.GetColumnIndex(NotesDbAdapter.KeyScriptureContent)),
                ScriptureForHighlight = note.GetString(note.GetColumnIndex(NotesDbAdapter.KeyScriptureForHighlight)),
                NoteTitle = note.GetString(note.GetColumnIndex(NotesDbAdapter.KeyTitle)),
                NoteBody = note.GetString(note.GetColumnIndex(NotesDbAdapter.KeyBody)),
                NWTId = note.GetString(note.GetColumnIndex(NotesDbAdapter.KeyNWTId))
            };

            return n;
        }