public static void RemoveImageFromCache(string imagePath) { SDWebImageManager.SharedManager.ImageCache.RemoveImage(EnvironmentConstants.getS3Url() + imagePath, true, completion: () => { Console.WriteLine(EnvironmentConstants.getS3Url() + imagePath + " removed from cache"); }); }
private void CommentButton_TouchUpInside(object sender, EventArgs e) { SurveyCommentModel surveyCommentModel = new SurveyCommentModel(); surveyCommentModel.text = commentArea.CommentText.Text; surveyCommentModel.surveyId = survey.userId + survey.creationDate; surveyCommentModel.profilePicture = LoginController.userModel.profilePicturePath; surveyCommentModel.userId = LoginController.userModel.id; surveyCommentModel.userName = LoginController.userModel.name; surveyCommentModel.commentDate = EnvironmentConstants.getServerDateTime().ToString("yyyyMMddTHHmmssfff"); comments.Add(surveyCommentModel); var indexes = new NSIndexPath[] { NSIndexPath.FromItemSection(comments.IndexOf(comments.Last()), 0) }; createComment(surveyCommentModel, indexes); feed.InsertItems(indexes); feed.ScrollToItem(indexes.First(), UICollectionViewScrollPosition.Bottom, true); commentArea.CommentText.Text = null; commentArea.CommentButton.Enabled = false; View.EndEditing(true); ScrollTheView(false); }
public void SocialLogin(string provider) { string returnUrlLogin = "******"; string externalProviderUrl = EnvironmentConstants.getServerUrl() + "api/Account/ExternalLogin?provider=" + provider + "&response_type=token&client_id=self&redirect_uri=" + returnUrlLogin + "&isAdmin=1"; sfViewController = new SFSafariViewController(new NSUrl(externalProviderUrl)); PresentViewControllerAsync(sfViewController, true); }
public static UIImage GetImageFromNSUrl(string imagePath) { UIImage result = null; SDWebImageManager.SharedManager.Download(new NSUrl(EnvironmentConstants.getS3Url() + imagePath), SDWebImageOptions.ProgressiveDownload, //HighPriority progressBlock: (receivedSize, completedSize) => { //do nothing }, completedBlock: (image, error, cacheType, finished, imageUrl) => { Console.WriteLine("Image = " + image); Console.WriteLine("Error = " + error); Console.WriteLine("Cache Type = " + cacheType); Console.WriteLine("Finished = " + finished); if (error != null && error.ToString().Contains("1100")) { SDWebImageManager.SharedManager.Download(new NSUrl(EnvironmentConstants.getS3Url() + imagePath), SDWebImageOptions.RetryFailed, progressBlock: (receivedSize, completedSize) => { //do nothing }, completedBlock: (image1, error1, cacheType1, finished1, imageUrl1) => { Console.WriteLine("Image1 = " + image); Console.WriteLine("Error1 = " + error); Console.WriteLine("Cache Type1 = " + cacheType); Console.WriteLine("Finished1 = " + finished); if (image1 != null) { result = image1; } }); } if (image != null && result == null) { result = image; } } ); return(result); }
public static DateTime ConvertToLocalTime(DateTime date) { return(TimeZoneInfo.ConvertTimeBySystemTimeZoneId(date, EnvironmentConstants.getServerTimeZone(), TimeZoneInfo.Local.Id)); }
//public static void SetImageFromNSUrlSession(string imagePath, UIImageView imageView, NSCache imageCache = null) //{ // UIImage imageFromCache = null; // var url = new NSUrl(EnvironmentConstants.getS3Url() + imagePath); // var noCacheStr = "?nocache=" + String.Format("{0:yyyyMMddHHmmssffff}", DateTime.Now); // var fetchUrl = new NSUrl(EnvironmentConstants.getS3Url() + imagePath + noCacheStr); // if (imageCache != null) // { // imageFromCache = (UIImage)imageCache.ObjectForKey(NSString.FromObject(url.AbsoluteString)); // } // if (imageFromCache != null) // { // imageView.Image = imageFromCache; // } // else // { // var task = NSUrlSession.SharedSession.CreateDataTask(fetchUrl, (data, response, error) => // { // try // { // DispatchQueue.MainQueue.DispatchAsync(() => // { // if (response != null && ((NSHttpUrlResponse)response).StatusCode != 403 && error == null) // { // if (imageCache != null) // { // var imageToCache = UIImage.LoadFromData(data); // imageView.Image = imageToCache; // if (imageToCache != null) // { // imageCache.SetObjectforKey(imageToCache, NSString.FromObject(url.AbsoluteString)); // } // } // else // { // imageView.Image = UIImage.LoadFromData(data); // } // } // }); // } // catch (Exception ex) // { // Utils.HandleException(ex); // } // }); // task.Resume(); // } //} public static void SetImageFromNSUrlSession(string imagePath, UIImageView imageView, NSObject controller, PictureType picType) { UIImage placeholder = UIImage.FromBundle("ImagePlaceholder"); try { if (picType.Equals(PictureType.Profile)) { placeholder = UIImage.FromBundle("Profile"); } if (picType.Equals(PictureType.Group)) { placeholder = UIImage.FromBundle("Group"); } imageView.SetImage(new NSUrl(EnvironmentConstants.getS3Url() + imagePath), placeholder, SDWebImageOptions.ProgressiveDownload, //HighPriority progressBlock: (receivedSize, completedSize) => { if (activityIndicator == null) { controller.InvokeOnMainThread(() => { activityIndicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.Gray); imageView.AddSubview(activityIndicator); activityIndicator.Center = imageView.Center; activityIndicator.StartAnimating(); }); } }, completedBlock: (image, error, cacheType, finished) => { Console.WriteLine("Image = " + image); Console.WriteLine("Error = " + error); Console.WriteLine("Cache Type = " + cacheType); Console.WriteLine("Finished = " + finished); if (activityIndicator != null) { controller.InvokeOnMainThread(() => { activityIndicator.RemoveFromSuperview(); activityIndicator = null; }); } if (error != null && error.ToString().Contains("1100")) { imageView.SetImage(new NSUrl(EnvironmentConstants.getS3Url() + imagePath), placeholder, SDWebImageOptions.RetryFailed); } if (image != null) { imageView.Image = image; } }); } catch (Exception e) { Console.WriteLine(e.Message); } }