private CustomDialogProfileSharingData OpenMiniProfileDialog() { var cdd = new CustomDialogProfileSharingData(Activity); var lp = new WindowManagerLayoutParams(); lp.CopyFrom(cdd.Window.Attributes); lp.Width = ViewGroup.LayoutParams.MatchParent; lp.Height = ViewGroup.LayoutParams.MatchParent; cdd.Show(); cdd.Window.Attributes = lp; return(cdd); }
private CustomDialogProfileSharingData OpenMiniProfileDialog() { var cdd = new CustomDialogProfileSharingData(Activity); var windowManager = Context.GetSystemService(Context.WindowService).JavaCast <IWindowManager>(); var lp = new WindowManagerLayoutParams(); lp.CopyFrom(cdd.Window.Attributes); lp.Width = ViewGroup.LayoutParams.MatchParent; lp.Height = ViewGroup.LayoutParams.MatchParent; cdd.Show(); cdd.Window.Attributes = lp; return(cdd); }
private async void BtnScan_Click(object sender, EventArgs e) { JSONObject qrJsonData = await Utils.ScanEncryptedQrCode(Activity); if (qrJsonData == null) { return; } try { CustomDialogProfileSharingData dialog = OpenMiniProfileDialog(); dialog.Name.Text = qrJsonData.GetString("Name"); Glide.With(this).Load(qrJsonData.GetString("Avatar")).Into(dialog.Image); dialog.ButtonConfirm.Click += (o, args) => { Task.Run(async() => { Log.Error("ListaConexiuni", "send data"); Log.Error("qrjsondata", qrJsonData + " "); var response = await WebServices.WebServices.Post($"{Constants.PublicServerAddress}/api/newSharingPeople", new JSONObject().Put("from", qrJsonData.GetString("Id")).Put("dest", Utils.GetDefaults("Id")), Utils.GetDefaults("Token")); Log.Error("SharingData scan", response + " "); if (!string.IsNullOrEmpty(response)) { Log.Error("SharingData scan", response); // Activity.RunOnUiThread(() => Toast.MakeText(Activity, response, ToastLength.Long).Show()); } //Activity.RunOnUiThread(() => ); }).Wait(); dialog.Dismiss(); }; dialog.ButtonCancel.Click += (o, args) => { dialog.Dismiss(); }; } catch (JSONException ex) { Toast.MakeText(Activity, "Cod Invalid", ToastLength.Long).Show(); ex.PrintStackTrace(); } }
private async void LoadData(View view) { try { var progressBarDialog = new ProgressBarDialog("Asteptati", "Se incarca datele...", Activity, false); progressBarDialog.Show(); // Initialize contacts List <SharingModel> contacts = null; await Task.Run(async() => { string response = await WebServices.WebServices.Post($"{Constants.PublicServerAddress}/api/getSharedPeople", new JSONObject().Put("id", Utils.GetDefaults("Id")), Utils.GetDefaults("Token")); if (!string.IsNullOrEmpty(response)) { contacts = JsonConvert.DeserializeObject <List <SharingModel> >(response); Log.Error("ListaConexiuni", "No. of contacts: " + contacts.Count); } }); Activity.RunOnUiThread(() => { progressBarDialog.Dismiss(); }); if (contacts != null) { var adapter = new SharingAdapter(contacts); _sharingRecyclerView.SetAdapter(adapter); _sharingRecyclerView.SetLayoutManager(new LinearLayoutManager(Activity)); adapter.ItemClick += delegate(object sender, SharingAdapterClickEventArgs args) { string name = contacts[args.Position].Name; string email = contacts[args.Position].Email; CustomDialogProfileSharingData dialog = OpenMiniProfileDialog(); dialog.Name.Text = name; Glide.With(this).Load($"{Constants.PublicServerAddress}/{contacts[args.Position].Avatar}").Into(dialog.Image); dialog.ButtonConfirm.Visibility = ViewStates.Gone; dialog.ButtonCancel.Text = "Sterge"; dialog.ButtonCancel.SetPadding(5, 5, 5, 5); dialog.ButtonCancel.Click += delegate { AlertDialog alertDialog = new AlertDialog.Builder(Activity, Resource.Style.AppTheme_Dialog).Create(); alertDialog.SetTitle("Avertisment"); alertDialog.SetMessage("Doriti sa stergeti aceasta conexiune?"); alertDialog.SetButton("Da", async delegate { SharingModel obj = adapter.getItemAt(args.Position); adapter.DeleteItemAt(args.Position); adapter.NotifyDataSetChanged(); //item deleted from list, call server await sendData(obj); dialog.Dismiss(); // var serialized = JsonConvert.SerializeObject(contacts); // Utils.SetDefaults("Rooms", serialized, Activity); }); alertDialog.SetButton2("Nu", delegate { }); alertDialog.Show(); }; }; adapter.ItemLongClick += delegate(object sender, SharingAdapterClickEventArgs args) { if (Build.VERSION.SdkInt >= BuildVersionCodes.O) { AlertDialog alertDialog = new AlertDialog.Builder(Activity, Resource.Style.AppTheme_Dialog).Create(); alertDialog.SetTitle("Avertisment"); alertDialog.SetMessage("Doriti sa stergeti aceasta conexiune?"); alertDialog.SetButton("Da", delegate { adapter.DeleteItemAt(args.Position); adapter.NotifyDataSetChanged(); // var serialized = JsonConvert.SerializeObject(contacts); // Utils.SetDefaults("Rooms", serialized, Activity); }); alertDialog.SetButton2("Nu", delegate { }); alertDialog.Show(); } else { AlertDialog alertDialog = new AlertDialog.Builder(Activity, Resource.Style.AppTheme_Dialog).Create(); alertDialog.SetTitle("Avertisment"); alertDialog.SetMessage("Doriti sa stergeti aceasta conexiune?"); alertDialog.SetButton("Da", delegate { adapter.DeleteItemAt(args.Position); adapter.NotifyDataSetChanged(); // var serialized = JsonConvert.SerializeObject(contacts); // Utils.SetDefaults("Rooms", serialized, Activity); }); alertDialog.SetButton2("Nu", delegate { //just close dialog }); alertDialog.Show(); } }; } } catch (Exception e) { e.PrintStackTrace(); } }