private async void LoginButton_Click(object sender, EventArgs e) { _loginButton.Enabled = false; var pr = new Android.App.ProgressDialog(_context); pr.SetMessage("Login..."); pr.SetCancelable(false); pr.Show(); await Task.Factory.StartNew(() => BigLongImportantMethodAsync()); pr.Hide(); _loginButton.Enabled = true; }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); progress = new Android.App.ProgressDialog(Activity); progress.Indeterminate = true; progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner); progress.SetCancelable(false); progress.SetMessage("Please wait..."); pref = Android.App.Application.Context.GetSharedPreferences("BookMarkInfo", FileCreationMode.Private); BookMarkDetails = pref.GetString("FinalBookMark", "false"); dba = new DBHelper(); }
public async Task Send_Number() { if (ic.connectivity()) { progress = new Android.App.ProgressDialog(Activity); progress.Indeterminate = true; progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner); progress.SetCancelable(false); progress.SetMessage("Please wait..."); progress.Show(); OTPModel otp_data = new OTPModel(); otp_data.MobileNo = number; otp_data.SMS = "OTP"; string otp_json = JsonConvert.SerializeObject(otp_data); try { string item = await restService.GetOtp(Activity, licenceid, geolocation, version, otp_json); if (item.Contains("Authentication Failed")) { progress.Dismiss(); AlertBox(); } else { var primeArray = item.Split(','); otp = primeArray[0]; otp = otp.Substring(1); username = primeArray[1]; progress.Dismiss(); verification(); } } catch (Exception e) { progress.Dismiss(); } } else { progress.Dismiss(); } }
/** * Performs a task in the background, showing an indeterminate {@link ProgressDialog}, * while the {@link AsyncCallable} is being processed. * * @param <T> * @param pTitleResID * @param pMessageResID * @param pErrorMessageResID * @param pAsyncCallable * @param pCallback * @param pExceptionCallback */ protected void DoAsync <T>(int pTitleResID, int pMessageResID, andengine.util.AsyncCallable <T> pAsyncCallable, andengine.util.Callback <T> pCallback, andengine.util.Callback <Exception> pExceptionCallback) { ProgressDialog pd = ProgressDialog.Show(this, this.GetString(pTitleResID), this.GetString(pMessageResID)); /* * pAsyncCallable.Call(new Callback<T>() { * @Override * public void onCallback(final T result) { * try { * pd.dismiss(); * } catch (final Exception e) { * Debug.e("Error", e); * /* Nothing. * / * } * * pCallback.onCallback(result); * } * }, pExceptionCallback); */ pAsyncCallable.Call(new DoAsync_Callback <T>(this, pd, pCallback), pExceptionCallback); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.Inflate(Resource.Layout.ImageChange, container, false); img = view.FindViewById <ImageView>(Resource.Id.imageForRotation); img.BuildDrawingCache(true); new Thread(new ThreadStart(delegate { Activity.RunOnUiThread(() => { Android.App.ProgressDialog progress = Android.App.ProgressDialog.Show(img.Context, "", "Loading image..", true); img.SetImageBitmap(GetPictureFromUrl(string.Format("http://placekitten.com/g/{0}/{1}", img.Width, img.Height))); progress.Dismiss(); } ); })).Start(); buttonRotate = view.FindViewById <Button>(Resource.Id.buttonRotate); buttonFlipH = view.FindViewById <Button>(Resource.Id.buttonFlipH); buttonFlipV = view.FindViewById <Button>(Resource.Id.buttonFlipV); //actions on rotate button buttonRotate.Click += (sender, e) => { img.SetImageBitmap(TransformImage(0)); img.BuildDrawingCache(true); }; //actions on flip horizontal button buttonFlipH.Click += (sender, e) => { img.SetImageBitmap(TransformImage(1)); img.BuildDrawingCache(true); }; //actions on flip vertical button buttonFlipV.Click += (sender, e) => { img.SetImageBitmap(TransformImage(2)); img.BuildDrawingCache(true); }; return(view); }
public override void OnCreate(Bundle savedInstanceState) { StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder(); StrictMode.SetVmPolicy(builder.Build()); StrictMode.ThreadPolicy.Builder builder1 = new StrictMode.ThreadPolicy.Builder().PermitAll(); StrictMode.SetThreadPolicy(builder1.Build()); base.OnCreate(savedInstanceState); progress = new Android.App.ProgressDialog(Activity); progress.Indeterminate = true; progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner); progress.SetCancelable(false); progress.SetMessage("Please Wait..."); pref = Android.App.Application.Context.GetSharedPreferences("AboutExamInfo", FileCreationMode.Private); Abour_Exam = pref.GetString("FinalAboutExam", "false"); dba = new DBHelper(); }
private async void BtnRegistrar_Click(object sender, EventArgs e) { progress = new Android.App.ProgressDialog(this.Context); progress.Indeterminate = true; progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner); progress.SetMessage("Registrando...Espere..."); progress.SetCancelable(false); progress.Show(); string dni = txtdni.Text; string nombre = txtnombre.Text; string email = txtEmail.Text; string telef = txtTele_F.Text; string telec = txtTele_C.Text; if (!string.IsNullOrEmpty(dni) || !string.IsNullOrEmpty(nombre) || !string.IsNullOrEmpty(email) || !string.IsNullOrEmpty(telef) || !string.IsNullOrEmpty(telec)) { //await var dato = await controller.RegistraCliente(int.Parse(dni), nombre, email, int.Parse(telef), int.Parse(telec)); if (dato != null) { progress.Dismiss(); Toast.MakeText(this.Context, "Registrado Correctamente", ToastLength.Short).Show(); LimpiarCasillas(); } else { progress.Dismiss(); Toast.MakeText(this.Context, "Error al Registrar", ToastLength.Short).Show(); LimpiarCasillas(); } } else { progress.Dismiss(); Toast.MakeText(this.Context, "Campos vacios", ToastLength.Short).Show(); } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.Inflate(Resource.Layout.assign, container, false); HasOptionsMenu = true; //ViewPager viewpager = rootView.FindViewById <ViewPager>(Resource.Id.viewpager); // personal = setupViewPager(viewpager); var tabLayout = rootView.FindViewById <TabLayout>(Resource.Id.tabs); tabLayout.SetupWithViewPager(viewpager); progress = new Android.App.ProgressDialog(Activity); progress.Indeterminate = true; progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner); progress.SetCancelable(false); progress.SetMessage("Please wait..."); return(rootView); }
private void DownloadFile(FileSystemEntry item, string cachePath, Action onCompletion, Action <Exception> onError) { if (File.Exists(cachePath)) { Activity.ShowAlert(GetString(Resource.String.error_download_file), GetString(Resource.String.file_exists)); return; } #pragma warning disable 0618 var progress = new Android.App.ProgressDialog(Context); progress.SetCancelable(false); progress.SetMessage(GetString(Resource.String.downloading)); progress.Show(); #pragma warning restore 0618 Task.Run(async() => { try { var source = Path.Combine(workingPath, item.Name); var target = new FileStream(cachePath, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); await(await fileSystem.ReadFileAsync(source).ConfigureAwait(false)).CopyToAsync(target).ConfigureAwait(false); await target.DisposeAsync().ConfigureAwait(false); Activity.RunOnUiThread(() => { progress.Dismiss(); onCompletion?.Invoke(); }); } catch (Exception exception) { try { File.Delete(cachePath); } catch { } Activity.RunOnUiThread(() => { progress.Dismiss(); onError?.Invoke(exception); }); } }); }
public async Task getorglist(string org_id) { progress = new Android.App.ProgressDialog(Activity); progress.Indeterminate = true; progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner); progress.SetCancelable(false); progress.SetMessage("Please wait..."); progress.Show(); dynamic value = new ExpandoObject(); value.OrgId = org_id; string json = JsonConvert.SerializeObject(value); try { string item = await restservice.MarkingList(Activity, json, location).ConfigureAwait(false); markinglist = JsonConvert.DeserializeObject <List <MarkingListModel> >(item); db.InsertMarkingList(markinglist); progress.Dismiss(); } catch (Exception ex) { progress.Dismiss(); } if (markinglist != null) { Activity.RunOnUiThread(() => { marked = new MarkingListAdapter(Activity, markinglist); list.SetAdapter(marked); }); } progress.Dismiss(); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.Inflate(Resource.Layout.AddressBook, container, false); popupView = inflater.Inflate(Resource.Layout.ActionsOnContact, container, false); //view for actions popup emailView = inflater.Inflate(Resource.Layout.MailTemplate, container, false); //view for sending email template Android.App.ProgressDialog pd = Android.App.ProgressDialog.Show(Context, "", "Loadind contacts..", false, false); new Thread(new ThreadStart(() => { searchBox = view.FindViewById <Android.Widget.SearchView>(Resource.Id.searchBox); searchBox.QueryTextChange += (sender, e) => { if (!string.IsNullOrEmpty(e.NewText)) { List <Contact> newContactList = contList.FindAll(x => x.Name.ToLower().Contains(e.NewText.ToLower())); //filtering query for the list addressListView.Adapter = new AddressBookListAdapter(Activity, newContactList); } else { addressListView.Adapter = new AddressBookListAdapter(Activity, contList); } }; addressListView = view.FindViewById <ListView>(Resource.Id.addressBookList); addressListView.SetDrawSelectorOnTop(true); addressListView.ItemClick += ((sender, e) => { PopupWindow popup = CreateActionsPopup(contList[e.Position], e); popup.OutsideTouchable = true; popup.ShowAtLocation(View, GravityFlags.Center, 0, 0); }); GetContactList(); addressListView.Adapter = new AddressBookListAdapter(Activity, contList); pd.Dismiss(); })).Start(); return(view); }
public async Task getOrgData() { progress = new Android.App.ProgressDialog(Activity); progress.Indeterminate = true; progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner); progress.SetCancelable(false); progress.SetMessage("Please wait..."); progress.Show(); //dynamic value = new ExpandoObject(); //value.OrgId = orgid; // string json = JsonConvert.SerializeObject(value); try { string item = await restservice.OrgnizationList(Activity, "", location); orgmodel = JsonConvert.DeserializeObject <List <OrgModel> >(item); for (int i = 0; i < orgmodel.Count; i++) { OrgModel org = new OrgModel(); org.organizationName = orgmodel[i].organizationName; orgname.Add(org); } // db.InsertMarkingList(orgmodel); progress.Dismiss(); selectorg.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(Selectorg_ItemSelected); ArrayAdapter adapter = new ArrayAdapter(Activity, Android.Resource.Layout.SimpleListItem1, orgmodel); selectorg.Adapter = adapter; } catch (Exception ex) { progress.Dismiss(); } }
private bool LoadData() { Log.Debug(TAG, nameof(LoadData)); this.Activity.RunOnUiThread(() => { Log.Debug(TAG, "[1] Starting dialog."); dialog = this.Activity.ProgressDialogShow(dialog); Log.Debug(TAG, "[2] Dialog started."); }); try { var r = db.Select <Record, DateTime>((o) => o.Earnings == false, (o) => o.Date, false).Result; listData = r.ToList();//r.Select(p => $"{p.Description}, {p.Cost}, {p.Date}").ToList(); // Month values this.monthCost_value.Text = listData.Where(p => p.Date.Month == DateTime.Now.Month && p.Date.Year == DateTime.Now.Year && p.Earnings == false).Select(p => p.Cost).Sum().ToString(); return(true); } catch (Exception ex) { Log.Error(TAG, ex.ToString()); throw; } finally { this.Activity.RunOnUiThread(() => { this.Activity.ProgressDialogDismiss(dialog); }); } return(false); }
public async Task getData() { if (ic.connectivity()) { progress = new Android.App.ProgressDialog(Activity); progress.Indeterminate = true; progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner); progress.SetCancelable(false); progress.SetMessage("Please wait..."); progress.Show(); dynamic value = new ExpandoObject(); value.task_id = task_id_to_send; string json = JsonConvert.SerializeObject(value); try { JsonValue item = await restService.GetComplianceTask(Activity, json, geolocation); comp = JsonConvert.DeserializeObject <ComplianceModel>(item); taskuploaded = comp.lstUploadedCompliance; db.complianceoutbox_insert(comp); } catch (Exception ex) { progress.Dismiss(); } } else { datacomp = db.GetCompliance_for_outbox(task_id_to_send); db.insertuploadedtask_for_outbox(comp.lstUploadedCompliance); taskuploaded = db.gettaskuploaded(task_id_to_send); // taskuploaded = comp.lstUploadedCompliance; db.insertCommunicationdetail(comp.lstCommunication, task_id_to_send); List <CommunicationModel> lstCommunication = db.GetCommunicationModels(task_id_to_send); } //if (datacomp.Count == 0) //{ // Toast.MakeText(Activity, "Please connect to the Internet.", ToastLength.Long).Show(); //} //else //{ //} // List<CommunicationModel> lstCommunication = comp.lstCommunication; if (taskuploaded != null) { for (int i = 0; i < taskuploaded.Count; i++) { if (taskuploaded[i].file_type.Equals("Image")) { imagelistoutbox.Add(taskuploaded[i]); } else if (taskuploaded[i].file_type.Equals("Video")) { videolistoutbox.Add(taskuploaded[i]); } else if (taskuploaded[i].file_type.Equals("Audio")) { audiolistoutbox.Add(taskuploaded[i]); } } for (int i = 0; i < taskuploaded.Count; i++) { filetype = taskuploaded[i].file_type; filename = taskuploaded[i].FileName; file_format = taskuploaded[i].file_format; path = taskuploaded[i].Path; geolocation = taskuploaded[i].GeoLocation; filesize = taskuploaded[i].FileSize; if (filetype == "Image") { gridimagecomp = new GridImagecomplianceoutbox(Activity, imagelistoutbox, FragmentManager); imagegrid.Adapter = gridimagecomp; imagegrid.setExpanded(true); } if (filetype == "Video") { gridvideocomp = new GridVideocomplianceoutbox(Activity, videolistoutbox, FragmentManager); videolistview.Adapter = gridvideocomp; videolistview.setExpanded(true); } if (filetype == "Audio") { gridaudiocomp = new GridAudiocomplianceOutbox(Activity, audiolistoutbox, FragmentManager); audiolistview.Adapter = gridaudiocomp; audiolistview.setExpanded(true); } } //task_id = comp.task_id; //task_description = comp.description; //deadline = comp.deadline_date; //meatingid = comp.Meeting_ID; //rownum = comp.RowNo; ////taskcreationDate = comp.task_creation_date; //markby = comp.task_mark_by; //taskstatus = comp.taskStatus; //markto = comp.markTo; //markingtype = comp.task_marking_type; //taskcreatedby = comp.task_created_by; //markingDate = comp.MarkingDate; //creationdate = comp.task_creation_date; //shapes_from_Comp = comp.shapes; //task_name = comp.task_name; progress.Dismiss(); } settingValues(); for (int i = 0; i <= taskuploaded.Count; i++) { max_num = comp.lstUploadedCompliance[i].max_numbers; file_format = comp.lstUploadedCompliance[i].file_format; filetype = comp.lstUploadedCompliance[i].file_type; // taskoverview = comp.lstUploadedCompliance[i].task_overview; //uploaded = comp.lstUploadedCompliance[i].Uploaded; if (filetype.Equals("Image")) { image_max = Convert.ToInt32(max_num); } else if (filetype.Equals("Video")) { video_max = Convert.ToInt32(max_num); } else if (filetype.Equals("Audio")) { audio_max = Convert.ToInt32(max_num); } //Image_no.Text = image_max.ToString(); //Video_no.Text = video_max.ToString(); //Audio_no.Text = audio_max.ToString(); } }
private async System.Threading.Tasks.Task CreatetaskService() { progress = new Android.App.ProgressDialog(Activity); progress.Indeterminate = true; progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner); progress.SetCancelable(false); progress.SetMessage("Please wait..."); progress.Show(); //models = db.GetFullAttachmentData(task_id_to_send); for (int i = 0; i < listmapping2.Count; i++) { byte[] img = GetStreamFromFile(listmapping2[i].localPath); var url1 = await blob.UploadPhotoAsync(img, listmapping2[i].localPath.Substring(listmapping2[i].localPath.LastIndexOf("/") + 1)); if (url1 != null) { listmapping2[i].Path = url1; } } dynamic value = new ExpandoObject(); value.task_name = taskname; value.description = taskdescri; value.deadline_date = deadline; value.taskCreatethrough = "mobile"; value.markTo = markto; value.lstTaskFileMapping = listmapping2; value.lstAddedCompliance = CreateTaskFrag.modelsaddcompliance; string json = JsonConvert.SerializeObject(value); try { string item = await restService.CreateTaskMethod(Activity, json, geolocation); if (item.Contains("Task Created successfully")) { //db.InsertCreateTaskData(taskname, taskdescri, deadline, "mobile", markto, "yes"); //Toast.MakeText(Activity, "Task Assign Successfully..", ToastLength.Long).Show(); Toast.MakeText(Activity, "Task Assign Successfully...", ToastLength.Long).Show(); CreateTaskFrag.modelsaddcompliance.Clear(); progress.Dismiss(); } else { //db.InsertCreateTaskData(taskname, taskdescri, deadline, "mobile", markto,"yes",listmapping2); tasknametext.Text = null; taskdescription.Text = null; deadlinetext.Text = null; markedontext.Text = null; designationtext.Text = null; nametext.Text = null; Toast.MakeText(Activity, "Task saved Successfully.. you have not internet connection", ToastLength.Long).Show(); progress.Dismiss(); } } catch (Exception ex) { progress.Dismiss(); } progress.Dismiss(); }
public void OnItemLongClick(int position) { if (position == 0 && workingPath.Length != 1) { return; } var item = items[workingPath.Length == 1 ? position : (position - 1)]; var view = layoutManager.FindViewByPosition(position); var popup = new PopupMenu(Context, view); popup.MenuInflater.Inflate(Resource.Menu.file_actions, popup.Menu); if (item.IsDirectory) { popup.Menu.FindItem(Resource.Id.action_download).SetVisible(false); } if (item.IsReadOnly) { popup.Menu.FindItem(Resource.Id.action_rename).SetVisible(false); popup.Menu.FindItem(Resource.Id.action_move).SetVisible(false); popup.Menu.FindItem(Resource.Id.action_delete).SetVisible(false); } if (item.Attributes.HasFlag(FileAttributes.Device)) { popup.Menu.FindItem(Resource.Id.action_rename).SetVisible(false); popup.Menu.FindItem(Resource.Id.action_move).SetVisible(false); } popup.MenuItemClick += (o, e) => { switch (e.Item.ItemId) { case Resource.Id.action_download: { opSource = item; this.StartActivityForResult(typeof(ChooseFolderActivity), CallbackDownload); return; } case Resource.Id.action_move: { opSource = item; var intent = new Intent(Context, typeof(ChooseDestinationActivity)); var deviceRoot = workingPath.Substring(1); var nextSeparator = deviceRoot.IndexOf(Path.AltDirectorySeparatorChar); if (nextSeparator == -1) { deviceRoot = "/" + deviceRoot; } else { deviceRoot = "/" + deviceRoot.Substring(0, nextSeparator); } intent.PutExtra(ChooseDestinationActivity.ExtraRootPath, deviceRoot); StartActivityForResult(intent, CallbackMove); return; } case Resource.Id.action_rename: { Activity.ShowEditorAlert(GetString(Resource.String.new_file_name), item.Name, item.Name, GetString(Resource.String.action_save), text => { if (string.IsNullOrWhiteSpace(text)) { Activity.ShowAlert(GetString(Resource.String.bad_file_name), null); return; } if (text == item.Name) { return; } #pragma warning disable 0618 var progress = new Android.App.ProgressDialog(Context); progress.SetCancelable(false); progress.SetMessage(GetString(Resource.String.renaming)); progress.Show(); #pragma warning restore 0618 Task.Run(async() => { try { var path = Path.Combine(workingPath, item.Name); await fileSystem.RenameAsync(path, text).ConfigureAwait(false); Activity.RunOnUiThread(() => { progress.Dismiss(); RefreshDirectory(this, EventArgs.Empty); }); } catch (HttpRequestException exception) { Activity.RunOnUiThread(() => { progress.Dismiss(); Activity.ShowAlert(GetString(Resource.String.error_remote), exception.Message); }); } catch (Exception exception) { Activity.RunOnUiThread(() => { progress.Dismiss(); Activity.ShowAlert(GetString(Resource.String.error_rename_file), exception.GetType().Name); }); } }); }, GetString(Resource.String.action_cancel), null); return; } case Resource.Id.action_delete: { Activity.ShowAlert(GetString(Resource.String.delete_permanently), GetString(Resource.String.delete_all_contents, item.Name), GetString(Resource.String.action_cancel), null, GetString(Resource.String.action_delete), () => { #pragma warning disable 0618 var progress = new Android.App.ProgressDialog(Context); progress.SetCancelable(false); progress.SetMessage(GetString(Resource.String.deleting)); progress.Show(); #pragma warning restore 0618 Task.Run(async() => { try { var path = Path.Combine(workingPath, item.Name); if (item.IsDirectory) { path += Path.AltDirectorySeparatorChar; } await fileSystem.DeleteAsync(path).ConfigureAwait(false); Activity.RunOnUiThread(() => { progress.Dismiss(); RefreshDirectory(this, EventArgs.Empty); }); } catch (HttpRequestException exception) { Activity.RunOnUiThread(() => { progress.Dismiss(); Activity.ShowAlert(GetString(Resource.String.error_remote), exception.Message); }); } catch (Exception exception) { Activity.RunOnUiThread(() => { progress.Dismiss(); Activity.ShowAlert(GetString(Resource.String.error_delete_file), exception.GetType().Name); }); } }); }); return; } } }; if (popup.Menu.Size() != 0) { var helper = new MenuPopupHelper(Context, (MenuBuilder)popup.Menu, view); helper.SetForceShowIcon(true); helper.Show(); } }
public override void OnActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case CallbackUpload: { if ((Android.App.Result)resultCode != Android.App.Result.Ok) { return; } var path = data.GetStringExtra(UploadFilesActivity.ResultPath); if (string.IsNullOrEmpty(path)) { throw new InvalidOperationException(); } #pragma warning disable 0618 var progress = new Android.App.ProgressDialog(Context); progress.SetCancelable(false); progress.SetMessage(GetString(Resource.String.uploading_file)); progress.Show(); #pragma warning restore 0618 Task.Run(async() => { var shouldDelete = false; var fileName = Path.GetFileName(path); var remotePath = Path.Combine(workingPath, fileName); try { var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); await fileSystem.WriteFileAsync(remotePath, stream).ConfigureAwait(false); Activity.RunOnUiThread(() => { progress.Dismiss(); RefreshDirectory(this, EventArgs.Empty); }); } catch (HttpRequestException exception) { shouldDelete = true; Activity.RunOnUiThread(() => { progress.Dismiss(); Activity.ShowAlert(GetString(Resource.String.error_remote), exception.Message); }); } catch (Exception exception) { shouldDelete = true; Activity.RunOnUiThread(() => { progress.Dismiss(); Activity.ShowAlert(GetString(Resource.String.error_upload_file), exception.GetType().Name); }); } /* * if (shouldDelete) * { * try { await fileSystem.DeleteAsync(remotePath).ConfigureAwait(false); } * catch { } // Ignored. * } */ }); return; } case CallbackDownload: { if ((Android.App.Result)resultCode != Android.App.Result.Ok || opSource is null) { return; } var path = data.GetStringExtra(ChooseFolderActivity.ResultPath); if (string.IsNullOrEmpty(path)) { return; } path = Path.Combine(path, opSource.Name); PreparePlaceholder(opSource, path, () => { Activity.ShowAlert(GetString(Resource.String.downloaded), GetString(Resource.String.downloaded_as, opSource.Name, path)); opSource = null; }, exception => { if (exception is HttpRequestException http) { Activity.ShowAlert(GetString(Resource.String.error_remote), http.Message); } else { Activity.ShowAlert(GetString(Resource.String.error_download_file), exception.GetType().Name); } opSource = null; }); return; } case CallbackMove: { if ((Android.App.Result)resultCode != Android.App.Result.Ok || opSource is null) { return; } var path = data.GetStringExtra(ChooseDestinationActivity.ResultPath); if (string.IsNullOrEmpty(path)) { return; } #pragma warning disable 0618 var progress = new Android.App.ProgressDialog(Context); progress.SetCancelable(false); progress.SetMessage(GetString(Resource.String.moving_file)); progress.Show(); #pragma warning restore 0618 Task.Run(async() => { try { var sourcePath = Path.Combine(workingPath, opSource.Name); path = Path.Combine(path, opSource.Name); await fileSystem.RenameAsync(sourcePath, path).ConfigureAwait(false); opSource = null; Activity.RunOnUiThread(() => { progress.Dismiss(); RefreshDirectory(this, EventArgs.Empty); }); } catch (HttpRequestException exception) { Activity.RunOnUiThread(() => { progress.Dismiss(); Activity.ShowAlert(GetString(Resource.String.error_remote), exception.Message); }); } catch (Exception exception) { Activity.RunOnUiThread(() => { progress.Dismiss(); Activity.ShowAlert(GetString(Resource.String.error_move_file), exception.GetType().Name); }); } }); return; } default: { base.OnActivityResult(requestCode, resultCode, data); return; } } }
public override bool OnOptionsItemSelected(IMenuItem item) { switch (item.ItemId) { case Resource.Id.finder_home: { workingPath = "/"; RefreshDirectory(this, EventArgs.Empty); return(true); } case Resource.Id.finder_connect: { this.StartActivity(typeof(ManageConnectionsActivity)); return(true); } case Resource.Id.action_new_folder: { Activity.ShowEditorAlert(GetString(Resource.String.new_folder_name), GetString(Resource.String.new_folder_placeholder), null, GetString(Resource.String.new_folder_create), text => { if (string.IsNullOrWhiteSpace(text)) { Activity.ShowAlert(GetString(Resource.String.bad_folder_name), null); return; } #pragma warning disable 0618 var progress = new Android.App.ProgressDialog(Context); progress.SetCancelable(false); progress.SetMessage(GetString(Resource.String.creating_new_folder)); progress.Show(); #pragma warning restore 0618 Task.Run(async() => { try { var path = Path.Combine(workingPath, text); await fileSystem.CreateDirectoryAsync(path).ConfigureAwait(false); Activity.RunOnUiThread(() => { progress.Dismiss(); RefreshDirectory(this, EventArgs.Empty); }); } catch (HttpRequestException exception) { Activity.RunOnUiThread(() => { progress.Dismiss(); Activity.ShowAlert(GetString(Resource.String.error_remote), exception.Message); }); } catch (Exception exception) { Activity.RunOnUiThread(() => { progress.Dismiss(); Activity.ShowAlert(GetString(Resource.String.error_new_folder), exception.GetType().Name); }); } }); }, GetString(Resource.String.action_cancel), null); return(true); } case Resource.Id.action_upload_file: { this.StartActivityForResult(typeof(UploadFilesActivity), CallbackUpload); return(true); } default: { return(base.OnOptionsItemSelected(item)); } } }
override public Android.App.Dialog OnCreateDialog(Bundle savedInstanceState) { Android.App.ProgressDialog progressDialog = new Android.App.ProgressDialog(GetActivity()); progressDialog.SetIndeterminate(true); progressDialog.SetMessage(GetString(GetArguments().GetInt(ARG_MESSAGE))); return progressDialog; }
private bool LoadData(DateTime dateFrom, DateTime dateTo, bool includeCosts, bool includeEarnings) { Log.Debug(TAG, $"{nameof(LoadData)} - {nameof(dateFrom)}:{dateFrom.ToString()}, {nameof(dateTo)}:{dateTo.ToString()}, {nameof(includeCosts)}:{includeCosts.ToString()},{nameof(includeEarnings)}:{includeEarnings}"); this.Activity.RunOnUiThread(() => { Log.Debug(TAG, "[1] Starting dialog."); dialog = this.Activity.ProgressDialogShow(dialog); Log.Debug(TAG, "[2] Dialog started."); }); try { // Refresh review var rAll = db.Select <Record, DateTime>((o) => o.Id > 0, (o) => o.Date, false).Result; var listAll = rAll.ToList(); if (listAll != null && listAll.Count > 0) { // Filtered values if (includeCosts == false && includeEarnings == false) { listData = new List <Record>(); // Month values this.monthCost_value.Text = Convert.ToString(0); } else if (includeCosts == false && includeEarnings == true) { listData = listAll.Where((o) => o.Date.Date >= dateFrom.Date && o.Date.Date <= dateTo.Date && o.Earnings == true).OrderByDescending(o => o.Date).ToList(); // Month values this.monthCost_value.Text = listAll.Where(p => p.Date.Month == DateTime.Now.Month && p.Date.Year == DateTime.Now.Year && p.Earnings == true).Select(p => p.Cost).Sum().ToString(); } else if (includeCosts == true && includeEarnings == false) { listData = listAll.Where((o) => o.Date.Date >= dateFrom.Date && o.Date.Date <= dateTo.Date && o.Earnings == false).OrderByDescending(o => o.Date).ToList(); // Month values this.monthCost_value.Text = listAll.Where(p => p.Date.Month == DateTime.Now.Month && p.Date.Year == DateTime.Now.Year && p.Earnings == false).Select(p => p.Cost).Sum().ToString(); } else if (includeCosts == true && includeEarnings == true) { listData = listAll.Where((o) => o.Date.Date >= dateFrom.Date && o.Date.Date <= dateTo.Date).OrderByDescending(o => o.Date).ToList(); // Month values this.monthCost_value.Text = listAll.Where(p => p.Date.Month == DateTime.Now.Month && p.Date.Year == DateTime.Now.Year).Select(p => p.Cost).Sum().ToString(); } if (listData != null && listData.Count > 0) { this.count_value.Text = listData.Count.ToString(); this.filterCost_value.Text = listData.Select(p => p.Cost).Sum().ToString(); } } else { this.monthCost_value.Text = Convert.ToString(0); listData = new List <Record>(); } // Refresh review this.count_value.Text = listData.Count.ToString(); this.filterCost_value.Text = listData.Select(p => p.Cost).Sum().ToString(); listView.Adapter = new RecordListAdapter(this.Activity, listData, db); return(true); } catch (Exception ex) { Log.Error(TAG, ex.ToString()); throw; } finally { this.Activity.ProgressDialogDismiss(dialog); } return(false); }
//@Override public void OnPreExecute() { //this.mPD = ProgressDialog.Show(BaseActivity.this, BaseActivity.this.getString(pTitleResID), BaseActivity.this.getString(pMessageResID)); this.mPD = ProgressDialog.Show(_this, _this.GetString(pTitleResID), _this.GetString(pMessageResID)); base.OnPreExecute(); }
/// <summary> /// Start adapter detection /// </summary> /// <param name="deviceAddress">Device Bluetooth address</param> /// <param name="deviceName">Device Bleutooth name</param> private void DetectAdapter(string deviceAddress, string deviceName) { Android.App.ProgressDialog progress = new Android.App.ProgressDialog(this); progress.SetCancelable(false); progress.SetMessage(GetString(Resource.String.detect_adapter)); progress.Show(); _sbLog.Clear(); Thread detectThread = new Thread(() => { AdapterType adapterType = AdapterType.Unknown; try { BluetoothDevice device = _btAdapter.GetRemoteDevice(deviceAddress); if (device != null) { BluetoothSocket bluetoothSocket = null; adapterType = AdapterType.ConnectionFailed; if (adapterType == AdapterType.ConnectionFailed) { try { bluetoothSocket = device.CreateRfcommSocketToServiceRecord(SppUuid); if (bluetoothSocket != null) { try { bluetoothSocket.Connect(); } catch (Exception) { // sometimes the second connect is working bluetoothSocket.Connect(); } adapterType = AdapterTypeDetection(bluetoothSocket); } } catch (Exception) { adapterType = AdapterType.ConnectionFailed; } finally { bluetoothSocket?.Close(); } } if (adapterType == AdapterType.ConnectionFailed) { try { // this socket sometimes looses data for long telegrams IntPtr createRfcommSocket = Android.Runtime.JNIEnv.GetMethodID(device.Class.Handle, "createRfcommSocket", "(I)Landroid/bluetooth/BluetoothSocket;"); if (createRfcommSocket == IntPtr.Zero) { throw new Exception("No createRfcommSocket"); } IntPtr rfCommSocket = Android.Runtime.JNIEnv.CallObjectMethod(device.Handle, createRfcommSocket, new Android.Runtime.JValue(1)); if (rfCommSocket == IntPtr.Zero) { throw new Exception("No rfCommSocket"); } bluetoothSocket = GetObject <BluetoothSocket>(rfCommSocket, Android.Runtime.JniHandleOwnership.TransferLocalRef); if (bluetoothSocket != null) { bluetoothSocket.Connect(); adapterType = AdapterTypeDetection(bluetoothSocket); } } catch (Exception) { adapterType = AdapterType.ConnectionFailed; } finally { bluetoothSocket?.Close(); } } } } catch (Exception) { adapterType = AdapterType.ConnectionFailed; } RunOnUiThread(() => { progress.Hide(); progress.Dispose(); switch (adapterType) { case AdapterType.ConnectionFailed: _altertInfoDialog = new AlertDialog.Builder(this) .SetPositiveButton(Resource.String.button_yes, (sender, args) => { ReturnDeviceType(deviceAddress, deviceName); }) .SetNegativeButton(Resource.String.button_no, (sender, args) => { }) .SetCancelable(true) .SetMessage(Resource.String.adapter_connection_failed) .SetTitle(Resource.String.alert_title_error) .Show(); _altertInfoDialog.DismissEvent += (sender, args) => { _altertInfoDialog = null; }; break; case AdapterType.Unknown: { bool yesSelected = false; _altertInfoDialog = new AlertDialog.Builder(this) .SetPositiveButton(Resource.String.button_yes, (sender, args) => { yesSelected = true; }) .SetNegativeButton(Resource.String.button_no, (sender, args) => { }) .SetCancelable(true) .SetMessage(Resource.String.unknown_adapter_type) .SetTitle(Resource.String.alert_title_error) .Show(); _altertInfoDialog.DismissEvent += (sender, args) => { _altertInfoDialog = null; _activityCommon.RequestSendMessage(_appDataDir, _sbLog.ToString(), PackageManager.GetPackageInfo(PackageName, 0), GetType(), (o, eventArgs) => { if (yesSelected) { ReturnDeviceType(deviceAddress, deviceName); } }); }; break; } case AdapterType.Elm327: { _altertInfoDialog = new AlertDialog.Builder(this) .SetNeutralButton(Resource.String.button_ok, (sender, args) => { ReturnDeviceType(deviceAddress + ";" + EdBluetoothInterface.Elm327Tag, deviceName); }) .SetCancelable(true) .SetMessage(Resource.String.adapter_elm_replacement) .SetTitle(Resource.String.alert_title_info) .Show(); _altertInfoDialog.DismissEvent += (sender, args) => { _altertInfoDialog = null; }; TextView messageView = _altertInfoDialog.FindViewById <TextView>(Android.Resource.Id.Message); if (messageView != null) { messageView.MovementMethod = new LinkMovementMethod(); } break; } case AdapterType.Elm327Invalid: case AdapterType.Elm327Fake21: { string message = GetString(adapterType == AdapterType.Elm327Fake21 ? Resource.String.fake_elm_adapter_type : Resource.String.invalid_adapter_type); message += "<br>" + GetString(Resource.String.recommened_adapter_type); _altertInfoDialog = new AlertDialog.Builder(this) .SetNeutralButton(Resource.String.button_ok, (sender, args) => { }) .SetCancelable(true) .SetMessage(Html.FromHtml(message)) .SetTitle(Resource.String.alert_title_error) .Show(); _altertInfoDialog.DismissEvent += (sender, args) => { _altertInfoDialog = null; _activityCommon.RequestSendMessage(_appDataDir, _sbLog.ToString(), PackageManager.GetPackageInfo(PackageName, 0), GetType()); }; TextView messageView = _altertInfoDialog.FindViewById <TextView>(Android.Resource.Id.Message); if (messageView != null) { messageView.MovementMethod = new LinkMovementMethod(); } break; } case AdapterType.Custom: case AdapterType.CustomUpdate: _altertInfoDialog = new AlertDialog.Builder(this) .SetPositiveButton(Resource.String.button_yes, (sender, args) => { ReturnDeviceType(deviceAddress, deviceName, true); }) .SetNegativeButton(Resource.String.button_no, (sender, args) => { ReturnDeviceType(deviceAddress, deviceName); }) .SetCancelable(true) .SetMessage(adapterType == AdapterType.CustomUpdate ? Resource.String.adapter_fw_update : Resource.String.adapter_cfg_required) .SetTitle(Resource.String.alert_title_info) .Show(); _altertInfoDialog.DismissEvent += (sender, args) => { _altertInfoDialog = null; }; break; default: { ReturnDeviceType(deviceAddress, deviceName); break; } } }); }) { Priority = System.Threading.ThreadPriority.Highest }; detectThread.Start(); }
public async Task getData() { Boolean connectivity = con.connectivity(); if (connectivity) { progress = new Android.App.ProgressDialog(Activity); progress.Indeterminate = true; progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner); progress.SetCancelable(false); progress.SetMessage("Please wait..."); progress.Show(); dynamic value = new ExpandoObject(); value.UserId = u_id; string json = JsonConvert.SerializeObject(value); try { JsonValue item = await restService.TaskInbox(Activity, json, geolocation); freq = JsonConvert.DeserializeObject <List <TaskInboxModel> >(item); dbHelper.insertdatainbox(freq); progress.Dismiss(); //if (freq.Count != 0) //{ // recyclerview_layoutmanger = new LinearLayoutManager(Activity, LinearLayoutManager.Vertical, false); // recyclerview.SetLayoutManager(recyclerview_layoutmanger); // recyclerview_adapter = new TaskInboxAdapter(Activity, freq, recyclerview, FragmentManager); // recyclerview.SetAdapter(recyclerview_adapter); //} //else //{ // LayoutParams lparams = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent); // TextView textView = new TextView(Activity); // textView.LayoutParameters = lparams; // lparams.Gravity = GravityFlags.Center; // textView.Text = "Oops ! You haven't assigned any task yet"; // linearLayout.AddView(textView); //} //progress.Dismiss(); } catch (Exception ex) { progress.Dismiss(); } } taskdata = dbHelper.GetTaskInbox(); if (taskdata.Count != 0) { recyclerview_layoutmanger = new LinearLayoutManager(Activity, LinearLayoutManager.Vertical, false); recyclerview.SetLayoutManager(recyclerview_layoutmanger); recyclerview_adapter = new TaskInboxAdapter(Activity, taskdata, recyclerview, FragmentManager); recyclerview.SetAdapter(recyclerview_adapter); } else { LayoutParams lparams = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); TextView textView = new TextView(Activity); textView.LayoutParameters = lparams; textView.Text = "Oops ! You haven't assigned any task yet"; linearLayout.AddView(textView); } }
public async Task getData() { progress = new Android.App.ProgressDialog(Activity); progress.Indeterminate = true; progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner); progress.SetCancelable(false); progress.SetMessage("Please wait..."); progress.Show(); dynamic value = new ExpandoObject(); value.UserId = userid; string json = JsonConvert.SerializeObject(value); try { JsonValue item = await restService.TaskOutbox(Activity, json, geolocation); List <TaskOutboxModel> taskOutbox = JsonConvert.DeserializeObject <List <TaskOutboxModel> >(item); dbHelper.insertdataoutbox(taskOutbox); for (int i = 0; i < taskOutbox.Count; i++) { TaskOutboxModel detail = new TaskOutboxModel { TaskPercentage = taskOutbox[i].TaskPercentage, Task_id = taskOutbox[i].Task_id, Task_name = taskOutbox[i].Task_name, Description = taskOutbox[i].Description, deadline_date = taskOutbox[i].deadline_date, mark_to = taskOutbox[i].mark_to, task_status = taskOutbox[i].task_status, Task_created_by = taskOutbox[i].Task_created_by, Task_creation_date = taskOutbox[i].Task_creation_date, task_mark_by = taskOutbox[i].task_mark_by, MarkingDate = taskOutbox[i].MarkingDate, task_marking_type = taskOutbox[i].task_marking_type }; im_model.Add(detail); } if (im_model.Count != 0) { recyclerview_layoutmanger = new LinearLayoutManager(Activity, LinearLayoutManager.Vertical, false); recyclerview.SetLayoutManager(recyclerview_layoutmanger); recyclerview_adapter = new TaskOutboxAdapter(Activity, im_model, recyclerview, FragmentManager); recyclerview.SetAdapter(recyclerview_adapter); } else { TextView textView = new TextView(Activity); textView.Text = "Oops ! You haven't assigned any task yet"; LinearLayout.AddView(textView); } progress.Dismiss(); } catch (Exception ex) { progress.Dismiss(); } progress.Dismiss(); }
private void ExecuteTestFormat() { _textViewTestFormatOutput.Text = string.Empty; if ((_selectedJob == null) || (_selectedResult == null)) { return; } Android.App.ProgressDialog progress = new Android.App.ProgressDialog(this); progress.SetCancelable(false); progress.SetMessage(GetString(Resource.String.xml_tool_execute_test_job)); progress.Show(); string resultText = string.Empty; bool executeFailed = false; Thread jobThread = new Thread(() => { try { _ediabas.ResolveSgbdFile(_ecuInfo.Sgbd); _ediabas.ArgString = string.Empty; _ediabas.ArgBinaryStd = null; _ediabas.ResultsRequests = string.Empty; _ediabas.ExecuteJob(_selectedJob.Name); List <Dictionary <string, EdiabasNet.ResultData> > resultSets = _ediabas.ResultSets; if (resultSets != null && resultSets.Count >= 2) { int dictIndex = 0; foreach (Dictionary <string, EdiabasNet.ResultData> resultDict in resultSets) { if (dictIndex == 0) { dictIndex++; continue; } EdiabasNet.ResultData resultData; if (resultDict.TryGetValue(_selectedResult.Name, out resultData)) { resultText = EdiabasNet.FormatResult(resultData, _selectedResult.Format) ?? string.Empty; break; } dictIndex++; } } } catch (Exception) { executeFailed = true; } RunOnUiThread(() => { progress.Hide(); progress.Dispose(); _textViewTestFormatOutput.Text = resultText; if (executeFailed) { _activityCommon.ShowAlert(GetString(Resource.String.xml_tool_read_test_job_failed), Resource.String.alert_title_error); } }); }); jobThread.Start(); }
public DoAsync_Callback(BaseActivity _this, ProgressDialog pd, andengine.util.Callback <T> pCallback) { this._this = _this; this.pCallback = pCallback; }