Exemple #1
0
        public static void MsgBox(Context context,
			string msg, 
			string Titolo = "Vegetha", 
			string PositiveText = "OK", 
			Action PositiveAction = null, 
			string NegativeText ="",
			Action NegativeAction = null)
        {
            AlertDialog.Builder d = new AlertDialog.Builder (context);
            d.SetTitle(Titolo);
            d.SetMessage (msg);
            if (PositiveAction != null) {
                d.SetPositiveButton (PositiveText, (sender, e) => {
                    PositiveAction.Invoke();
                });
            } else {
                d.SetPositiveButton (PositiveText, (sender, e) => {

                });
            }

            if (NegativeAction != null) {
                d.SetNegativeButton (NegativeText, (sender, e) => {
                    NegativeAction.Invoke ();
                });
            }
            d.Show ();
        }
Exemple #2
0
        public static void Alert(Activity context, string title, string message, bool CancelButton, Action<Result> callback = null)
        {
            context.RunOnUiThread(() =>
            {
                AlertDialog.Builder builder = new AlertDialog.Builder(context);
                builder.SetTitle(title);
                builder.SetMessage(message);

                if (callback != null)
                {
                    builder.SetPositiveButton("Ok", (sender, e) =>
                    {
                        callback(Result.Ok);
                    });

                    if (CancelButton)
                    {
                        builder.SetNegativeButton("Cancel", (sender, e) =>
                        {
                            callback(Result.Canceled);
                        });
                    }
                }
                else
                {
                    builder.SetPositiveButton("OK", (sender, e) => { });
                }

                builder.Show();
            });
        }
