예제 #1
0
        public string UpdateCurrentPersonalSpec(PersonalSpec obj)
        {
            try
            {
                if (db_connection != null)
                {
                    // Only one row should contain isSpecCurrent as true. Old current should be made as false (if any).

                    PersonalSpec oldSpec = SelectCurrentPersonalSpec();
                    if (oldSpec != null)
                    {
                        oldSpec.isSpecCurrent = 0;
                        db_connection.Update(oldSpec);
                    }

                    return(db_connection.Insert(obj).ToString());
                }
                Log.Warn("DBServices", "DB connection does not exist");
                return("DB connection does not exist");
            }
            catch (SQLiteException ex)
            {
                Log.Warn("DBServices", ex.Message);
                return(ex.Message);
            }
        }
예제 #2
0
        public void updateWeight()
        {
            PersonalSpec spec = DBServices.Instance.SelectCurrentPersonalSpec();

            //todo - volume unit

            if (spec != null)
            {
                FindViewById <TextView>(Resource.Id.textView_TargetML).Text = ((int)(utils.calcWaterRequirement(spec.weight, (utils.Weight_Unit)spec.weight_unit, Pref_Volume_Unit, spec.exercise_duration))).ToString();
            }
            else
            {
                // all defaults
                FindViewById <TextView>(Resource.Id.textView_TargetML).Text = ((int)(utils.calcWaterRequirement(0.0, utils.Weight_Unit.Unit_Kg, Pref_Volume_Unit, 0))).ToString();
            }
        }
        public override Dialog OnCreateDialog(Bundle bundle)
        {
            AlertDialog.Builder builder = new AlertDialog.Builder(this.Activity);
            View view;

            LayoutInflater inflater = (LayoutInflater)this.Activity.GetSystemService(Context.LayoutInflaterService);

            view = inflater.Inflate(Resource.Layout.EditPersonalSpecModal, null);
            builder.SetView(view);

            view.FindViewById <ImageButton>(Resource.Id.EditPersonalSpecModal_OkBtn).Click   += onClickOk;
            view.FindViewById <ImageButton>(Resource.Id.EditPersonalSpecModal_UndoBtn).Click += onClickUndo;

            PersonalSpec spec = DBServices.Instance.SelectCurrentPersonalSpec();

            if (spec != null)
            {
                view.FindViewById <EditText>(Resource.Id.EditPersonalSpec_WeightInput).Text   = spec.weight.ToString();
                view.FindViewById <EditText>(Resource.Id.EditPersonalSpec_ExerciseInput).Text = spec.exercise_duration.ToString();

                curr_weight_unit = (utils.Weight_Unit)spec.weight_unit;
            }
            else
            {
                curr_weight_unit = utils.Weight_Unit.Unit_Kg;
            }

            ArrayAdapter adapter = ArrayAdapter.CreateFromResource(parent, Resource.Array.Weight_Units_String_Array, Resource.Drawable.units_spinner_item);

            adapter.SetDropDownViewResource(Resource.Drawable.units_spinner_dropdown_item);

            view.FindViewById <Spinner>(Resource.Id.EditPersonalSpec_textWeightUnitSpinner).Adapter       = adapter;
            view.FindViewById <Spinner>(Resource.Id.EditPersonalSpec_textWeightUnitSpinner).ItemSelected +=
                new EventHandler <AdapterView.ItemSelectedEventArgs>(onWeightUnitItemSelected);
            view.FindViewById <Spinner>(Resource.Id.EditPersonalSpec_textWeightUnitSpinner).SetSelection((int)curr_weight_unit, true);
            dialg = builder.Create();

            return(dialg);
        }