Exemplo n.º 1
0
        private void Adapter_EditClicked(int position)
        {
            var view     = recycler.GetChildAt(position);
            var vieNote  = view.FindViewById <TextView>(Resource.Id.viewNote);
            var editNote = view.FindViewById <TextView>(Resource.Id.noteEdit);
            var content  = view.FindViewById <TextView>(Resource.Id.notesContent);

            var dialog = new AddNoteDialog(notes[position]);

            dialog.OnNoteSave += (Note note) =>
            {
                notes[position] = note;
                var foundIdea = Global.Categories.FirstOrDefault(x => x.CategoryLbl == note.Category).Items.FirstOrDefault(y => y.Title == note.Title);
                if (foundIdea != null)
                {
                    foundIdea.Note = note;
                }

                var foundBookmark = bookmarkedItems.FirstOrDefault(x => x.Title == notes[position].Title);
                if (foundBookmark != null)
                {
                    foundBookmark.Note = note;
                }
                adapter.NotifyItemChanged(position);
            };

            dialog.OnError += () => Snackbar.Make(recycler, "Invalid note. Please retry editing.", Snackbar.LengthLong).Show();

            dialog.Show(FragmentManager, "NOTESFRAG");
        }
Exemplo n.º 2
0
        private void Adapter_EditClicked(int position)
        {
            var dialog = new AddNoteDialog(notes[position]);

            dialog.OnNoteSave += (Note note) =>
            {
                notes[position] = note;
                var foundIdea = Global.Categories.FirstOrDefault(x => x.CategoryLbl == note.Category).Items.FirstOrDefault(y => y.Title == note.Title);
                if (foundIdea != null)
                {
                    foundIdea.Note = note;
                }

                var foundBookmark = bookmarkedItems.FirstOrDefault(x => x.Title == notes[position].Title);
                if (foundBookmark != null)
                {
                    foundBookmark.Note = note;
                }

                adapter.NotifyItemChanged(position);

                SaveChanges();
            };

            dialog.OnError += () => Snackbar.Make(recycler, "Invalid note. Entry fields cannot be empty.", Snackbar.LengthLong).Show();

            dialog.Show(FragmentManager, "NOTESFRAG");
        }
Exemplo n.º 3
0
 private void AddNoteFab_Click(object sender, EventArgs e)
 {
     if (item.Note == null)
     {
         var dialog = new AddNoteDialog(ideasList[Global.ItemScrollPosition].Category, ideasList[Global.ItemScrollPosition].Title);
         dialog.OnError    += () => { Snackbar.Make(addNoteFab, "Invalid note. Entry fields cannot be empty.", Snackbar.LengthLong).Show(); };
         dialog.OnNoteSave += (Note note) => HandleNoteSave(note);
         dialog.Show(FragmentManager, "ADDNOTEFRAG");
     }
     else
     {
         Snackbar.Make(addNoteFab, "This idea already has a note. Consider editing that instead.", Snackbar.LengthLong).Show();
     }
 }
Exemplo n.º 4
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            ideaTitleLbl       = FindViewById <TextView>(Resource.Id.itemTitle);
            ideaDescriptionLbl = FindViewById <TextView>(Resource.Id.itemDescription);
            detailsView        = FindViewById <LinearLayout>(Resource.Id.detailsView);
            addNoteFab         = FindViewById <FloatingActionButton>(Resource.Id.addNotefab);
            var editNoteBtn = FindViewById <Button>(Resource.Id.editNoteBtn);

            noteCard       = FindViewById <CardView>(Resource.Id.noteHolder);
            noteContentLbl = FindViewById <TextView>(Resource.Id.noteContent);

            addNoteFab.Click += AddNoteFab_Click;
            var swipeListener = new OnSwipeListener(this);

            swipeListener.OnSwipeRight += SwipeListener_OnSwipeRight;
            swipeListener.OnSwipeLeft  += SwipeListener_OnSwipeLeft;
            ideaDescriptionLbl.SetOnTouchListener(swipeListener);
            detailsView.SetOnTouchListener(swipeListener);

            editNoteBtn.Click += delegate
            {
                var dialog = new AddNoteDialog(bookmarkedItems[Global.IdeaScrollPosition].Note);
                dialog.OnError += () => Snackbar.Make(addNoteFab, "Invalid note. Entry fields cannot be empty.", Snackbar.LengthLong).Show();
                dialog.Show(FragmentManager, "ADDNOTEFRAG");
                dialog.OnNoteSave += (Note note) => SaveNote(note);
            };

            bookmarkedItems = await DBSerializer.DeserializeDBAsync <List <Idea> >(Global.BOOKMARKS_PATH);

            bookmarkedItems = bookmarkedItems ?? new List <Idea>();

            bookmarkedIdea = bookmarkedItems[Global.BookmarkScrollPosition];
            ideasList      = Global.Categories.FirstOrDefault(x => x.CategoryLbl == bookmarkedIdea.Category).Items;

            notes = await DBSerializer.DeserializeDBAsync <List <Note> >(Global.NOTES_PATH);

            notes = notes ?? new List <Note>();

            SetupUI();
        }
Exemplo n.º 5
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            path = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "bookmarks.json");
            base.OnCreate(savedInstanceState);
            ideaTitleLbl       = FindViewById <TextView>(Resource.Id.itemTitle);
            ideaDescriptionLbl = FindViewById <TextView>(Resource.Id.itemDescription);
            detailsView        = FindViewById <LinearLayout>(Resource.Id.detailsView);
            addNoteFab         = FindViewById <FloatingActionButton>(Resource.Id.addNotefab);
            editNoteBtn        = FindViewById <Button>(Resource.Id.editNoteBtn);
            noteCard           = FindViewById <CardView>(Resource.Id.noteHolder);
            noteContentLbl     = FindViewById <TextView>(Resource.Id.noteContent);

            addNoteFab.Click           += AddNoteFab_Click;
            SwipeListener               = new OnSwipeListener(this);
            SwipeListener.OnSwipeRight += SwipeListener_OnSwipeRight;
            SwipeListener.OnSwipeLeft  += SwipeListener_OnSwipeLeft;
            ideaDescriptionLbl.SetOnTouchListener(SwipeListener);
            detailsView.SetOnTouchListener(SwipeListener);

            editNoteBtn.Click += delegate
            {
                var dialog = new AddNoteDialog(bookmarkedItems[Global.ItemScrollPosition].Note);
                dialog.Show(FragmentManager, "ADDNOTEFRAG");
                dialog.OnNoteSave += (Note note) => HandleNoteSave(note);
            };

            bookmarkedItems = await DBAssist.DeserializeDBAsync <List <Idea> >(path);

            bookmarkedItems = bookmarkedItems ?? new List <Idea>();

            item      = bookmarkedItems[Global.BookmarkScrollPosition];
            ideasList = Global.Categories.FirstOrDefault(x => x.CategoryLbl == item.Category).Items;
            SetupUI();

            notes = await DBAssist.DeserializeDBAsync <List <Note> >(notesdb);

            notes = notes ?? new List <Note>();
        }