protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); var textEmailAddress = FindViewById <EditText>(Resource.Id.editTextEmail); var etPassword = FindViewById <EditText>(Resource.Id.editTextPassword); var btn = FindViewById <Button>(Resource.Id.buttonValidate); btn.Click += async(sender, e) => { progress = new Android.App.ProgressDialog(this); progress.SetCancelable(false); progress.SetTitle("Trabajando"); progress.SetMessage("Por favor, espera..."); progress.SetProgressStyle(Android.App.ProgressDialogStyle.Horizontal); progress.Indeterminate = true; progress.Show(); await Validate(); Android.App.AlertDialog.Builder Builder = new AlertDialog.Builder(this); AlertDialog Alert = Builder.Create(); Alert.SetTitle("Resultado de la verificación"); Alert.SetIcon(Resource.Drawable.dotnet); Alert.SetMessage( $"{Result.Status}\n{Result.FullName}\n{Result.Token}"); Alert.SetButton("Ok", (s, ev) => { }); progress.Cancel(); Alert.Show(); }; }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.instructorChapterListToolBar); progress = new Android.App.ProgressDialog(this); progress.Indeterminate = true; progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner); progress.SetTitle("Please Wait"); progress.SetMessage("Getting Course Details"); progress.SetCancelable(false); progress.Show(); string inst_id = Intent.GetStringExtra("instructor_id") ?? "Data not available"; language_id = Intent.GetStringExtra("language_id") ?? "Data not available"; inst_name = Intent.GetStringExtra("instructor_name") ?? "Name Not Available"; try { Console.WriteLine("instructor_name : " + inst_name); await Task.Run(() => ChapterList(inst_id, language_id)); await Task.Run(() => CourseInfoFetcher(language_id)); progress.Hide(); //InitData(); FindViews(); chapterListInstructorName.Text = inst_name; } catch (Exception ChapterListError) { Console.WriteLine("ChapterListError : " + ChapterListError); throw; } }
public override Android.Views.View OnCreateView(Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState) { // Console.WriteLine("[{0}] OnCreateView Called: {1}", TAG, DateTime.Now.ToLongTimeString()); View v = inflater.Inflate(Resource.Layout.fragment_photo, container, false); mImageView = v.FindViewById<ImageView>(Resource.Id.photoView); photoUrl = Activity.Intent.GetStringExtra(PhotoGalleryFragment.PHOTO_URL_EXTRA); photoUrl = photoUrl.Substring(0, photoUrl.Length-6) + ".jpg"; photoFilename = new FlickrFetchr().GetFilenameFromUrl(photoUrl); ProgressDialog pg = new ProgressDialog(Activity); pg.SetMessage(Resources.GetString(Resource.String.loading_photo_message)); pg.SetTitle(Resources.GetString(Resource.String.loading_photo_title)); pg.SetCancelable(false); pg.Show(); Task.Run(async () => { Bitmap image = await new FlickrFetchr().GetImageBitmapAsync(photoUrl, 0, new CancellationTokenSource().Token, photoFilename).ConfigureAwait(false); Activity.RunOnUiThread(() => { mImageView.SetImageBitmap(image); //Console.WriteLine("[{0}] File created: {1}", TAG, photoUrl); pg.Dismiss(); }); }); return v; }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.ChapterDetailsLayout); string chapt_id = Intent.GetStringExtra("chapter_id") ?? "Data not available"; //string instructor_name = Intent.GetStringExtra("instructor_name") ?? "Name Not Available"; //instructorName.Text = instructor_name; progress = new Android.App.ProgressDialog(this); progress.Indeterminate = true; progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner); progress.SetTitle("Please Wait"); progress.SetMessage("Getting Course Details"); progress.SetCancelable(false); progress.Show(); await Task.Run(() => ChapterDetailsFetcher(chapt_id)); progress.Hide(); FindViews(); instructorName.Text = Convert.ToString(instructorChapterList.inst_name); briefDescription.Text = briefDesc; mainContent.Text = chapterContent; toolbarChapterNumber.Text = chapterNumber; toolbarChapterName.Text = chapterName; }
public void Show(Context context, string content, string title) { var dialog = new ProgressDialog(context); dialog.SetMessage(content); dialog.SetTitle (title); dialog.SetCancelable(false); dialog.Show(); System.Threading.Thread.Sleep (2000); dialog.Hide (); }
public static void ShowProgressDialog(Activity context, string msg="Loading", string title="",bool isCancle=false) { if(_mProgressDialog != null) return; _mProgressDialog = new ProgressDialog(context); _mProgressDialog.SetProgressStyle(ProgressDialogStyle.Spinner); _mProgressDialog.SetTitle(title); _mProgressDialog.SetMessage(msg); _mProgressDialog.SetCancelable(isCancle); if (!context.IsFinishing) { _mProgressDialog.Show(); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.ListImages); String tagService = Intent.GetStringExtra ("TagService"); gallery = (Gallery)FindViewById <Gallery> (Resource.Id.gallery); images = new List<Bitmap> (); progressDialog = new ProgressDialog(this) { Indeterminate = true }; progressDialog.SetTitle("Carga de Datos"); progressDialog.SetMessage("Wait"); searchImagesByTag (tagService); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); _loginService = new LoginService(); _progressDialog = new ProgressDialog(this) { Indeterminate = true }; _progressDialog.SetTitle("Login In Progress"); _progressDialog.SetMessage("Please wait..."); loginSynchronously(); //loginWithThread(); //loginWithJavaThread(); //loginWithThreadPool(); //loginWithAsyncTask(); //loginWithTaskLibrary(); }
protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); SetContentView (Resource.Layout.Main); Presenter = new TwitterPresenter(this, new TwitterRepoImpl()); TwitterList = FindViewById<ListView> (Resource.Id.twitterList); NoTweetsLabel = FindViewById<TextView>(Resource.Id.noTweetsMessage); progressDialog = new ProgressDialog(this); progressDialog.SetTitle("Loading Tweets"); Presenter.LoadFeed(); }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.courseDetailToolBar); courseCode = Intent.GetStringExtra("courseCode") ?? "Data not available"; //Defines the settings for progress bar progress = new Android.App.ProgressDialog(this); progress.Indeterminate = true; progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner); progress.SetTitle("Please Wait"); progress.SetMessage("Getting Course Details"); progress.SetCancelable(false); progress.Show(); try { await Task.Run(() => CourseListFetcher(courseCode)); await Task.Run(() => InstructorListFetcher(courseCode)); progress.Hide(); //listSample.Add("Getting Instructors"); InitData(); FindViews(); //foreach (var item in listSample) //{ // Console.WriteLine("ListSample : " + item); //} //foreach (var item in userID) //{ // Console.WriteLine("UserIDs : " + item); //} } catch (System.Exception something) { progress.Hide(); Console.WriteLine("Something : " + something); throw; } }
private void DeleteMessage(MessageListItem selectedMessage) { _progressDialog = new ProgressDialog(Activity); _progressDialog.SetTitle ("Delete Message"); _progressDialog.SetMessage (string.Format ("Deleting Message with {0} recipients. Please wait...", selectedMessage.RecipientCount)); _progressDialog.Show (); Task.Factory .StartNew(() => { var messages = _messageRepo.GetAllForEvent (selectedMessage.SmsGroup.Id, selectedMessage.DateSent, selectedMessage.Text); messages.ForEach (message => _messageRepo.Delete (message)); }) .ContinueWith(task => Activity.RunOnUiThread(() => { _sortedItems = GetGroupedMessages (20); ListAdapter = new MessageListAdapter(Activity, _sortedItems); ((BaseAdapter)ListAdapter).NotifyDataSetChanged (); _progressDialog.Dismiss (); })); }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); // Prepare the view SetContentView (Resource.Layout.StockChartActivityLayout); // Create and show the progress dialog _progressDialog = new ProgressDialog (this); _progressDialog.SetTitle ("Retrieving Data..."); _progressDialog.SetMessage ("Please wait"); _progressDialog.SetCancelable (false); _progressDialog.Show (); // Manage the updates of the presenter and application var app = ShinobiStockChartApplication.GetApplication (this); app.CurrentActivity = this; _presenter = app.Presenter as StockChartPresenter; _presenter.SetView (this); // Get the chart and configure it var chartFrag = FragmentManager.FindFragmentById<ChartFragment> (Resource.Id.chart); _chart = chartFrag.ShinobiChart; _chart.SetLicenseKey ("<PUT YOUR LICENSE KEY HERE>"); _chart.XAxis = new DateTimeAxis (); _chart.XAxis.EnableGestures (); _chart.YAxis = new NumberAxis (); _chart.YAxis.EnableGestures (); // Set the style _chart.Style.BackgroundColor = Resources.GetColor (Resource.Color.chart_background); _chart.Style.CanvasBackgroundColor = Color.Transparent; _chart.Style.PlotAreaBackgroundColor = Color.Transparent; _chart.XAxis.Style.LineColor = Resources.GetColor (Resource.Color.chart_axis); _chart.YAxis.Style.LineColor = Resources.GetColor (Resource.Color.chart_axis); _chart.XAxis.Style.TickStyle.LabelColor = Resources.GetColor (Resource.Color.chart_axis); _chart.YAxis.Style.TickStyle.LabelColor = Resources.GetColor (Resource.Color.chart_axis); _chart.XAxis.Style.TickStyle.LineColor = Resources.GetColor (Resource.Color.chart_axis); _chart.YAxis.Style.TickStyle.LineColor = Resources.GetColor (Resource.Color.chart_axis); // Set the title if (_chartTitle != null) { FindViewById<TextView> (Resource.Id.symbolTextView).Text = _chartTitle; } // Enable the home button ActionBar.SetDisplayHomeAsUpEnabled (true); ActionBar.SetHomeButtonEnabled (true); ActionBar.Title = _presenter.Title; }
public IMenuItem OnOptionsItemSelected(IMenuItem item, EditDetailFragment fragment, View viewEditDetail, Presentation presentation) { Logging.Log (this, Logging.LoggingTypeDebug, "OnOptionsItemSelected()"); switch((ActionBarButtons)item.ItemId) { case ActionBarButtons.SelectPresentation: fragment.Activity.RunOnUiThread(() => { EditActivity editActivity = context as EditActivity; if (editActivity != null) editActivity.ShowPresentationSelection(); fragment.SetHasOptionsMenu(false); }); break; case ActionBarButtons.Save: if (presentation != null) { SavePresentation(fragment, viewEditDetail, presentation); Toast.MakeText(fragment.Activity, Resource.String.ToastPresentationSaved, ToastLength.Long).Show(); } break; case ActionBarButtons.Render: // Async Daten Asyncron rendern lassen ProgressDialog pdlg = new ProgressDialog(fragment.Activity); pdlg.SetCancelable(false); pdlg.SetTitle(fragment.GetText(Resource.String.ProgressRenderPresentation)); pdlg.SetMessage(fragment.GetText(Resource.String.PleaseWait)); pdlg.Show(); Task.Factory.StartNew(() => { return new WSRenderGoogleIO2012(this.context).RenderPresentation(presentation.PresentationUID); }).ContinueWith(t => { pdlg.Cancel(); if (t.Exception == null && t.Result) Toast.MakeText(fragment.Activity, Resource.String.ToastPresentationRendered, ToastLength.Long).Show(); else { fragment.Activity.RunOnUiThread(delegate() { ((BaseActivity)fragment.Activity).ShowErrorMsg(fragment.GetText(Resource.String.ToastErrorRenderPresentation)); }); } }, TaskScheduler.FromCurrentSynchronizationContext()); break; case ActionBarButtons.Present: StartPresentation(fragment, presentation); break; } return item; }
/// <summary> /// Downloads the podcast clicked. /// </summary> /// <param name='sender'>Sender.</param> /// <param name='e'>E.</param> private void downloadPodcastClicked(object sender, EventArgs e) { Episode myEpisode = EpisodeList.SelectedEpisode; // instantiate it within the onCreate method ProgressDialog downloadProgress = new ProgressDialog(this); downloadProgress.SetMessage(myEpisode.PodcastTitle); downloadProgress.Indeterminate = false; downloadProgress.SetTitle("Downloading Episode"); downloadProgress.Max = 100; downloadProgress.SetProgressStyle(ProgressDialogStyle.Horizontal); long fileLength = 0; // create a background worker to download everything BackgroundWorker downloadInBackground = new BackgroundWorker(delegate(ref bool stop){ RunOnUiThread(() => downloadProgress.Show()); // we will read data via the response stream string outputPath = PortaPodderDataSource.GetEpisodeLocation(myEpisode); // check to see if the output path if(File.Exists(outputPath)) { return; } Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); // prepare the web page we will be asking for HttpWebRequest request = (HttpWebRequest)WebRequest.Create(myEpisode.Url.ToString()); // execute the request HttpWebResponse response = (HttpWebResponse)request.GetResponse(); fileLength = response.ContentLength; downloadProgress.Max = (int)(fileLength / 1024); // used on each read operation byte[] buf = new byte[1024 * 20]; using(System.IO.Stream resStream = response.GetResponseStream(), output = new FileStream(outputPath, FileMode.CreateNew, FileAccess.Write, FileShare.None, buf.Length)) { int count = 0; long total = 0; do { // check for the stop condition if(stop){ return; } // fill the buffer with data count = resStream.Read(buf, 0, buf.Length); // make sure we read some data if(count != 0) { total += count; downloadProgress.Progress = (int)(total / 1024); output.Write(buf, 0, count); } } while (count > 0); // any more data to read? } }); downloadInBackground.Completed += delegate(Exception exc){ RunOnUiThread(() => downloadProgress.Dismiss()); string outputPath = PortaPodderDataSource.GetEpisodeLocation(myEpisode); // log the exception if there was one if(exc != null){ PortaPodderApp.LogMessage(exc); } // delete the file if the download is incomplete or if there was an error if(File.Exists(outputPath) && (new FileInfo(outputPath).Length < fileLength || exc != null)){ File.Delete(outputPath); } setGUIForDownloadState(File.Exists(outputPath)); }; // if the progress bar is canceled, then the stop signal needs to be given downloadProgress.CancelEvent += delegate(object cancelSender, EventArgs cancelEvent) { downloadInBackground.Stop = true; }; downloadInBackground.Execute(); }
private async void LoadData(Bundle bundle) { ProgressDialog dialog = null; currentStage = AssessmentStage.Preparing; RunOnUiThread(() => { dialog = new ProgressDialog(this); dialog.SetTitle("Downloading..."); dialog.SetMessage("Please wait while we prepare your assessment."); dialog.SetCancelable(false); dialog.Show(); }); int id = Intent.GetIntExtra("ActivityId", -1); if (id >= 0) { assessment = (Assessment)await AppData.Session.FetchActivityWithId(id); } else { assessment = await ServerData.FetchAssessment(); } if (assessment == null) { RunOnUiThread(() => { dialog.Hide(); SelfDestruct("It looks like you're offline...", "Oops! We couldn't download your assessment - check your internet connection and try again later!"); }); return; } helpers = await assessment.PrepareTasks(); FindViewById<TextView>(Resource.Id.assessment_preamble).Text = assessment.Description; tasks = assessment.AssessmentTasks; zipPath = Path.Combine(AppData.Exports.Path, assessment.Id + "_assessmentRes.zip"); results = new ScenarioResult(assessment.Id, zipPath) { IsAssessment = true }; if (bundle != null) { var previous = bundle.GetInt("ASSESSMENT_PROGRESS", -1); if (previous >= 0 && previous < tasks.Length) { taskIndex = previous; StartAssessment(bundle.GetInt("TASK_PROGRESS", -1)); } else { currentStage = AssessmentStage.Preamble; preambleContainer.Visibility = ViewStates.Visible; recButton.Visibility = ViewStates.Visible; helpButton.Visibility = ViewStates.Visible; } } else { currentStage = AssessmentStage.Preamble; preambleContainer.Visibility = ViewStates.Visible; recButton.Visibility = ViewStates.Visible; helpButton.Visibility = ViewStates.Gone; } RunOnUiThread(() => { dialog.Hide(); }); }
protected override Dialog OnCreateDialog(int id) { switch (id) { case DIALOG_YES_NO_MESSAGE: { var builder = new AlertDialog.Builder (this); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_two_buttons_title); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); return builder.Create (); } case DIALOG_YES_NO_OLD_SCHOOL_MESSAGE: { var builder = new AlertDialog.Builder (this, Android.App.AlertDialog.ThemeTraditional); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_two_buttons_title); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); return builder.Create (); } case DIALOG_YES_NO_HOLO_LIGHT_MESSAGE: { var builder = new AlertDialog.Builder (this, Android.App.AlertDialog.ThemeHoloLight); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_two_buttons_title); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); return builder.Create (); } case DIALOG_YES_NO_LONG_MESSAGE: { var builder = new AlertDialog.Builder (this); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_two_buttons_msg); builder.SetMessage (Resource.String.alert_dialog_two_buttons_msg); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); builder.SetNeutralButton (Resource.String.alert_dialog_something, NeutralClicked); return builder.Create (); } case DIALOG_YES_NO_ULTRA_LONG_MESSAGE: { var builder = new AlertDialog.Builder (this); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_two_buttons_msg); builder.SetMessage (Resource.String.alert_dialog_two_buttons2ultra_msg); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); builder.SetNeutralButton (Resource.String.alert_dialog_something, NeutralClicked); return builder.Create (); } case DIALOG_LIST: { var builder = new AlertDialog.Builder (this); builder.SetTitle (Resource.String.select_dialog); builder.SetItems (Resource.Array.select_dialog_items, ListClicked); return builder.Create (); } case DIALOG_PROGRESS: { progress_dialog = new ProgressDialog (this); progress_dialog.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); progress_dialog.SetTitle (Resource.String.select_dialog); progress_dialog.SetProgressStyle (ProgressDialogStyle.Horizontal); progress_dialog.Max = MAX_PROGRESS; progress_dialog.SetButton (Android.App.Dialog.InterfaceConsts.ButtonPositive, GetText (Resource.String.alert_dialog_ok), OkClicked); progress_dialog.SetButton (Android.App.Dialog.InterfaceConsts.ButtonNegative, GetText (Resource.String.alert_dialog_cancel), CancelClicked); return progress_dialog; } case DIALOG_SINGLE_CHOICE: { var builder = new AlertDialog.Builder (this); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_single_choice); builder.SetSingleChoiceItems (Resource.Array.select_dialog_items2, 0, ListClicked); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); return builder.Create (); } case DIALOG_MULTIPLE_CHOICE: { var builder = new AlertDialog.Builder (this); builder.SetIcon (Resource.Drawable.ic_popup_reminder); builder.SetTitle (Resource.String.alert_dialog_multi_choice); builder.SetMultiChoiceItems (Resource.Array.select_dialog_items3, new bool[] { false, true, false, true, false, false, false }, MultiListClicked); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); return builder.Create (); } case DIALOG_MULTIPLE_CHOICE_CURSOR: { var projection = new string[] { BaseColumns.Id, Contacts.PeopleColumns.DisplayName, Contacts.PeopleColumns.SendToVoicemail }; var cursor = ManagedQuery (ContactsContract.Contacts.ContentUri, projection, null, null, null); var builder = new AlertDialog.Builder (this); builder.SetIcon (Resource.Drawable.ic_popup_reminder); builder.SetTitle (Resource.String.alert_dialog_multi_choice_cursor); builder.SetMultiChoiceItems (cursor, Contacts.PeopleColumns.SendToVoicemail, Contacts.PeopleColumns.DisplayName, MultiListClicked); return builder.Create (); } case DIALOG_TEXT_ENTRY: { // This example shows how to add a custom layout to an AlertDialog var factory = LayoutInflater.From (this); var text_entry_view = factory.Inflate (Resource.Layout.alert_dialog_text_entry, null); var builder = new AlertDialog.Builder (this); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_text_entry); builder.SetView (text_entry_view); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); return builder.Create (); } } return null; }
// Initializes a simple progress dialog that gets presented while the app is communicating with the server. private void InitializeProgressDialog() { progressDialog?.Dismiss(); progressDialog = new ProgressDialog(this); progressDialog.Indeterminate = true; progressDialog.SetTitle(GetString(Resource.String.please_wait)); progressDialog.SetCancelable(true); progressDialog.CancelEvent += delegate { Finish(); }; }
public override bool OnContextItemSelected(IMenuItem item) { if (_position < 0) return false; switch (item.ItemId) { case Resource.Id.editSMS: using (var editSmsIntent = new Intent()) { editSmsIntent.PutExtra ("groupId", _smsGroups[_position].Id); editSmsIntent.SetClass (Activity, typeof(EditSmsGroupActivity)); StartActivity (editSmsIntent); } break; case Resource.Id.sendSMS: using (var sendMessage = new Intent()) { sendMessage.PutExtra ("groupId", _smsGroups[_position].Id); sendMessage.SetClass (Activity, typeof(SendMessageActivity)); StartActivity (sendMessage); } break; case Resource.Id.deleteSMS: new AlertDialog.Builder(Activity) .SetTitle ("Delete SMS Group") .SetMessage (string.Format ("Are you sure you want to delete the following group: {0}", _smsGroups[_position])) .SetPositiveButton ("Ok", (o, e) => { _progressDialog = new ProgressDialog(Activity); _progressDialog.SetTitle ("Delete SMS Group"); _progressDialog.SetMessage ("Please wait. Deleting SMS Group..."); _progressDialog.Show (); Task.Factory .StartNew(() => { var smsGroup = _smsGroups[_position]; //Delete all messages, group memebers, and then delete sms group var messageRepo = new SmsMessageRepository(); var messages = messageRepo.GetAllForGroup (smsGroup.Id); messages.ForEach (messageRepo.Delete); _contactRepo = new ContactRepository(Activity); var contacts = _contactRepo.GetMembersForSmsGroup(smsGroup.Id); contacts.ForEach (c => _contactRepo.Delete (c)); _smsGroupRepo.Delete (smsGroup); }) .ContinueWith(task => Activity.RunOnUiThread(() => { _smsGroups.RemoveAt (_position); ListAdapter = new GroupListAdapter(Activity, _smsGroups); ((BaseAdapter)ListAdapter).NotifyDataSetChanged (); _progressDialog.Dismiss (); })); }) .SetNegativeButton ("Cancel", (o, e) => { }) .Show (); break; } return base.OnContextItemSelected (item); }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); BindService (); SetContentView(Resource.Layout.SendMessage); ActionBar.SetDisplayHomeAsUpEnabled (true); var groupId = Intent.GetIntExtra("groupId", 0); _smsGroupRepo = new SmsGroupRepository(); _smsGroup = _smsGroupRepo.Get (groupId); _contactRepo = new ContactRepository(this); _recipients = _contactRepo.GetMembersForSmsGroup (groupId); FindViewById <TextView>(Resource.Id.recipientGroup).Text = _smsGroup.Name; FindViewById <TextView>(Resource.Id.recipients).Text = string.Join (", ", _recipients.Select (c => c.Name)); FindViewById <ImageButton>(Resource.Id.cmdSend).Click += (sender, e) => { _progressDialog = new ProgressDialog(this); _progressDialog.SetTitle ("Sending Messages"); _progressDialog.SetMessage ("Please wait. Sending message to recipients in group..."); Task.Factory .StartNew(() => QueueMessage ()) .ContinueWith(task => RunOnUiThread(() => { if (task.Result) { new AlertDialog.Builder(this) .SetTitle ("Messages Queued") .SetMessage (string.Format ("Your message was queued to be sent to each recipient of the '{0}' group", _smsGroup.Name)) .SetPositiveButton ("Ok", (o, args) => { var homeIntent = new Intent(); homeIntent.PutExtra ("defaultTab", 0); homeIntent.AddFlags (ActivityFlags.ClearTop); homeIntent.SetClass (this, typeof(MainActivity)); StartActivity(homeIntent); }) .Show (); } else { new AlertDialog.Builder(this) .SetTitle ("Message Error") .SetMessage (string.Format ("Doh! Your message could not be sent to the '{0}' group.", _smsGroup.Name)) .Show (); } _progressDialog.Dismiss (); })); }; }
/// <summary> /// Takes the account created from the Google login and sends it to the server for comparison. /// The returned User object contains a Key for authentication in future POST requests /// </summary> /// <param name="thisUser">The user created from 3rd party systems</param> private async void SetupUserAccount(User thisUser) { ProgressDialog dialog = null; RunOnUiThread(() => { dialog = new ProgressDialog(this); dialog.SetTitle("Signing in..."); dialog.SetMessage("Please wait..."); dialog.SetCancelable(false); dialog.Show(); }); User serverUser = await ServerData.PostUserAccount(thisUser); RunOnUiThread(() => dialog.Hide()); if (serverUser == null) { ThrowError("Failed to set up your account with the service. Please try again later."); return; } AppData.AssignCurrentUser(serverUser); ReadyMainMenu(); }
public async void ReadyMainMenu() { ProgressDialog dialog = null; RunOnUiThread(() => { dialog = new ProgressDialog(this); dialog.SetTitle("Welcome, " + AppData.Session.CurrentUser.Nickname + "!"); dialog.SetMessage("Downloading data. Please wait..."); dialog.SetCancelable(false); dialog.Show(); }); bool success = await ServerData.FetchCategories(); RunOnUiThread(() => { dialog.Hide(); }); signInClicked = false; if (!success) { ThrowError("Failed to download all of the necessary files. Please check your Internet connection and try again later!"); return; } StartActivity(typeof (MainActivity)); Finish(); }
private void DownloadLanguageFiles() { var url = context.GetString(Resource.String.language_pack_apk_url); Uri uri = new Uri(url); var filename = System.IO.Path.Combine(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads).AbsolutePath, System.IO.Path.GetFileName(uri.LocalPath)); if (System.IO.File.Exists(filename)) { try { System.IO.File.Delete(filename); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Language files APK exists and cannot be deleted"); Toast.MakeText(context, context.GetString(Resource.String.err_download_failed), ToastLength.Short).Show(); return; } } if (!System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(filename))) { try { System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(filename)); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Download folder doesn't exist and cannot be created"); Toast.MakeText(context, context.GetString(Resource.String.err_download_failed), ToastLength.Short).Show(); return; } } var progressDialog = new ProgressDialog(context); progressDialog.SetTitle(context.GetString(Resource.String.title_downloading)); progressDialog.SetMessage(context.GetString(Resource.String.please_wait)); progressDialog.Progress = 0; progressDialog.SetCancelable(false); progressDialog.Indeterminate = false; progressDialog.Max = 100; progressDialog.SetProgressStyle(ProgressDialogStyle.Horizontal); try { using (WebClient wc = new WebClient()) { wc.DownloadProgressChanged += (sender, e) => { progressDialog.Progress = e.ProgressPercentage; }; wc.DownloadFileCompleted += (sender, e) => { progressDialog.Dismiss(); if (e.Error != null) { Toast.MakeText(context, context.GetString(Resource.String.err_download_failed) + " " + e.Error.Message, ToastLength.Short).Show(); System.Diagnostics.Debug.WriteLine("Failed to download language pack. " + e.Error.Message); return; } System.Diagnostics.Debug.WriteLine("Downloaded file " + filename); progressDialog.Dismiss(); InstallLanguageFiles(filename); }; wc.DownloadFileAsync(uri, filename); } progressDialog.Show(); } catch (Exception ex) { progressDialog.Dismiss(); Toast.MakeText(context, context.GetString(Resource.String.err_download_failed) + " " + ex.Message, ToastLength.Short).Show(); System.Diagnostics.Debug.WriteLine("Failed to download language pack. " + ex.Message); } }
void RefreshItems() { string itemStocksURL = String.Format("{0}/itemstocks.php", MainActivity.BASE_URL); pd = new ProgressDialog(this); pd.SetTitle("Loading..."); pd.SetMessage("Please wait while loading..."); pd.SetCancelable(false); pd.SetIndeterminate(true); pd.Show(); var worker = new BackgroundWorker(); worker.DoWork += OnGetItemStocks; worker.RunWorkerAsync(itemStocksURL); }
public void buscaryabrir(string termino) { RunOnUiThread(() => { #pragma warning disable CS0618 // El tipo o el miembro est�n obsoletos alerta = new ProgressDialog(this); #pragma warning restore CS0618 // El tipo o el miembro est�n obsoletos #pragma warning restore CS0618 // El tipo o el miembro est�n obsoletos alerta.SetCanceledOnTouchOutside(false); alerta.SetCancelable(false); alerta.SetTitle("Buscando resultados..."); alerta.SetMessage("Por favor espere"); alerta.Show(); }); try { // RunOnUiThread(() => progreso.Progress = 50); VideoSearch src = new VideoSearch(); var results = src.SearchQuery(termino, 1); if (results.Count > 0) { var listatitulos = results.Select(ax => WebUtility.HtmlDecode(RemoveIllegalPathCharacters(ax.Title.Replace(""", "").Replace("&", "")))).ToList(); var listalinks = results.Select(ax => ax.Url).ToList(); RunOnUiThread(() => { ListView lista = new ListView(this); lista.ItemClick += (o, e) => { var posicion = 0; posicion = e.Position; Intent intentoo = new Intent(this, typeof(customdialogact)); intentoo.PutExtra("index", posicion.ToString()); intentoo.PutExtra("color", "DarkGray"); intentoo.PutExtra("titulo", listatitulos[posicion]); if (!isserver) { intentoo.PutExtra("ipadress", Mainmenu.gettearinstancia().ip); } else { intentoo.PutExtra("ipadress", "localhost"); } intentoo.PutExtra("url", listalinks[posicion]); intentoo.PutExtra("imagen", @"https://i.ytimg.com/vi/" + listalinks[posicion].Split('=')[1] + "/mqdefault.jpg"); StartActivity(intentoo); }; adapterlistaremoto adapt = new adapterlistaremoto(this, listatitulos, listalinks); lista.Adapter = adapt; new Android.App.AlertDialog.Builder(this) .SetTitle("Resultados de la busqueda") .SetView(lista).SetPositiveButton("Cerrar", (dd, fgf) => { }) .Create() .Show(); }); } RunOnUiThread(() => { alerta.Dismiss(); }); } catch (Exception) { RunOnUiThread(() => Toast.MakeText(this, "No se encotraron resultados", ToastLength.Long).Show()); alerta.Dismiss(); } }
public void cargarresults() { try { RunOnUiThread(() => { #pragma warning disable CS0618 // El tipo o el miembro están obsoletos alerta = new ProgressDialog(this); #pragma warning restore CS0618 // El tipo o el miembro están obsoletos alerta.SetTitle("Buscando videos sugeridos"); alerta.SetMessage("Por favor espere..."); alerta.SetCancelable(false); alerta.Create(); alerta.Show(); }); YoutubeSearch.VideoSearch buscar = new YoutubeSearch.VideoSearch(); List <YoutubeSearch.VideoInformation> results = new List <YoutubeSearch.VideoInformation>(); if (YoutubePlayerServerActivity.gettearinstancia() != null) { if (YoutubePlayerServerActivity.gettearinstancia().sugerencias.Count > 0) { results = YoutubePlayerServerActivity.gettearinstancia().sugerencias; } else { results = buscar.SearchQuery("", 1); YoutubePlayerServerActivity.gettearinstancia().sugerencias = results; } } else if (Mainmenu.gettearinstancia() != null) { if (Mainmenu.gettearinstancia().sugerencias.Count > 0) { results = Mainmenu.gettearinstancia().sugerencias; } else { results = buscar.SearchQuery("", 1); Mainmenu.gettearinstancia().sugerencias = results; } } List <PlaylistElement> listafake = new List <PlaylistElement>(); foreach (var data in results) { listafake.Add(new PlaylistElement { Name = WebUtility.HtmlDecode(data.Title), Link = data.Url }); } RunOnUiThread(() => { adaptadorcartas adap = new adaptadorcartas(listafake, this); adap.ItemClick += (aa, aaa) => { RunOnUiThread(() => { var elemento = listafake[aaa.Position]; Intent intento = new Intent(this, typeof(customdialogact)); intento.PutExtra("url", elemento.Link); intento.PutExtra("titulo", elemento.Name); intento.PutExtra("imagen", "http://i.ytimg.com/vi/" + elemento.Link.Split('=')[1] + "/mqdefault.jpg"); StartActivity(intento); }); }; listasugerencias.SetAdapter(adap); alerta.Dismiss(); if (listafake.Count > 0) { secciones[3].Visibility = ViewStates.Visible; } else { secciones[3].Visibility = ViewStates.Gone; } }); } catch (Exception) { RunOnUiThread(() => alerta.Dismiss()); } }
void RefreshPilotList() { string pilotsOnlineURL = String.Format("{0}/onlinepilots.php", MainActivity.BASE_URL); pd = new ProgressDialog(this); pd.SetTitle("Loading..."); pd.SetMessage("Please wait while loading..."); pd.SetCancelable(false); pd.SetIndeterminate(true); pd.Show(); var worker = new BackgroundWorker(); worker.DoWork += OnGetOnlinePilots; worker.RunWorkerAsync(pilotsOnlineURL); }
private void SendInvites(List<Contact> toContactsList) { int count = 0; RunOnUiThread(delegate { dialog = new ProgressDialog(context); dialog.SetMessage(Application.Context.GetString(Resource.String.invitePBMessage)); dialog.SetTitle(Application.Context.GetString(Resource.String.invitePBTitle)); dialog.SetProgressStyle(ProgressDialogStyle.Horizontal); dialog.Max = toContactsList.Count; dialog.Progress = 0; dialog.Show(); }); switch (this.networkType) { case AccountOAuth.OAuthTypes.FaceBook: foreach (Contact eachContact in toContactsList) { try { string oauthID = string.Empty; for (int i = 0; i < eachContact.ContactOAuths.Count; i++) { if (eachContact.ContactOAuths [i].OAuthType == AccountOAuth.OAuthTypes.FaceBook) { oauthID = eachContact.ContactOAuths [i].OAuthID; break; } } #if(DEBUG) this.Provider.PostToFeed("Testing, nevermind. http://www.example.com", oauthID); #else this.Provider.PostToFeed (string.Format ( Application.Context.GetString (Resource.String.inviteFacebookPostMessageFormat), LOLConstants.LinkLOLAppWebsiteUrl), oauthID); #endif RunOnUiThread(delegate { dialog.Progress = (int)(++count / toContactsList.Count); }); } catch (Exception ex) { #if(DEBUG) System.Diagnostics.Debug.WriteLine("Exception inviting user: {0} {1}\n{2}--{3}", eachContact.ContactUser.FirstName, eachContact.ContactUser.LastName, ex.Message, ex.StackTrace); #endif } } break; case AccountOAuth.OAuthTypes.Google: case AccountOAuth.OAuthTypes.YouTube: if (toContactsList.Count > 0) { List<LOLConnectInviteEmail> emailInvites = new List<LOLConnectInviteEmail>(); emailInvites = toContactsList .Select(s => { return new LOLConnectInviteEmail() { ContactName = string.Format("{0} {1}", s.ContactUser.FirstName, s.ContactUser.LastName), EmailAddress = s.ContactUser.EmailAddress, OAuthType = this.networkType }; }) .ToList(); //RunOnUiThread(delegate { dialog.Progress = (int)(++count / toContactsList.Count); }); RunOnUiThread(() => Toast.MakeText(context, Application.Context.GetString(Resource.String.commonSendInvite), ToastLength.Short).Show()); LOLConnectClient service = new LOLConnectClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint); service.ContactsSendInviteEmailCompleted += Service_ContactsSendInviteEmailCompleted; service.ContactsSendInviteEmailAsync(emailInvites); }//end if break; case AccountOAuth.OAuthTypes.LinkedIn: if (toContactsList.Count > 0) { try { LLinkedInManager lMan = (LLinkedInManager)this.Provider; lMan.PostToFeed( StringUtils.CreateLinkedInXMLMessage(Application.Context.GetString(Resource.String.inviteLinkedInPostMessage), LOLConstants.LinkLOLAppWebsiteUrl, AndroidData.CurrentUser, lMan.GetUserProfileUrl()), string.Empty); RunOnUiThread(delegate { dialog.Progress = (int)(++count / toContactsList.Count); }); } catch (Exception ex) { #if(DEBUG) System.Diagnostics.Debug.WriteLine("Exception creating LinkedIn activity: {0}--{1}", ex.Message, ex.StackTrace); #endif } } break; } RunOnUiThread(delegate { if (dialog != null) dialog.Dismiss(); }); }
public ProgressDialog DownloadingProgressDialog(string title, string message) { ProgressDialog progress = new ProgressDialog(context); progress.SetMessage(message); progress.SetTitle(title); progress.SetIcon(Resource.Drawable.Icon); progress.SetButton("Cancel", (sender, args) => { // Close progress dialog progress.Dismiss(); // Stop all downloads client.CancelAsync(); // Remove any language folders that were to be downloaded for (var i = 0; i < downloadQueue.Count; i++) { DeleteLanguagePack(downloadQueue[i]); } // No downloads to be downloaded downloadQueue = new List<string>(); // No files to be download FilesCoutner = 0; // They didn't all download, but set to true anyways allDownloaded = true; if (DownloadedLanguages.Count > 0) { Language = Language; } }); progress.SetProgressStyle(ProgressDialogStyle.Horizontal); progress.SetCancelable(false); progress.SetCanceledOnTouchOutside(false); return progress; }
private async void FinishAssessment() { currentStage = AssessmentStage.Finished; ProgressDialog progress; AppCompatDialog ratingsDialog = null; bool rated = false; RunOnUiThread(() => { progress = new ProgressDialog(this); progress.SetTitle("Assessment Complete!"); progress.SetMessage("Getting your recordings ready to upload..."); ratingsDialog = new Android.Support.V7.App.AlertDialog.Builder(this) .SetTitle("Assessment Complete!") .SetMessage("How do you feel you did?") .SetView(Resource.Layout.RatingDialog) .SetCancelable(false) .SetPositiveButton("Done", (par1, par2) => { // ReSharper disable once PossibleNullReferenceException // ReSharper disable once AccessToModifiedClosure RatingBar rating = ratingsDialog.FindViewById<RatingBar>(Resource.Id.dialogRatingBar); results.UserRating = rating.Rating; progress.Show(); rated = true; }) .Create(); ratingsDialog.Show(); }); FastZip fastZip = new FastZip(); fastZip.CreateZip(zipPath, localTempDirectory, true, null); Directory.Delete(localTempDirectory, true); while (!rated) { await Task.Delay(200); } results.CompletionDate = DateTime.Now; AppData.Session.ResultsToUpload.Add(results); AppData.SaveCurrentData(); StartActivity(typeof (UploadsActivity)); Finish(); }
void RefreshStations() { string stationInventoryURL = String.Format("{0}/stationinventory.php", MainActivity.BASE_URL); pd = new ProgressDialog(this); pd.SetTitle("Loading..."); pd.SetMessage("Please wait while loading..."); pd.SetCancelable(false); pd.SetIndeterminate(true); pd.Show(); var worker = new BackgroundWorker(); worker.DoWork += OnGetStationInventory; worker.RunWorkerAsync(stationInventoryURL); }
void RefreshItemDetail(Int64 itemID) { string itemDetailURL = String.Format("{0}/itemdetail.php?id={1}", MainActivity.BASE_URL, itemID.ToString().Replace(",", "")); pd = new ProgressDialog(this); pd.SetTitle("Loading..."); pd.SetMessage("Please wait while loading..."); pd.SetCancelable(false); pd.SetIndeterminate(true); pd.Show(); var worker = new BackgroundWorker(); worker.DoWork += OnGetItemDetail; worker.RunWorkerAsync(itemDetailURL); }
/// <summary> /// Exports the recordings into a zip and marks them as being ready to upload /// </summary> private async void ExportRecordings() { // Compress exported recordings into zip (Delete existing zip first) File.Delete(resultsZipPath); ProgressDialog progressDialog; AppCompatDialog ratingsDialog = null; AppCompatDialog commentDialog = null; bool rated = false; RunOnUiThread(() => { progressDialog = new ProgressDialog(this); progressDialog.SetTitle("Scenario Complete!"); progressDialog.SetMessage("Getting your recordings ready to upload..."); commentDialog = new Android.Support.V7.App.AlertDialog.Builder(this) .SetTitle("Ask for feedback") .SetMessage("If you'd like feedback on anything specific, ask your question in the box below.") .SetView(Resource.Layout.FeedbackDialog) .SetCancelable(false) .SetPositiveButton("Done", (par1, par2) => { progressDialog.Show(); EditText textInput = commentDialog.FindViewById<EditText>(Resource.Id.dialogTextField); results.FeedbackQuery = textInput.Text; rated = true; }) .Create(); ratingsDialog = new Android.Support.V7.App.AlertDialog.Builder(this) .SetTitle("Scenario Complete!") .SetMessage("How confident are you that you've spoken clearly?") .SetView(Resource.Layout.RatingDialog) .SetCancelable(false) .SetPositiveButton("Done", (par1, par2) => { // ReSharper disable once PossibleNullReferenceException // ReSharper disable once AccessToModifiedClosure RatingBar rating = ratingsDialog.FindViewById<RatingBar>(Resource.Id.dialogRatingBar); results.UserRating = rating.Rating; commentDialog.Show(); }) .Create(); ratingsDialog.Show(); }); try { FastZip fastZip = new FastZip(); fastZip.CreateZip(resultsZipPath, localTempDirectory, true, null); // Clean up zipped files string[] toDel = Directory.GetFiles(localTempDirectory); foreach (string path in toDel) { if (path == resultsZipPath) continue; File.Delete(path); } while (!rated) { await Task.Delay(200); } results.CompletionDate = DateTime.Now; AppData.Session.ResultsToUpload.Add(results); AppData.SaveCurrentData(); StartActivity(typeof (UploadsActivity)); Finish(); } catch (Exception except) { Console.Write(except.Message); } }
public override Dialog OnCreateDialog(Bundle savedInstanceState) { ProgressDialog dialog = new ProgressDialog (Activity); dialog.SetTitle (Resource.String.dialogtitle); dialog.SetMessage (GetString (Resource.String.dialogmessage)); dialog.Indeterminate = true; dialog.SetCancelable (false); return dialog; }
protected override void OnPreExecute() { base.OnPreExecute(); _progressDialog = new ProgressDialog(_context); _progressDialog.SetTitle("Mandelbrot generation in progress"); _progressDialog.SetMessage("Please wait..."); _progressDialog.SetCancelable(true); _progressDialog.SetProgressStyle(ProgressDialogStyle.Horizontal); _progressDialog.SetButton(-2, "Cancel", CancelClicked); _progressDialog.Show(); }
/// <summary> /// Pulls today's featured wikipedia article /// </summary> private async void LoadWikiInfo() { ProgressDialog dialog = new ProgressDialog(this); dialog.SetTitle("Please Wait..."); dialog.SetMessage("Downloading today's content!"); dialog.SetCancelable(false); dialog.Show(); wiki = await AndroidUtils.GetTodaysWiki(this); if (wikiImage != null && wiki.imageURL != null) { if (!File.Exists(wiki.imageURL)) { // Force update, file has been deleted somehow wiki = await ServerData.FetchWikiData(AndroidUtils.DecodeHTML); } wikiImage.SetImageURI(Android.Net.Uri.FromFile(new Java.IO.File(wiki.imageURL))); wikiImage.Visibility = ViewStates.Visible; } else if(wikiImage != null) { wikiImage.Visibility = ViewStates.Gone; } string[] sentences = wiki.content.Split(new[] {". "}, StringSplitOptions.RemoveEmptyEntries); string finalText = ""; int charTarget = 400; foreach (string sentence in sentences) { if (finalText.Length < charTarget && finalText.Length + sentence.Length < 570) { finalText += sentence + ". "; } else { break; } } wikiText.Text = finalText; // If it's longer than expected, reduce the text size! if (finalText.Length > 520) { if ((Resources.Configuration.ScreenLayout & Android.Content.Res.ScreenLayout.SizeMask) <= Android.Content.Res.ScreenLayout.SizeNormal) { wikiText.SetTextSize(Android.Util.ComplexUnitType.Sp, 15); } else { wikiText.SetTextSize(Android.Util.ComplexUnitType.Sp, 19); } } SwitchMode(ServerData.TaskType.Loudness); dialog.Hide(); }
ProgressDialog SetUpProgressDialog (string title, string message, bool indeterminate, ProgressDialogStyle style) { var dialog = new ProgressDialog (this) { Indeterminate = indeterminate, Max = 100, Progress = 0 }; dialog.SetTitle (title); dialog.SetMessage (message); dialog.SetProgressStyle (style); return dialog; }