Exemple #3
0
        public static void AlertYesOrNo(Activity context, string title, string message, Action<Result> callback)
        {
            AlertDialog.Builder builder = new AlertDialog.Builder(context);
            builder.SetTitle(title);
            builder.SetMessage(message);

            if (callback != null)
            {
                builder.SetPositiveButton("Yes", (sender, e) =>
                {
                    callback(Result.Ok);
                });

                builder.SetNegativeButton("No", (sender, e) =>
                {
                    callback(Result.Canceled);
                });
            }
            else
            {
                builder.SetPositiveButton("OK", (sender, e) => { });
            }

            builder.Show();
        }
		/**
	     * Show End User License Agreement.
	     *
	     * @param accepted True IFF user has accepted license already, which means it can be dismissed.
	     *                 If the user hasn't accepted, then the EULA must be accepted or the program
	     *                 exits.
	     * @param activity Activity started from.
	     */
		public static void ShowEula(bool accepted, Activity activity)
		{
			AlertDialog.Builder eula = new AlertDialog.Builder(activity)
				.SetTitle(Resource.String.eula_title)
				.SetIcon(Android.Resource.Drawable.IcDialogInfo)
				.SetMessage(Resource.String.eula_text)
				.SetCancelable(accepted);
			
			if (accepted) 
			{
				eula.SetPositiveButton(Android.Resource.String.Ok, (object dialog, DialogClickEventArgs which) => {
					(dialog as IDialogInterface).Dismiss();	
				});
			} else {
				eula.SetPositiveButton(Resource.String.accept,(object dialog, DialogClickEventArgs which) => {
					SetAcceptedEula(activity);
					(dialog as IDialogInterface).Dismiss();
				})
				.SetNegativeButton(Resource.String.decline, (object dialog, DialogClickEventArgs which) => { 
					(dialog as IDialogInterface).Cancel();
					activity.Finish();
				});
			}
			eula.Show();
		}
 void GetInfo()
 {
     // создаем xml-документ
     XmlDocument xmlDocument = new XmlDocument ();
     // делаем запрос на получение имени пользователя
     WebRequest webRequest = WebRequest.Create ("https://api.vk.com/method/users.get.xml?&access_token=" + token);
     WebResponse webResponse = webRequest.GetResponse ();
     Stream stream = webResponse.GetResponseStream ();
     xmlDocument.Load (stream);
     string name =  xmlDocument.SelectSingleNode ("response/user/first_name").InnerText;
     // делаем запрос на проверку,
     webRequest = WebRequest.Create ("https://api.vk.com/method/groups.isMember.xml?group_id=20629724&access_token=" + token);
     webResponse = webRequest.GetResponse ();
     stream = webResponse.GetResponseStream ();
     xmlDocument.Load (stream);
     bool habrvk = (xmlDocument.SelectSingleNode ("response").InnerText =="1");
     // выводим диалоговое окно
     var builder = new AlertDialog.Builder (this);
     // пользователь состоит в группе "хабрахабр"?
     if (!habrvk) {
         builder.SetMessage ("Привет, "+name+"!\r\n\r\nТы не состоишь в группе habrahabr.Не хочешь вступить?");
         builder.SetPositiveButton ("Да", (o, e) => {
             // уточнив, что пользователь желает вступить, отправим запрос
             webRequest = WebRequest.Create ("https://api.vk.com/method/groups.join.xml?group_id=20629724&access_token=" + token);
              webResponse = webRequest.GetResponse ();
         });
         builder.SetNegativeButton ("Нет", (o, e) => {
         });
     } else {
         builder.SetMessage ("Привет, "+name+"!\r\n\r\nОтлично! Ты состоишь в группе habrahabr.");
         builder.SetPositiveButton ("Ок", (o, e) => {
         });
     }
     builder.Create().Show();
 }
        public async void ForgotPassword(View view)
        {
            ProgressDialog dialog = DialogHelper.CreateProgressDialog("Please wait...", this);
            dialog.Show();

            EditText StudentId = FindViewById<EditText>(Resource.Id.forgotStudentId);
            AuthService ForgotPasswordService = new AuthService();
            GenericResponse Response = await ForgotPasswordService.ForgotPassword(StudentId.Text);
            dialog.Hide();

            if (Response.Success)
            {

                AlertDialog.Builder builder = new AlertDialog.Builder(this, Resource.Style.LightDialog);
                builder.SetTitle("Password Reset Sent");
                builder.SetMessage("Please check your emails to reset your password");
                builder.SetCancelable(false);
                builder.SetPositiveButton("OK", delegate { Finish(); });
                builder.Show();
            }
            else
            {
                DialogHelper.ShowDialog(this, Response.Message, Response.Title);
            }
        }
		protected override async void OnResume()
		{
			base.OnResume ();

			Title = DataHolder.Current.CurrentCity.Name;

			// Load pollutions
			pollutionService = new PollutionService(Settings.ApiBaseUrl);
			var pollutions = await pollutionService.GetPollutionForCity(DataHolder.Current.CurrentCity.Zip);
			if (pollutions == null) 
			{
				// An error occured
				var builder = new AlertDialog.Builder(this);
				builder.SetTitle(GetString(Resource.String.error_header));
				builder.SetMessage(GetString(Resource.String.pollution_error_body));
				builder.SetPositiveButton (GetString (Android.Resource.String.Ok), (senderAlert, args) => {});
				builder.Show();
			} else {
				DataHolder.Current.CurrentPollutions = pollutions;
			}				

			// Initialize tabs
			AddPollutionDayTab(Resources.GetString(Resource.String.tab_today), 0);
			AddPollutionDayTab(Resources.GetString(Resource.String.tab_tomorrow), 1);
			AddPollutionDayTab(Resources.GetString(Resource.String.tab_aftertomorrow), 2);

			// Hide loading indicator
			var loading = FindViewById<ProgressBar> (Resource.Id.pbLoading);
			loading.Visibility = ViewStates.Gone;
		}
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
			SetContentView (Resource.Layout.Splash);
			new Handler ().PostDelayed (() => {
				//LoadActivity();
				var updateManager = new UpdateManager(this,true);
				if (updateManager.CheckUpdate())
				{
					var builder = new AlertDialog.Builder (this).SetTitle ("软件升级").SetMessage ("发现新版本,建议更新使用新版本").SetOnKeyListener(this).SetCancelable(false);
					builder.SetPositiveButton ("下载", (sender, e) => {
						noticeDialog.Dismiss();	
						//显示下载对话框,下载
						updateManager.ShowDownloadDialog();
					});
					builder.SetNegativeButton ("以后再说", (sender, e) => {
						noticeDialog.Dismiss();	
						LoadActivity();
					});
					noticeDialog= builder.Create ();
					noticeDialog.Show();
				}
				else
				{
					LoadActivity();
				}
			},2000);
		
			// Create your application here
		}
		protected void CreateChatRooms(){
			chatroomsAdapter = new ChatRoomsAdapter (this);
			var chatRoomsListView = FindViewById<ListView> (Resource.Id.chatroomsListView);
			chatRoomsListView.Adapter = chatroomsAdapter;
			chatRoomsListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => {
				ChatRoom currChatRoom = chatroomsAdapter.GetChatRoomAt(e.Position);
				var intent = new Intent(this, typeof(ChatRoomActivity));
				intent.PutExtra("chatroom", currChatRoom.webID);
				StartActivity(intent);
			};
			chatRoomsListView.ItemLongClick += async (object sender, AdapterView.ItemLongClickEventArgs e) => {
				AlertDialog.Builder alert = new AlertDialog.Builder(this);
				alert.SetTitle("Do you want to delete this chatroom?");
				alert.SetPositiveButton("Yes", (senderAlert, args) => {
					ChatRoom currChatRoom = chatroomsAdapter.GetChatRoomAt(e.Position);
					ParsePush.UnsubscribeAsync (currChatRoom.webID);
					ChatRoomUser cru = DatabaseAccessors.ChatRoomDatabaseAccessor.DeleteChatRoomUser(DatabaseAccessors.CurrentUser().webID, currChatRoom.webID);
					DatabaseAccessors.ChatRoomDatabaseAccessor.DeleteChatRoom(currChatRoom.webID);
					ParseChatRoomDatabase pcrd = new ParseChatRoomDatabase();
					pcrd.DeleteChatRoomUserAsync(cru);
					Console.WriteLine("ERASED");
					chatroomsAdapter.NotifyDataSetChanged();

				});
				alert.SetNegativeButton("No", (senderAlert, args) => {
				});	
				alert.Show();
			};
		}
