public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var view = inflater.Inflate(Resource.Layout.checklist_fragment, null); checklist1Button = view.FindViewById <Button>(Resource.Id.checklist1Button); checklist2Button = view.FindViewById <Button>(Resource.Id.checklist2Button); checklist3Button = view.FindViewById <Button>(Resource.Id.checklist3Button); checklist4Button = view.FindViewById <Button>(Resource.Id.checklist4Button); checklist5Button = view.FindViewById <Button>(Resource.Id.checklist5Button); addFloatingActionButton = view.FindViewById <FloatingActionButton>(Resource.Id.addFloatingActionButton); checklist1Button.Click += async(s, e) => { fragmentDefconStatus = 1; SetButtonColors(1); await ReloadCheckList(1); }; checklist2Button.Click += async(s, e) => { fragmentDefconStatus = 2; SetButtonColors(2); await ReloadCheckList(2); }; checklist3Button.Click += async(s, e) => { fragmentDefconStatus = 3; SetButtonColors(3); await ReloadCheckList(3); }; checklist4Button.Click += async(s, e) => { fragmentDefconStatus = 4; SetButtonColors(4); await ReloadCheckList(4); }; checklist5Button.Click += async(s, e) => { fragmentDefconStatus = 5; SetButtonColors(5); await ReloadCheckList(5); }; addFloatingActionButton.Click += async(s, e) => { _onCreateView.PerformHapticFeedback(FeedbackConstants.VirtualKey, FeedbackFlags.IgnoreGlobalSetting); var checkListEntry = new CheckListEntry() { DefconStatus = fragmentDefconStatus, UnixTimeStampCreated = DateTimeOffset.Now.ToUnixTimeMilliseconds(), FontSize = 26 }; _checkList.Add(checkListEntry); await _sqLiteAsyncConnection.InsertAsync(checkListEntry); _checklistRecyclerViewAdapter.NotifyDataSetChanged(); await SetCounter(); }; itemsCounter1 = view.FindViewById <TextView>(Resource.Id.counterOne); itemsCounter2 = view.FindViewById <TextView>(Resource.Id.counterTwo); itemsCounter3 = view.FindViewById <TextView>(Resource.Id.counterThree); itemsCounter4 = view.FindViewById <TextView>(Resource.Id.counterFour); itemsCounter5 = view.FindViewById <TextView>(Resource.Id.counterFife); _onCreateView = view; return(view); }
public override void OnResume() { base.OnResume(); if (_checklistRecyclerViewAdapter != null && _recyclerView != null) { _recyclerView.GetLayoutManager().ScrollToPosition(_checklistRecyclerViewAdapter.ItemCount); } else { try { _checklistRecyclerViewAdapter = new ChecklistRecyclerViewAdapter(_checkList); _recyclerView.SetAdapter(_checklistRecyclerViewAdapter); _checklistRecyclerViewAdapter.NotifyDataSetChanged(); } catch (Exception) { } } }