/// <summary> /// Logins the button clicked. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> private void loginButtonClicked(object sender, EventArgs e) { if(string.IsNullOrEmpty(usernameEdit.Text)){ Toast.MakeText(this, "Please enter username", ToastLength.Short).Show(); return; } if(string.IsNullOrEmpty(passwordEdit.Text)){ Toast.MakeText(this, "Please enter password", ToastLength.Short).Show(); return; } // create the worker object BackgroundWorker worker = new BackgroundWorker(delegate(ref bool stop) { RunOnUiThread(() => setChildrenEnableState(false)); // get the username and password values string username = usernameEdit.Text; string password = passwordEdit.Text; // setup the server with the username and password MyGPO.ConnectedUser = new User(username, password); // should the login be successful, we will put the username and password into the preferences ISharedPreferencesEditor editor = PortaPodderApp.prefs.Edit(); editor.PutString(EncryptedPreferences.KEY_USERNAME, username); editor.PutString(EncryptedPreferences.KEY_PASSWORD, password); editor.Commit(); // we are going to attempt to get the lists of devices and only if this returns correctly authenticated do we continue to finish this activity MyGPO.GetDevicesFromServer(); }); worker.Completed += delegate(Exception exc) { RunOnUiThread(() => setChildrenEnableState(true)); if(exc != null){ MyGPO.ConnectedUser = null; PortaPodderApp.LogMessage(exc); RunOnUiThread(() => Toast.MakeText(this, "Unable to authenticate user with this password.", ToastLength.Short).Show()); } else{ // close the parent activity RunOnUiThread(Finish); } }; // do the work worker.Execute(); }
/// <summary> /// Initializes a new instance of the <see cref="GPodder.PortaPodder.EpisodePlayer"/> class. /// </summary> public EpisodePlayer() { // assign the instructions for the progress monitor to execture when doing it's work in the background progressMonitor = new BackgroundWorker(delegate(ref bool stop){ while(!stop){ broadcastProgress(); Thread.Sleep(500); } }); // we are going to need a broadcase reciever here reciever = new EpisodeBroadcastReciever(this); }