Exemple #10
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            String extra = Intent.GetStringExtra("User") ?? "Data not available";

            var builder = new AlertDialog.Builder(this);
            builder.SetTitle("Logged in");
            builder.SetMessage(extra);
            builder.SetPositiveButton("Ok", delegate { Finish(); });
            builder.Create().Show();

            // Create your application here
            SetContentView(Resource.Layout.Home);

            TextView textView = FindViewById<TextView>(Resource.Id.textView_Username);
            textView.Text = extra;

            Button goToBogdan = FindViewById<Button>(Resource.Id.button_Veres);
            Button goToMiki = FindViewById<Button>(Resource.Id.button_Miki);

            goToBogdan.Click += (sender, args) =>
            {
                var bogdan = new Intent(this, typeof(Bogdan));
                StartActivity(bogdan);
            };

            goToMiki.Click += (sender, args) =>
            {
                var miki = new Intent(this, typeof(Miki));
                StartActivity(miki);
            };
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button> (Resource.Id.loginButton);

            button.Click += delegate {
                //set alert for executing the task
                var alert = new AlertDialog.Builder (this);

                alert.SetTitle ("Login Popup");

                alert.SetPositiveButton ("OK", (senderAlert, args) => {

                });

                alert.SetMessage ("Logged In");

                //run the alert in UI thread to display in the screen
                RunOnUiThread (() => {
                    alert.Show ();
                });
            };
        }
