Exemple #1
0
 public void activityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
 {
     if (resultCode == Result.Ok)
     {
         var tmp = new Perscription[((MainActivity)Activity).GetPerscriptSize()];
         Array.Copy(((MainActivity)Activity).getPerscript(), tmp, tmp.Length);
         perscription = new PerscriptionListing(tmp);
         mAdapter     = new PerscriptionsAdapter(perscription);
         _recycler.SetAdapter(mAdapter);
         mAdapter.NotifyDataSetChanged();
     }
 }
        private void addPerscription(string v)
        {
            PerscriptionDeseriaized deserialized = JsonConvert.DeserializeObject <PerscriptionDeseriaized>(v);

            int idForm = 0;
            int idTake = 0;

            switch (deserialized.form)
            {
            case "Pill":
                idForm = Resource.Drawable.pills;
                break;

            case "Capsule":
                idForm = Resource.Drawable.capsule;
                break;

            case "Patch":
                idForm = Resource.Drawable.patch;
                break;

            case "Liquid":
                idForm = Resource.Drawable.liquid;
                break;

            case "Injection":
                idForm = Resource.Drawable.needle;
                break;
            }

            switch (deserialized.takeWith)
            {
            case "None":
                idTake = Resource.Drawable.none;
                break;

            case "Food":
                idTake = Resource.Drawable.food;
                break;

            case "Drink":
                idTake = Resource.Drawable.water;
                break;

            case "Food and Drink":
                idTake = Resource.Drawable.foodwater;
                break;
            }

            Perscription newP = new Perscription
            {
                _formID       = idForm,
                _perscription = deserialized.medication,
                _dosage       = deserialized.dosage,
                _takeID       = idTake,
                _interval     = deserialized.interval,
                _start        = deserialized.startDate,
                _end          = deserialized.endDate,
                _schedule     = new List <string>(deserialized.intervals)
            };

            if (Perscript.Length == endposPerscript)
            {
                var arr = Perscript;
                Array.Resize(ref arr, arr.Length + 20);
                Perscript = arr;
            }
            Perscript[endposPerscript] = newP;
            ++endposPerscript;
        }