// ************************** // Private/Helper functions // ************************** private IEnumerator LoadImageFromPathIntoImageSphereInternal(ImageSphereController imageSphereController, int sphereIndex, int galleryImageIndex, string filePathAndIdentifier, bool showLoading, int maxImageWidth) { if (galleryImageIndex != Helper.kIgnoreImageIndex && !m_gallery.IsValidRequest(galleryImageIndex)) { yield break; } m_isLoading = true; if (showLoading) { m_loadingIcon.Display(); } int textureIndex = GetAvailableTextureIndex(); yield return(m_cppPlugin.LoadImageFromPathIntoImageSphere(imageSphereController, sphereIndex, filePathAndIdentifier, textureIndex, maxImageWidth)); m_isLoading = false; if (showLoading) { m_loadingIcon.Hide(); } }
private void OnLogin(object sender, RoutedEventArgs e) { var userName = UserNameTxt.Text.Trim(); userName = StringUtil.CheckPhoneNum(userName) ? "+86" + userName : userName; var password = PasswordTxt.Password.Trim(); var captcha = CaptchaTxt.Text.Trim(); LoadingIcon.Display(); AuthorizationHelper.Login(LoginType.ZhiHu, new ZhiHuLoginInfo() { Captcha = NeedCaptcha ? captcha : null, UserName = userName, Password = password }, loginSuccess => { if (loginSuccess) { PopupMessage.DisplayMessageInRes("LoginSuccess"); var info = StorageInfo.Instance.ZhiHuAuthoInfo; if (info == null) { return; } LLQNotifier.Default.Notify(new LoginEvent() { IsLogin = true, UserPhotoUrl = info.avatar }); Hide(); } else { GetCaptchaImage(); } LoadingIcon.Hide(); }); }
private IEnumerator UploadImageInternal(string filePath, bool profilePic = false) //NOTE: Ensured that this function cannot be stopped midway because the LoadingIcon blocks UI { yield return(m_appDirector.VerifyInternetConnection()); m_loadingIcon.Display(); if (Debug.isDebugBuild) { Debug.Log("------- VREEL: Running UploadImageInternal() for image with path: " + filePath); } //0) Delete temporary file's if they somehow still exist... string originalImageFilePath = filePath; string tempThumbnailPath = m_imagesTopLevelDirectory + "/tempThumbnailImage.png"; string tempOriginalPath = m_imagesTopLevelDirectory + "/tempOriginalImage.png"; if (File.Exists(tempThumbnailPath)) { File.Delete(tempThumbnailPath); } if (File.Exists(tempOriginalPath)) { File.Delete(tempOriginalPath); } // 1) Get PresignedURL yield return(m_backEndAPI.S3_PresignedURL()); // 2) Create Thumbnail from Original image bool successfullyCreatedThumbnail = false; bool successfullyCreatedMaxResolutionImage = false; if (m_backEndAPI.IsLastAPICallSuccessful()) { bool isDebugBuild = Debug.isDebugBuild; m_threadJob.Start(() => successfullyCreatedThumbnail = CreateSmallerImageWithResolution(originalImageFilePath, tempThumbnailPath, Helper.kThumbnailWidth, isDebugBuild) ); yield return(m_threadJob.WaitFor()); m_threadJob.Start(() => successfullyCreatedMaxResolutionImage = CreateSmallerImageWithResolution(originalImageFilePath, tempOriginalPath, Helper.kMaxImageWidth, isDebugBuild) ); yield return(m_threadJob.WaitFor()); } // 3) Upload Original if (m_backEndAPI.IsLastAPICallSuccessful() && successfullyCreatedThumbnail && successfullyCreatedMaxResolutionImage) { yield return(m_backEndAPI.UploadObject( m_backEndAPI.GetS3PresignedURLResult().data.attributes.original.url.ToString(), originalImageFilePath )); } // 4) Upload Thumbnail if (m_backEndAPI.IsLastAPICallSuccessful() && successfullyCreatedThumbnail && successfullyCreatedMaxResolutionImage) { yield return(m_backEndAPI.UploadObject( m_backEndAPI.GetS3PresignedURLResult().data.attributes.thumbnail.url.ToString(), tempThumbnailPath )); } // 5) Register Post as Created if (m_backEndAPI.IsLastAPICallSuccessful() && successfullyCreatedThumbnail && successfullyCreatedMaxResolutionImage) { string captionText = m_captionNewText.GetComponentInChildren <Text>().text; Helper.TruncateString(ref captionText, Helper.kMaxCaptionOrDescriptionLength); if (profilePic) { yield return(m_backEndAPI.Register_UpdateProfileImage( m_backEndAPI.GetS3PresignedURLResult().data.attributes.thumbnail.key.ToString(), m_backEndAPI.GetS3PresignedURLResult().data.attributes.original.key.ToString() )); } else { yield return(m_backEndAPI.Post_CreatePost( m_backEndAPI.GetS3PresignedURLResult().data.attributes.thumbnail.key.ToString(), m_backEndAPI.GetS3PresignedURLResult().data.attributes.original.key.ToString(), captionText )); } } //6) Delete temporary thumbnail file if (successfullyCreatedThumbnail) { File.Delete(tempThumbnailPath); } if (successfullyCreatedMaxResolutionImage) { File.Delete(tempOriginalPath); } yield return(null); // 7) If there has been a successful upload -> Inform user that image has been uploaded if (Debug.isDebugBuild) { Debug.Log("------- VREEL: Uploaded image: " + originalImageFilePath + ", with Success: " + (m_backEndAPI.IsLastAPICallSuccessful() && successfullyCreatedThumbnail && successfullyCreatedMaxResolutionImage)); } if (m_backEndAPI.IsLastAPICallSuccessful()) { //TODO: SHOW A SUCCESS MESSAGE! } m_imageFlow.Close(); m_loadingIcon.Hide(); if (profilePic) { m_profile.SetMenuBarProfileDetails(); } }