コード例 #1
0
ファイル: LoginPage.cs プロジェクト: Nahums0/caller-id
        }                 // Login button handler

        public void BtnRegister_Click(object sender, EventArgs e)
        {
            //TODO: Add sms auth
            var LoadPanel = FindViewById(Resource.Id.LoginPageloadingPanel);

            LoadPanel.Visibility = Android.Views.ViewStates.Visible;
            FindViewById <ProgressBar>(Resource.Id.LoginPageSpinner).IndeterminateDrawable.SetColorFilter(new Android.Graphics.Color(255, 255, 255), Android.Graphics.PorterDuff.Mode.Multiply);
            Context context = this;
            var     t       = Task.Run(async() =>
            {
                string Phonenumber = etPhoneNumber.Text;
                if (Phonenumber == "" || !ValidateNumber(Phonenumber))
                {
                    RunOnUiThread(() =>
                    {
                        Toast.MakeText(this, "Enter A Valid Phone Number", ToastLength.Short).Show();
                        LoadPanel.Visibility = Android.Views.ViewStates.Gone;
                    });
                    return;
                }

                var content = await RestQueries.PostUser(context, Phonenumber);

                if (content == "-1")
                {
                    RunOnUiThread(() =>
                    {
                        Toast.MakeText(this, "Access Denied", ToastLength.Long).Show();
                        LoadPanel.Visibility = Android.Views.ViewStates.Gone;
                    });
                    return;
                }

                var responsedata = RestQueries.Authenticate(Phonenumber);
                if (responsedata.Logged)
                {
                    SaveCurrentUser(Phonenumber, responsedata.Data);
                    ProceedToMainActivity(Phonenumber, responsedata.Data);
                }
                else
                {
                    RunOnUiThread(() =>
                    {
                        Toast.MakeText(this, "An Error Has Accured Please Try Again Later", ToastLength.Long).Show();
                        LoadPanel.Visibility = Android.Views.ViewStates.Gone;
                    });
                }
            });
        }        // Register button handler
コード例 #2
0
ファイル: MainActivity.cs プロジェクト: Nahums0/caller-id
 private async void PostUser()
 {
     await RestQueries.PostUser(this, Intent.GetStringExtra("PhoneNumber"));
 }