Exemple #12
0
        public bool showConfirmDialog(Context context, string info)
        {
            if (!prepareModal())
                return false;
            // reset choice
            mChoice = false;

            AlertDialog.Builder builder = new AlertDialog.Builder(context);
            builder.SetMessage(info);
            builder.SetCancelable(false);
            builder.SetPositiveButton("OK", (object o, Android.Content.DialogClickEventArgs e) =>
                {
                    this.mQuitModal = true;
                    this.mChoice = true;
                    builder.Dispose();
                });

            builder.SetNegativeButton("Cancel", (object o, Android.Content.DialogClickEventArgs e) =>
                {
                    mQuitModal = true;
                    mChoice = false;
                    builder.Dispose(); // probably wrong
                });

            AlertDialog alert = builder.Create();
            alert.Show();

            doModal();
            return mChoice;
        }
		private void initListeners()
		{
			create.Click += delegate 
			{
				if(!validdateForm()) return;
				create.Enabled = false;
				var task = Task<TournamentModel>.Factory.StartNew(() => ServerData.createTournament(name.Text, Session.Instance().CurrentUser.Id));
				task.ContinueWith(x =>     
				{
					create.Enabled = true;
					try 
					{
						if (x.Exception != null) throw x.Exception.InnerException;
						// Success
						Session.Instance().selectedTournament = task.Result;
						StartActivity(typeof(TournamentDetails));
						Finish();
					}
					catch (WebException e)
					{
						var builder = new AlertDialog.Builder(this);
						builder.SetMessage("Er is iets mis met de verbinding, probeer het later opnieuw.");
						builder.SetCancelable(false);
						builder.SetPositiveButton("OK", delegate { });
						builder.Show();
					}
				},
				TaskScheduler.FromCurrentSynchronizationContext());
			};
		}
Exemple #14
0
        public async void Register(View view)
        {
            ProgressDialog dialog = DialogHelper.CreateProgressDialog("Registering...", this);
            dialog.Show();

            RegisterRequest request = new RegisterRequest
            {
                FirstName = FindViewById<EditText>(Resource.Id.registerFirstName).Text,
                LastName = FindViewById<EditText>(Resource.Id.registerLastName).Text,
                StudentId = FindViewById<EditText>(Resource.Id.registerStudentId).Text,
                Password = FindViewById<EditText>(Resource.Id.registerPassword).Text
            };
            
            GenericResponse Response = await Services.Auth.Register(request);
            dialog.Hide();

            if (Response.Success)
            {
                AlertDialog.Builder builder = new AlertDialog.Builder(this, Resource.Style.LightDialog);
                builder.SetTitle("Successfully Registered");
                builder.SetMessage("Please check your UTS email for instructions to confirm your account");
                builder.SetCancelable(false);
                builder.SetPositiveButton("OK", delegate { Finish(); });
                builder.Show();
            }
            else
            {
                DialogHelper.ShowDialog(this, Response.Message, Response.Title);
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

#if __ANDROID_14__
            Window.RequestFeature(WindowFeatures.ActionBar);
            ActionBar.SetDisplayHomeAsUpEnabled(ViewModel.CanGoBack);
#endif

            SetContentView(Resource.Layout.identityproviderlistview);

            _loadingToken = ViewModel.WeakSubscribe(() => ViewModel.LoadingIdentityProviders, (sender, args) =>
            {
                if (ViewModel.LoadingIdentityProviders)
                    LoadingDialog.Show();
                else
                    LoadingDialog.Dismiss();

                InvalidateOptionsMenu();
            });

            ViewModel.LoginError += (sender, args) =>
            {
                var builder = new AlertDialog.Builder(this);
                builder.SetTitle("Error");
                builder.SetIcon(Android.Resource.Drawable.IcDialogAlert);
                builder.SetMessage(args.Message);
                builder.SetPositiveButton("Dismiss", (s, e) => { });
                builder.Create().Show();
            };
        }
Exemple #16
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Resource.Id.mmenu_back:
                BackupDatabase ();
                return true;
            case Resource.Id.mmenu_downdb:
                var builderd = new AlertDialog.Builder(this);
                builderd.SetMessage("Confirm to download database from server ? All local data will be overwritten by the downloaded data.");
                builderd.SetPositiveButton("OK", (s, e) => { DownlooadDb ();;});
                builderd.SetNegativeButton("Cancel", (s, e) => { /* do something on Cancel click */ });
                builderd.Create().Show();
                return true;
            //			case Resource.Id.mmenu_Reset:
            //				//do something
            //				return true;
            case Resource.Id.mmenu_setting:
                StartActivity (typeof(SettingActivity));
                return true;
            case Resource.Id.mmenu_logoff:
                RunOnUiThread(() =>ExitAndLogOff()) ;
                return true;
            case Resource.Id.mmenu_downcompinfo:
                DownloadCompInfo ();
                return true;
            case Resource.Id.mmenu_clear:
                ClearPostedInv ();
                return true;
            }

            return base.OnOptionsItemSelected(item);
        }
