Exemple #1
0
        private void exercise_AddClick(object sender, int position)
        {
            //save new log
            if (LogManager.AddExerciseForToday(_exercises[position]))
            {
                Toast.MakeText(this, _exercises[position].Name + " has been added", ToastLength.Short).Show();
            }
            else
            {
                Toast.MakeText(this, _exercises[position].Name + " already in list", ToastLength.Short).Show();
            }

            var intent = new Intent(this, typeof(Activities.ExerciseDetailActivity));

            intent.PutExtra(ParamKeys.EXERCISE_ID, _exercises[position].Id.Value);
            StartActivity(intent);
            Finish();
        }
Exemple #2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.fragment_add_log, container, false);

            _exercise = ExerciseManager.GetExerciseById(Arguments.GetInt(ParamKeys.EXERCISE_ID));
            var log = _exercise.TodaysLog;

            if (log != null)
            {
                LogManager.AddExerciseForToday(_exercise);
                log = _exercise.TodaysLog;
            }


            /*bind log list*/
            var listViewLogs = view.FindViewById <ListView>(Resource.Id.listViewLogs);

            log.AddNewSetIfEmpty();
            _addLogListAdapter   = new AddSetAdapter(base.Activity, log.Sets);
            listViewLogs.Adapter = _addLogListAdapter;

            /*remove set button click */
            _addLogListAdapter.RemoveSetClick += (s, position) =>
            {
                if (log.Sets.Count > position)
                {
                    log.DeleteSet(position);
                    _addLogListAdapter.NotifyDataSetChanged();
                }
            };


            /*bind Plus button*/
            var fab = view.FindViewById <FloatingActionButton>(Resource.Id.fab);

            fab.Click += (sender, args) =>
            {
                log.AddNewSet();
                _addLogListAdapter.NotifyDataSetChanged();
            };

            return(view);
        }