コード例 #1
0
        public override RecyclerView.ViewHolder OnCreateViewHolder(Android.Views.ViewGroup parent, int viewType)
        {
            View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.item_today_card, parent, false);

            var contactViewHolder = new ContactViewHolder(itemView);

            contactViewHolder.fab.Click += (sender, e) => {
                Entry t = contactViewHolder.entry;
                periodDeleteVM.SetSelected(t, false);
                contactViewHolder.fab.Visibility = ViewStates.Gone;
            };

            contactViewHolder.linearLayout.Click += (object sender, EventArgs e) => {
                Entry t = contactViewHolder.entry;
                if (periodDeleteVM.InDeleteMode)
                {
                    periodDeleteVM.SetSelected(t, !periodDeleteVM.IsSelected(t));
                    contactViewHolder.fab.Visibility = (periodDeleteVM.IsSelected(t)) ? ViewStates.Visible : ViewStates.Gone;
                }
                else
                {
                    Navigate.ToEntryDetail(t);
                }
            };

            //			//handle long click listener
            contactViewHolder.linearLayout.LongClick += (sender, e) => {
                Entry t = contactViewHolder.entry;
                periodDeleteVM.Period       = t.Period;
                periodDeleteVM.InDeleteMode = true;
                //itemLongClick.onItemLongClick(cardList.get(i).Text);
                periodDeleteVM.SetSelected(t, true);
                contactViewHolder.fab.Visibility = ViewStates.Visible;
                InputMethodManager imm = (InputMethodManager)context.GetSystemService(Context.InputMethodService);
                imm.HideSoftInputFromWindow((sender as View).WindowToken, 0);
            };

                        #if DEBUG
            AndroidDebug.SetViewBorders(itemView);
                        #endif

            return(contactViewHolder);
        }
コード例 #2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            Bundle   bundle = this.Arguments;
            DateTime date   = Arguments.GetString("date").ToDateTime();

            Period = (Period)Enum.Parse(typeof(Period), Arguments.GetString("period"));
            view   = inflater.Inflate(Resource.Layout.fragment_today_card, container, false);
            vm     = new PeriodVM(date, Period, true);

            var binding = DataContext <PeriodVM> .FromView(view);

            binding.VM = vm;

            if (binding.Bindings.Count == 0)
            {
                binding.Add(Resource.Id.layout_time_calories, x => x.TimeOrTotalVisibility);
                binding.Add(Resource.Id.text_totalCalories1, x => x.TotalVisibility);
                binding.Add(Resource.Id.text_totalCalories2, x => x.TotalVisibility);
                binding.Add(Resource.Id.text_totalCalories1, x => x.TotalText);
                binding.Add(Resource.Id.text_totalCalories2, x => x.TotalValue);
                binding.Add(Resource.Id.button_pick_time, x => x.Time);
                binding.Add(Resource.Id.button_pick_time, x => x.TimeVisibility);
                binding.Add(Resource.Id.button_pick_time, (x) =>
                {
                    DateTime current;
                    if (!DateTime.TryParse(x.Time, out current))
                    {
                        current = DateTime.Now;
                    }
                    var tpd = new Android.App.TimePickerDialog(Activity,
                                                               (s, e) => { x.Time = DateTime.Now.SetTime(e.HourOfDay, e.Minute, 0).ToShortTimeString(); }
                                                               , current.Hour, current.Minute, true);
                    tpd.Show();
                });
                binding.Add(Resource.Id.editText_Notes, x => x.Note);
                binding.Add(Resource.Id.layout_notes, x => x.NoteVisibility);
                binding.Add(Resource.Id.btn_delete, x => { x.Note = null; });
            }

            recycler                 = view.FindViewById <RecyclerView>(Resource.Id.recycler);
            editText                 = view.FindViewById <EditText>(Resource.Id.editText_Notes);
            advertisement            = view.FindViewById <LinearLayout>(Resource.Id.advertisement);
            linearLayoutTimeCalories = view.FindViewById <LinearLayout>(Resource.Id.layout_time_calories);
            editNotes                = view.FindViewById <LinearLayout>(Resource.Id.inputNotes);
            ImageView cross = view.FindViewById <ImageView>(Resource.Id.btn_delete);

            textTotalCalories   = view.FindViewById <TextView>(Resource.Id.text_totalCalories);
            buttonSetTime       = view.FindViewById <Button>(Resource.Id.button_pick_time);
            textNotes           = view.FindViewById <TextView>(Resource.Id.text_today_notes);
            layoutNotesSection  = view.FindViewById <LinearLayout>(Resource.Id.layout_note_section);
            emptyScreenImage    = view.FindViewById <ImageView>(Resource.Id.empty_screen);
            getStarted          = view.FindViewById <TextView>(Resource.Id.get_started);
            getStartedText      = view.FindViewById <TextView>(Resource.Id.get_started_text);
            text_totalCalories2 = view.FindViewById <TextView>(Resource.Id.text_totalCalories2);
            UpdateEmptyVisibility();

            cross.Click += async delegate
            {
                Android.Views.InputMethods.InputMethodManager inputManager = (Android.Views.InputMethods.InputMethodManager)inflater.Context.GetSystemService(Context.InputMethodService);
                inputManager.HideSoftInputFromWindow(cross.WindowToken, 0);
            };
            setupRecycler();

            this.HasOptionsMenu = true;

#if DEBUG
            AndroidDebug.SetViewBorders(view);
#endif


            return(view);
        }