protected override void OnStart() { base.OnStart(); _viewModel.LoadNotes(); ListAdapter = new NotesAdapter(this, _viewModel.Notes); }
//Инициализация всех полей private void Initialize() { GardenBed bed = UserSingleton.Instance.CurrentBed; typeName.Text = bed.Plant.TypeName; sortName.Text = bed.Plant.SortName; waterDate.Text = bed.WaterDate.ToString("dd/MM/yyyy hh:mm"); waterPeriod.Text = bed.WaterPeriod.ToString(); weedDate.Text = bed.WeedDate.ToString("dd/MM/yyyy hh:mm"); weedPeriod.Text = bed.WeedPeriod.ToString(); pileUpDate.Text = bed.PileUpDate.ToString("dd/MM/yyyy hh:mm"); pileUpPeriod.Text = bed.PileUpPeriod.ToString(); fertilizeDate.Text = bed.FertilizeDate.ToString("dd/MM/yyyy hh:mm"); fertilizePeriod.Text = bed.FertilizePeriod.ToString(); //FIXME:: Отрисовать все записки mRecyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView1); // Plug in the linear layout manager: mLayoutManager = new LinearLayoutManager(this); mRecyclerView.SetLayoutManager(mLayoutManager); // Plug in my adapter: mAdapter = new NotesAdapter(bed.Notes, this); mRecyclerView.SetAdapter(mAdapter); //Привязываю нажатия на элементы адаптера mAdapter.NoteChanged += OnNoteChanged; RegisterForContextMenu(mRecyclerView); }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); notes = await DBSerializer.DeserializeDBAsync <List <Note> >(Global.NOTES_PATH); notes = notes ?? new List <Note>(); bookmarkedItems = await DBSerializer.DeserializeDBAsync <List <Idea> >(Global.BOOKMARKS_PATH); bookmarkedItems = bookmarkedItems ?? new List <Idea>(); recycler = FindViewById <RecyclerView>(Resource.Id.notesRecyclerView); emptyState = FindViewById(Resource.Id.empty); if (notes.Count == 0) { ShowEmptyState(); } else { adapter = new NotesAdapter(notes); adapter.EditClicked += Adapter_EditClicked; adapter.ViewNoteClicked += ViewNoteClicked; adapter.DeleteClicked += DeleteClicked; recycler.SetLayoutManager(new LinearLayoutManager(this)); recycler.SetAdapter(adapter); recycler.SetItemAnimator(new DefaultItemAnimator()); } }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); notes = await DBAssist.DeserializeDBAsync <List <Note> >(notesdb); notes = notes ?? new List <Note>(); bookmarkedItems = await DBAssist.DeserializeDBAsync <List <Idea> >(bookmarksdb); bookmarkedItems = bookmarkedItems ?? new List <Idea>(); recycler = FindViewById <RecyclerView>(Resource.Id.notesRecyclerView); emptyState = FindViewById(Resource.Id.empty); if (notes.Count == 0) { ShowEmptyState(); } else { manager = new LinearLayoutManager(this); adapter = new NotesAdapter(notes); adapter.EditClicked += Adapter_EditClicked; adapter.ViewNoteClicked += (position) => { new AlertDialog.Builder(this) .SetTitle(notes[position].Name) .SetMessage(notes[position].Content) .SetPositiveButton("Great", (sender, e) => { return; }) .Create().Show(); }; adapter.DeleteClicked += (position) => { var foundIdea = Global.Categories.FirstOrDefault(x => x.CategoryLbl == notes[position].Category).Items.FirstOrDefault(y => y.Title == notes[position].Title); if (foundIdea != null) { foundIdea.Note = null; } var foundBookmark = bookmarkedItems.FirstOrDefault(x => x.Title == notes[position].Title); if (foundBookmark != null) { foundBookmark.Note = null; } notes.RemoveAt(position); adapter.NotifyItemRemoved(position); if (notes.Count == 0) { ShowEmptyState(); } }; recycler.SetAdapter(adapter); recycler.SetLayoutManager(manager); recycler.SetItemAnimator(new DefaultItemAnimator()); } }
//Инициализация всех полей private void Initialize() { //Поле вида растения typeName = FindViewById <EditText>(Resource.Id.editText1); //Поле сорта растения sortName = FindViewById <EditText>(Resource.Id.editText2); //Поле даты полива waterDate = FindViewById <EditText>(Resource.Id.editText3); //Поле периодичности полива waterPeriod = FindViewById <EditText>(Resource.Id.editText4); //Поле даты прополки weedDate = FindViewById <EditText>(Resource.Id.editText5); //Поле периодичности прополки weedPeriod = FindViewById <EditText>(Resource.Id.editText6); //Поле даты окучивания pileUpDate = FindViewById <EditText>(Resource.Id.editText7); //Поле периодичности окучивания pileUpPeriod = FindViewById <EditText>(Resource.Id.editText8); //Поле даты удобрения fertilizeDate = FindViewById <EditText>(Resource.Id.editText9); //Поле периодичности удобрения fertilizePeriod = FindViewById <EditText>(Resource.Id.editText10); bed = new GardenBed(new PlantType("Вид", "Сорт")); typeName.Text = bed.Plant.TypeName; sortName.Text = bed.Plant.SortName; //Полив waterDate.Text = bed.WaterDate.ToString("dd/MM/yyyy hh:mm"); waterPeriod.Text = bed.WaterPeriod.ToString(); //Прополка weedDate.Text = bed.WeedDate.ToString("dd/MM/yyyy hh:mm"); weedPeriod.Text = bed.WeedPeriod.ToString(); //Окучивание pileUpDate.Text = bed.PileUpDate.ToString("dd/MM/yyyy hh:mm"); pileUpPeriod.Text = bed.PileUpPeriod.ToString(); //Удобрение fertilizeDate.Text = bed.FertilizeDate.ToString("dd/MM/yyyy hh:mm"); fertilizePeriod.Text = bed.FertilizePeriod.ToString(); mRecyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView1); // Plug in the linear layout manager: mLayoutManager = new LinearLayoutManager(this); mRecyclerView.SetLayoutManager(mLayoutManager); // Plug in my adapter: mAdapter = new NotesAdapter(bed.Notes); mRecyclerView.SetAdapter(mAdapter); //Привязываю нажатия на элементы адаптера mAdapter.NoteChanged += OnNoteChanged; RegisterForContextMenu(mRecyclerView); }
protected override void Dispose(bool disposing) { if (this.disposed) { return; } if (!disposing) { return; } this.adapter?.Dispose(); this.adapter = null; base.Dispose(true); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); _noteRecyclerView = FindViewById <RecyclerView>(Resource.Id.notesRecyclerView); _notesLayoutManager = new LinearLayoutManager(this); //_pieLayoutManager = new GridLayoutManager(this, 2, GridLayoutManager.Horizontal, false); _noteRecyclerView.SetLayoutManager(_notesLayoutManager); _notesAdapter = new NotesAdapter(); _notesAdapter.ItemClick += Notes_ItemClick; _noteRecyclerView.SetAdapter(_notesAdapter); BottomNavigationView navigation = FindViewById <BottomNavigationView>(Resource.Id.navigation); navigation.SetOnNavigationItemSelectedListener(this); }
public NotesRepository(IProgressConnection connection) { this.adapter = new NotesAdapter(connection); this.Cono = this.adapter.Cono; this.OnCreated(); }