コード例 #1
0
 private void GetOwnerInfo()
 {
     try
     {
         if (PermissionsHelper.HasPermission(this, ConstantsAndTypes.AppPermission.ReadContacts) && PermissionsHelper.PermissionGranted(this, ConstantsAndTypes.AppPermission.ReadContacts))
         {
             ContactsHelper contactHelper = new ContactsHelper(this);
             if (contactHelper.ReadProfile())
             {
                 string ownerUri       = contactHelper.DeviceOwner.ThumbnailUri;
                 string ownerFirstName = contactHelper.DeviceOwner.FirstName;
                 string ownerSurname   = contactHelper.DeviceOwner.Surname;
                 if (_ownerThumb != null)
                 {
                     if (!string.IsNullOrEmpty(ownerUri))
                     {
                         ImageryHelper imageHelper = new ImageryHelper(this, _ownerThumb);
                         imageHelper.GetImageFromStringUri(contactHelper.DeviceOwner.ThumbnailUri);
                     }
                     else
                     {
                         _ownerThumb.SetImageResource(Resource.Drawable.ic_launcher);
                     }
                 }
                 if (_ownerWelcome != null)
                 {
                     if (!(string.IsNullOrEmpty(ownerFirstName) || string.IsNullOrEmpty(ownerSurname)))
                     {
                         _ownerWelcome.Text = GetString(Resource.String.WelcomeMindYourMood) + " " + contactHelper.DeviceOwner.FirstName + " " + contactHelper.DeviceOwner.Surname;
                     }
                     else
                     {
                         _ownerWelcome.Text = GetString(Resource.String.WelcomeMindYourMoodNoContacts);
                     }
                 }
             }
         }
         else
         {
             if (_ownerWelcome != null)
             {
                 _ownerWelcome.Text = GetString(Resource.String.WelcomeMindYourMoodNoContacts);
             }
             if (_ownerThumb != null)
             {
                 _ownerThumb.SetImageResource(Resource.Drawable.ic_launcher);
             }
         }
     }
     catch (Exception e)
     {
         Log.Error(TAG, "GetOwnerInfo: Exception - " + e.Message);
         if (GlobalData.ShowErrorDialog)
         {
             ErrorDisplay.ShowErrorAlert(this, e, GetString(Resource.String.ErrorMainGetOwnerInfo), "MainActivity.GetOwnerInfo");
         }
     }
 }
コード例 #2
0
 private void GetPositivePictureForToday()
 {
     try
     {
         ImageryHelper imageHelper = new ImageryHelper(this, _pictureOfTheDay);
         imageHelper.GetPositivePictureOfTheDay();
         _currentPictureUri = imageHelper.PictureOfTheDayUri;
     }
     catch (Exception e)
     {
         Log.Error(TAG, "GetPositivePictureForToday: Exception - " + e.Message);
         if (GlobalData.ShowErrorDialog)
         {
             ErrorDisplay.ShowErrorAlert(this, e, GetString(Resource.String.ErrorMainActivityPositivePic), "SummaryActivity.GetPositivePictureForToday");
         }
     }
 }