private async void GetPoselData()
        {
            IPeopleRepository repository = PeopleRepository.Instance;

            try {
                posel = await repository.GetPosel(id);

                tvImie.Text         = posel.Imie;
                tvNazwisko.Text     = posel.Nazwisko;
                tvDataZawod.Text    = String.Concat(posel.DataUrodzenia, ". ", posel.Zawod);
                tvPartiaOkreg.Text  = String.Concat(posel.SejmKlubyNazwa, ". Okręg nr: ", posel.OkregWyborczyNumer);
                tvUstawy.Text       = posel.LiczbaProjektowUstaw.ToString();
                tvUchwaly.Text      = posel.LiczbaProjektowUchwal.ToString();
                tvFrekwencja.Text   = String.Concat(posel.Frekwencja.ToString(), "%");
                tvZamieszkanie.Text = posel.MiejsceZamieszkania;

                string imgUrl = posel.GetWebURL();

                AQuery aq = new AQuery(Activity);

                Bitmap imgLoading = aq.GetCachedImage(Android.Resource.Drawable.IcMenuGallery);

                ((AQuery)aq.Id(Resource.Id.miniature)).Image(imgUrl, true, true, 0, 0, imgLoading, 0, 1f);

                //loadImage (ivMiniature, );

                BiuroPoselskie biuroGlowne = posel.Biura.Where(item => item.Podstawowe.Equals("1")).FirstOrDefault();

                if (biuroGlowne != null)
                {
                    String phone = "";
                    try {
                        String[] phones    = biuroGlowne.Telefon.Split('f');
                        String[] phone1    = phones[0].Split(' ');
                        String   firstpart = phones[1].Split('(')[1].Split(')')[0];
                        phone = String.Concat(firstpart, " ", phone1[2].Replace('-', ' '));
                    }catch (Exception e) {
                        Log.Error("PhoneParse", e.Message);
                        phone = biuroGlowne.Telefon;
                    }
                    tvTelefon.Text = phone;

                    tvTelefon.Click += delegate {
                        var uri    = Android.Net.Uri.Parse("tel:" + phone.Replace(" ", string.Empty));
                        var intent = new Intent(Intent.ActionView, uri);
                        StartActivity(intent);
                    };

                    tvEmail.Text = biuroGlowne.Email;
                }

                if (viewSwitcher.CurrentView != contentLayout)
                {
                    viewSwitcher.ShowPrevious();
                }
            } catch (ApiRequestException ex) {
                personDetailsActivity.ShowErrorDialog(ex.Message);
            } catch (Exception exc) {
                //raportowanie błędów przy ładowaniu danych
                Xamarin.Insights.Report(exc);
            }
        }
Exemple #2
0
        private async void GetPoselData()
        {
            IPeopleRepository repository = PeopleRepository.Instance;

            try {
                posel = await repository.GetPosel((ParentViewController as PoselController).PoselID);



                BiuroPoselskie biuroGlowne = posel.Biura.Where(item => item.Podstawowe.Equals("1")).FirstOrDefault();

                if (biuroGlowne != null)
                {
                    String phone = "";
                    try {
                        String[] phones    = biuroGlowne.Telefon.Split('f');
                        String[] phone1    = phones[0].Split(' ');
                        String   firstpart = phones[1].Split('(')[1].Split(')')[0];
                        phone = String.Concat(firstpart, " ", phone1[2].Replace('-', ' '));
                    }catch (Exception e) {
                        System.Diagnostics.Debug.WriteLine(e.Message);
                        phone = biuroGlowne.Telefon;
                    }
                    Telephone.Text = phone;

                    /*
                     * Telephone.Click += delegate {
                     *      var uri = Android.Net.Uri.Parse ("tel:" + phone.Replace(" ", string.Empty));
                     *      var intent = new Intent (Intent.ActionView, uri);
                     *      StartActivity (intent);
                     * };
                     */// TODO : Telephone click

                    Email.Text = biuroGlowne.Email;
                }


                NameLabel.Text          = posel.Imie + " " + posel.Nazwisko;
                BirthdayOccupation.Text = String.Concat(posel.DataUrodzenia, ". ", posel.Zawod);
                PartiaOkreg.Text        = String.Concat(posel.SejmKlubyNazwa, ". Okręg nr: ", posel.OkregWyborczyNumer);
                UstawyUchwaly.Text      = String.Concat(
                    "Ustawy: ", posel.LiczbaProjektowUstaw.ToString(),
                    "   Uchwały: ", posel.LiczbaProjektowUchwal.ToString()
                    );
                Frequency.Text = String.Concat("Frekwencja: ", posel.Frekwencja.ToString(), "%");
                FromWhere.Text = posel.MiejsceZamieszkania;

                ParentViewController.Title = NameLabel.Text;
                var imgUrl = posel.GetWebURL();
                PoselImage.SetImage(
                    url: new NSUrl(imgUrl),
                    placeholder: UIImage.FromBundle("ImageLoad")
                    );

                loadingOverlay.Hide();
            } catch (ApiRequestException ex) {
                DisplayError(ex.Message);
                System.Diagnostics.Debug.WriteLine(ex.Message);
            } catch (Exception exc) {
                System.Diagnostics.Debug.WriteLine(exc.Message);
            } finally {
                loadingOverlay.Hide();
            }
        }