Example #1
0
        private async void BletoothRM_clicked(object sender, EventArgs e)
        {
            activityIndicator.IsRunning = true;

            try
            {
                //await BletoothRM.ScaleTo(0.9, 1500, Easing.Linear);
                string LastDevices = Settings.LastUsedDevices;

                string Get = "";
                try
                {
                    Get = GETApi("api/web/ok/1");
                }
                catch
                {
                    label1.Text = "Server is not available. Check your Internet connection,";
                    activityIndicator.IsRunning = false;
                }
                if (Get == "\"Oks\"")
                {
                    //await BletoothRM.ScaleTo(1, 2000, Easing.Linear);
                    if (LastDevices == null)
                    {
                        activityIndicator.IsRunning = false;
                        await  DisplayAlert("Device error", "Check the device number in 'Settings'", "Ok");

                        return;
                    }
                    string            json13  = GETApi("api/params/paraparams?id=" + LastDevices + "&simbol=1&ugo=ugo");
                    AverageJsonParams JParams = JsonConvert.DeserializeObject <AverageJsonParams>(json13);
                    AvSpeed.Text = JParams.AverageSpeed.ToString();
                    AvCal.Text   = JParams.TotalDistance.ToString();
                    AvDis.Text   = JParams.TotalCalories.ToString();
                    await stackLayout3.FadeTo(0, 1000);

                    stackLayout3.IsVisible = false;
                    await StartRM.FadeTo(1, 1000);

                    DatePicker1.IsEnabled       = true;
                    activityIndicator.IsRunning = false;
                }
                else
                {
                    await DisplayAlert("Error", "Server is not available. Check your Internet connection", "Ok");
                }
                activityIndicator.IsRunning = false;
            }
            catch
            {
                await DisplayAlert("Device error", "Check the device number in 'Settings'", "Ok");

                activityIndicator.IsRunning = false;
            }
        }
Example #2
0
        private async void ApiConnect(string LastDevices, string date, int destin)
        {
            try
            {
                if (destin == 0)
                {
                    string            json4Date = GETApi("api/params/paraparams?id=" + LastDevices + "&simbol=2&ugo=" + date);
                    AverageJsonParams JParamss  = JsonConvert.DeserializeObject <AverageJsonParams>(json4Date);
                    AvDateSp.Text   = JParamss.AverageSpeed.ToString();
                    AvDateDist.Text = JParamss.TotalDistance.ToString();
                    AvDateCal.Text  = JParamss.TotalCalories.ToString();
                }
            }
            catch
            {
                await DisplayAlert("Error", "No data found for this date", "Ok");
            }
            while (StopRM.IsVisible == true)
            {
                try
                {
                    if (destin != 0)
                    {
                        string     json    = GETApi("api/params/paraparams?id=" + LastDevices + "&simbol=0&ugo=ugo");
                        JsonParams JParams = JsonConvert.DeserializeObject <JsonParams>(json);
                        LSpeed.Text    = JParams.Speed.ToString();
                        LDistance.Text = JParams.Distance.ToString();
                        LCalories.Text = JParams.Сalories.ToString();

                        string json4Average = GETApi("api/params/paraparams?id=" + LastDevices + "&simbol=1&ugo=ugo");

                        AverageJsonParams JParamss = JsonConvert.DeserializeObject <AverageJsonParams>(json4Average);
                        AvSpeed.Text = JParamss.AverageSpeed.ToString();
                        AvCal.Text   = JParamss.TotalDistance.ToString();
                        AvDis.Text   = JParamss.TotalCalories.ToString();
                    }


                    int i = rnd.Next(1, 3);
                    if (i == 1)
                    {
                        await StopRM.RotateTo(720, 4000, Easing.CubicInOut);

                        await StopRM.RotateTo(0, 0);
                    }
                    if (i == 2)
                    {
                        await StopRM.RotateTo(1080, 6000, Easing.CubicInOut);

                        await StopRM.RotateTo(0, 0);
                    }
                }
                catch
                {
                    StopRM.IsVisible  = false;
                    StartRM.IsVisible = true;
                    await DisplayAlert("Server is not available", "Check your Internet connection", "Ok");

                    break;
                }
            }
        }