Exemple #17
0
        public static AlertDialog ShowQuestion(this Activity activity, string title, string message, string positiveButton, string negativeButton, Action positive, Action negative)
        {
            AlertDialog dialog = null;

            var builder = new AlertDialog.Builder(activity);
            builder.SetTitle(title);
            builder.SetMessage(message);
            builder.SetPositiveButton(positiveButton, (s, e) =>
            {
                dialog.Cancel();
                dialog.Dismiss();

                if (positive != null)
                    positive();
            });

            builder.SetNegativeButton(negativeButton, (s, e) =>
            {
                dialog.Cancel();
                dialog.Dismiss();

                if (negative != null)
                    negative();
            });

            dialog = builder.Show();

            return dialog;
        }
 public override Dialog OnCreateDialog(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     // Begin building a new dialog.
     var builder = new AlertDialog.Builder(Activity);
     //Get the layout inflater
     var inflater = Activity.LayoutInflater;
     populate (listData);
     viewdlg = SetViewDelegate;
     var view = inflater.Inflate(Resource.Layout.ListCustView, null);
     listView = view.FindViewById<ListView> (Resource.Id.CustList);
     if (listView != null) {
         adapter = new GenericListAdapter<Trader> (this.Activity, listData,Resource.Layout.ListCustDtlView, viewdlg);
         listView.Adapter = adapter;
         listView.ItemClick += ListView_Click;
         txtSearch= view.FindViewById<EditText > (Resource.Id.txtSearch);
         butSearch= view.FindViewById<Button> (Resource.Id.butCustBack);
         butSearch.Text = "SEARCH";
         butSearch.SetCompoundDrawables (null, null, null, null);
         butSearch.Click+= ButSearch_Click;
         //txtSearch.TextChanged += TxtSearch_TextChanged;
         builder.SetView (view);
         builder.SetPositiveButton ("CANCEL", HandlePositiveButtonClick);
     }
     var dialog = builder.Create();
     //Now return the constructed dialog to the calling activity
     return dialog;
 }
        public void AskForString(string message, string title, System.Action<string> returnString)
        {
            var activity = Mvx.Resolve<IMvxAndroidCurrentTopActivity> ().Activity;
            var builder = new AlertDialog.Builder(activity);
            builder.SetIcon(Resource.Drawable.ic_launcher);
            builder.SetTitle(title ?? string.Empty);
            builder.SetMessage(message);
            var view = View.Inflate(activity, Resource.Layout.dialog_add_member, null);
            builder.SetView(view);

            var textBoxName = view.FindViewById<EditText>(Resource.Id.name);

            builder.SetCancelable(true);
            builder.SetNegativeButton(Resource.String.cancel, delegate { });//do nothign on cancel

            builder.SetPositiveButton(Resource.String.ok, delegate
                {

                    if (string.IsNullOrWhiteSpace(textBoxName.Text))
                        return;

                returnString(textBoxName.Text.Trim());
                });

            var alertDialog = builder.Create();
            alertDialog.Show();
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.identityproviderlistview);

            _loadingToken = ViewModel.WeakSubscribe(() => ViewModel.LoadingIdentityProviders, (sender, args) =>
            {
                if (ViewModel.LoadingIdentityProviders)
                    LoadingDialog.Show();
                else
                    LoadingDialog.Dismiss();

                InvalidateOptionsMenu();
            });

            ViewModel.LoginError += (sender, args) =>
            {
                var builder = new AlertDialog.Builder(this);
                builder.SetTitle("Error");
                builder.SetIcon(Android.Resource.Drawable.IcDialogAlert);
                builder.SetMessage(args.Message);
                builder.SetPositiveButton("Dismiss", (s, e) => { });
                builder.Create().Show();
            };
        }
        public override Dialog OnCreateDialog(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Build Set Meals Dialog
            var builder = new AlertDialog.Builder(Activity);

            // Get Layout Inflater
            var inflator = Activity.LayoutInflater;

            // Inflate Layout For Password Dialog
            var dialogView = inflator.Inflate(Resource.Layout.SetMealsDialogFragment, null);

            // Initialize Properties
            breakfastEditText = dialogView.FindViewById<EditText>(Resource.Id.editTextBreakfast);
            lunchEditText = dialogView.FindViewById<EditText>(Resource.Id.editTextLunch);
            dinnerEditText = dialogView.FindViewById<EditText>(Resource.Id.editTextDinner);

            // Set Text To Current Meal Values
            breakfastEditText.Text = MealItem.Breakfast;
            lunchEditText.Text = MealItem.Lunch;
            dinnerEditText.Text = MealItem.Dinner;

            // Set Positive & Negative Buttons
            builder.SetView(dialogView);
            builder.SetPositiveButton("Set Meals", HandlePositiveButtonClick);
            // builder.SetNeutralButton("Clear Meals", HandleNeutralButtonClick);
            builder.SetNegativeButton("Cancel", HandleNegativeButtonClick);

            // Build And Return Dialog
            var dialog = builder.Create();
            return dialog;
        }
		public bool Display (string body, string cancelButtonTitle, string acceptButtonTitle = "", Action action = null, bool negativeAction = false)
		{
			AlertDialog.Builder alert = new AlertDialog.Builder (Forms.Context);

			alert.SetTitle ("Alert");
			alert.SetMessage (body);
			alert.SetNeutralButton (cancelButtonTitle, (senderAlert, args) => {

			});


			if (acceptButtonTitle != "") {
				if (!negativeAction) {
					alert.SetPositiveButton (acceptButtonTitle, (senderAlert, args) => {
						if (action != null) {
							action.Invoke ();
						}
					});
				} else {
					alert.SetNegativeButton (acceptButtonTitle, (senderAlert, args) => {
						if (action != null) {
							action.Invoke ();
						}
					});
				}
			}

			((Activity)Forms.Context).RunOnUiThread (() => {
				alert.Show ();
			});
			return true;
		}
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Page_Dialog);

            var yesNoDialogbutton = FindViewById<Button>(Resource.Id.YesNoDialogButton);
            yesNoDialogbutton.Click += delegate
                                {
                                    var builder = new AlertDialog.Builder(this);
                                    builder.SetMessage(Resource.String.knigts_dialog_title);
                                    builder.SetPositiveButton(Resource.String.yes, (s, e) => { });
                                    builder.SetNegativeButton(Resource.String.no, (s, e) => { }).Create();
                                    builder.Show();
                                };

            var alertDialogButton = FindViewById<Button>(Resource.Id.AlertDialogButton);
            alertDialogButton.Click += delegate { ShowDialog(AlertDialog); };

            var listDialogButton = FindViewById<Button>(Resource.Id.ListDialogButton);
            listDialogButton.Click += delegate { ShowDialog(ListDialog); };

            var multiChoiceDialogButton = FindViewById<Button>(Resource.Id.MultiChoiceDialogButton);
            multiChoiceDialogButton.Click += delegate { ShowDialog(MultiChoiceDialog); };

            var customViewDialogButton = FindViewById<Button>(Resource.Id.CustomViewDialogButton);
            customViewDialogButton.Click += delegate { ShowDialog(CustomViewDialog); };

            var fragmentDialogsButton = FindViewById<Button>(Resource.Id.FragmentDialogsButton);
            fragmentDialogsButton.Click += delegate
                                               {
                                                   var intent = new Intent(this, typeof (DialogFragmentActivity));
                                                   intent.AddFlags(ActivityFlags.ClearTop);
                                                   StartActivity(intent);
                                               };
        }
        public void Login(object sender, EventArgs e)
        {
            EditText Email = FindViewById<EditText>(Resource.Id.Email);
            EditText Password = FindViewById<EditText>(Resource.Id.Password);
            TextView tex1 = FindViewById<TextView>(Resource.Id.text1);
            TextView tex2 = FindViewById<TextView>(Resource.Id.text2);

            EmailSend = Email.Text;
            PasswordSend = Password.Text;
            ConnectDatabase data;

            string HashText = null;

            if (EmailSend == "" || PasswordSend == "" || EmailSend.Length < 5 || PasswordSend.Length < 5)
            {
                AlertDialog.Builder alert = new AlertDialog.Builder(this);
                alert.SetMessage("Invalid Username or Password");
                alert.SetTitle("Error");
                alert.SetCancelable(true);
                alert.SetPositiveButton("OK", (EventHandler<DialogClickEventArgs>)null);
                alert.Show();
            }
            else
            {
                StartActivity(typeof(StartPageActivity));
                data = new ConnectDatabase(EmailSend, PasswordSend);
                HashText = data.GetHash;
                tex1.Text = EmailSend;
                tex2.Text = HashText;

            }
        }
        public override Dialog OnCreateDialog(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Build Password Dialog
            var builder = new AlertDialog.Builder(Activity);

            // Get Layout Inflater
            var inflator = Activity.LayoutInflater;

            // Inflate Layout For Password Dialog
            var dialogView = inflator.Inflate(Resource.Layout.AddReminderDialogFragment, null);

            // Initialize Properties
            ReminderEditText = dialogView.FindViewById<EditText>(Resource.Id.editTextReminder);

            // Set Positive & Negative Buttons
            builder.SetView(dialogView);
            builder.SetPositiveButton("Add Reminder", HandlePositiveButtonClick);
            builder.SetNegativeButton("Cancel", HandleNegativeButtonClick);

            // Build And Return Dialog
            var dialog = builder.Create();
            return dialog;
        }
		public void Display (string body, string title, GoalsAvailable availableGoal, string cancelButtonTitle, string acceptButtonTitle = "", Action<GoalsAvailable, int> action = null)
		{
			EditText goalTextBox = new EditText (Forms.Context);
			AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder (Forms.Context);
			alertDialogBuilder.SetTitle (title);
			alertDialogBuilder.SetMessage (body);
			alertDialogBuilder.SetView (goalTextBox);

			goalTextBox.InputType = Android.Text.InputTypes.NumberFlagSigned;

			var inputFilter = new Android.Text.InputFilterLengthFilter (7);
			var filters = new Android.Text.IInputFilter[1];

			filters [0] = inputFilter;

			goalTextBox.SetFilters (filters);
			goalTextBox.InputType = Android.Text.InputTypes.ClassNumber;

			alertDialogBuilder.SetPositiveButton ("OK", (senderAlert, args) => {
				if(action != null)
				{
					int goalValue;
					int.TryParse(goalTextBox.Text, out goalValue);
					action.Invoke(availableGoal, goalValue);
				}

			} );
			alertDialogBuilder.SetNeutralButton ("CANCEL", (senderAlert, args) => {

			} );

			alertDialogBuilder.Show ();

		}
		private void refreshRanking()
		{
			var task = Task<List<TournamentRankingModel>>.Factory.StartNew(() => ServerData.getTournamentRanking(Session.Instance().selectedTournament.Id));
			task.ContinueWith(x =>     
			{
				try 
				{
					if (x.Exception != null) throw x.Exception.InnerException;
					ranking = task.Result;
					if(ranking.Count > 0)
					{
						notStarted.Visibility = ViewStates.Gone;
						Session.Instance().selectedTournament.Open = false;
						populateTable ();
					}
				} 
				catch (WebException e)
				{
					var builder = new AlertDialog.Builder(this);
					builder.SetMessage("Er is iets mis met de verbinding, probeer het later opnieuw.");
					builder.SetCancelable(false);
					builder.SetPositiveButton("OK", delegate { });
					builder.Show();
				}
			},
			TaskScheduler.FromCurrentSynchronizationContext());
		}
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
                case Resource.Id.actionNew:
                    string default_game_name = "Game";
                    AlertDialog.Builder alert1 = new AlertDialog.Builder(this.Activity);
                    EditText input = new EditText(this.Activity);
                    input.Text = default_game_name;
                    alert1.SetTitle("Game Name");
                    alert1.SetView(input);
                    alert1.SetPositiveButton("OK", delegate { AddGame(input.Text); });
                    alert1.SetNegativeButton("Cancel", (s, e) => { });
                    alert1.Show();
                    _adapter.NotifyDataSetChanged();
                    return true;

                case Resource.Id.actionRefresh:
                    GameData.Service.RefreshCache();
                    _adapter.NotifyDataSetChanged();
                    return true;

                default:
                    return base.OnOptionsItemSelected(item);
            }
        }
Exemple #29
0
        void LoginToVk()
        {
            var auth = new OAuth2Authenticator (
                clientId: "",  // put your id here
                scope: "friends,video,groups",
                authorizeUrl: new Uri ("https://oauth.vk.com/authorize"),
                redirectUrl: new Uri ("https://oauth.vk.com/blank.html"));

            auth.AllowCancel = true;
            auth.Completed += (s, ee) => {
                if (!ee.IsAuthenticated) {
                    var builder = new AlertDialog.Builder (this);
                    builder.SetMessage ("Not Authenticated");
                    builder.SetPositiveButton ("Ok", (o, e) => { });
                    builder.Create().Show();
                    return;
                }
                else
                {
                    token = ee.Account.Properties ["access_token"].ToString ();
                    userId = ee.Account.Properties ["user_id"].ToString ();
                    GetInfo();
                }
            };
            var intent = auth.GetUI (this);
            StartActivity (intent);
        }
		void LoginToVk ()
		{
			var auth = new OAuth2Authenticator (
				clientId: "5171316",  // id  нашого додатку 
				scope: "wall,photos,notes,pages", // запит прав нашого додатку 
				authorizeUrl: new System.Uri ("https://oauth.vk.com/authorize"),
				redirectUrl: new System.Uri ("https://oauth.vk.com/blank.html"));

			auth.AllowCancel = true;
			auth.Completed += (s, ee) => { //провірка чи аудентифіколваний
				if (!ee.IsAuthenticated) {
					var builder = new AlertDialog.Builder (this);
					builder.SetMessage ("Not Authenticated");
					builder.SetPositiveButton ("Ok", (o, e) => { });
					builder.Create().Show();
					return;
				}
				else
				{
					token = ee.Account.Properties ["access_token"].ToString ();
					userId = ee.Account.Properties ["user_id"].ToString ();	
					GetInfo();
				}
			};
			var intent = auth.GetUI (this);
			StartActivity (intent);
		}