Esempio n. 1
0
    private IEnumerator DownloadOriginalImageInternal(ImageSphereType imageSphereType)
    {
        yield return(m_appDirector.VerifyInternetConnection());

        m_loadingIcon.Display();

        yield return(RefreshProfileData());

        if (m_backEndAPI.IsLastAPICallSuccessful())
        {
            if (imageSphereType == ImageSphereType.kProfile)
            {
                if (Debug.isDebugBuild)
                {
                    Debug.Log("------- VREEL: DownloadOriginalImageInternal() loading User Original Image for: " + m_originalUrl);
                }

                m_imageLoader.LoadImageFromURLIntoImageSphere(m_imageSphereController, Helper.kSkyboxSphereIndex, Helper.kIgnoreImageIndex, m_originalUrl, m_userId, true);
            }
            else if (imageSphereType == ImageSphereType.kMenuBar)
            {
                if (Debug.isDebugBuild)
                {
                    Debug.Log("------- VREEL: DownloadOriginalImageInternal() loading User Original Image for: " + m_loggedUserOriginalUrl);
                }

                m_imageLoader.LoadImageFromURLIntoImageSphere(m_imageSphereController, Helper.kSkyboxSphereIndex, Helper.kIgnoreImageIndex, m_loggedUserOriginalUrl, m_user.m_id, true);
            }
        }

        m_loadingIcon.Hide();
    }
Esempio n. 2
0
    private IEnumerator DeletePostInternal(string id)
    {
        yield return(m_appDirector.VerifyInternetConnection());

        if (Debug.isDebugBuild)
        {
            Debug.Log("------- VREEL: Delete() called on post: " + id);
        }

        m_loadingIcon.Display();

        yield return(m_backEndAPI.Post_DeletePost(id));

        if (m_backEndAPI.IsLastAPICallSuccessful())
        {
            // TODO: Report Success!
            m_posts.RequestPostRemoval(id);
        }
        else
        {
            // TODO: Report Failure!
        }

        Close();

        m_profile.OpenUserProfile();

        m_loadingIcon.Hide();
    }
Esempio n. 3
0
    private IEnumerator LoginInternal()
    {
        yield return(m_appDirector.VerifyInternetConnection());

        if (Debug.isDebugBuild)
        {
            Debug.Log("------- VREEL: LogIn() called");
        }

        m_loadingIcon.Display();

        yield return(m_backEndAPI.Session_SignIn(
                         m_loginUsernameEmailInput.text,
                         m_loginPasswordInput.GetComponent <PasswordText>().GetString(),
                         m_user.GetPushNotificationUserID()
                         ));

        m_loadingIcon.Hide();

        if (m_backEndAPI.IsLastAPICallSuccessful())
        {
            CloseLogin();
            m_appDirector.RefreshCurrentState();
            m_profile.SetMenuBarProfileDetails();
        }
    }
Esempio n. 4
0
    private IEnumerator StoreFirstPostsAndSetSpheres()
    {
        yield return(m_appDirector.VerifyInternetConnection());

        if (Debug.isDebugBuild)
        {
            Debug.Log("------- VREEL: StoreFirstPostsAndSetSpheres() called for PostType: " + m_postsType.ToString());
        }

        m_loadingIcon.Display(); //NOTE: This should stop the following operation from ever being cut half-way through

        m_posts.Clear();

        yield return(GetPosts());

        if (m_backEndAPI.IsLastAPICallSuccessful())
        {
            StoreNewPosts();
        }

        m_currPostIndex = 0; // set to a valid Index
        m_coroutineQueue.EnqueueAction(DownloadThumbnailsAndSetSpheres());

        m_loadingIcon.Hide();
    }
Esempio n. 5
0
        private void OnWeiBoLogin(object sender, RoutedEventArgs e)
        {
            Hide();
            LoadingIcon.Display();
            AuthorizationHelper.Login(LoginType.Sina, null, 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
                    });
                }
                else
                {
                    PopupMessage.DisplayMessageInRes("LoginFailed");
                }
                LoadingIcon.Hide();
            });
        }
        private async void PostToCirclePage_Loaded(object sender, RoutedEventArgs arg)
        {
            LoadingIcon.Display();
            OwnCircles = await DataRequester.GetOwnCircles();

            if (OwnCircles.Circles != null && OwnCircles.Circles.Count > 0)
            {
                CurrentCircle            = OwnCircles.Circles[0];
                CurrentCircleBtn.Content = CurrentCircle.Name;
                OwnCircles.Circles.ForEach(circle => {
                    var menuItem = new MenuFlyoutItem()
                    {
                        Text = circle.Name, Tag = circle
                    };
                    menuItem.Click += (s, e) => { CurrentCircle = ((OwnCircleInfo)((MenuFlyoutItem)s).Tag); CurrentCircleBtn.Content = CurrentCircle.Name; };
                    CircleMenu.Items.Add(menuItem);
                });
            }
            else if (_needCreateCircle)
            {
                LLQNotifier.Default.Notify(new StoryEvent()
                {
                    Type = StoryEventType.CreateCircle
                });
                PopupMessage.DisplayMessageInRes("NoCircle");
            }
            LoadingIcon.Hide();
        }
Esempio n. 7
0
    private IEnumerator LogoutInternal()
    {
        yield return(m_appDirector.VerifyInternetConnection());

        if (Debug.isDebugBuild)
        {
            Debug.Log("------- VREEL: LogOut() called");
        }

        m_loadingIcon.Display();

        yield return(m_backEndAPI.Session_SignOut());

        m_loadingIcon.Hide();

        if (m_backEndAPI.IsLastAPICallSuccessful())
        {
            CloseOptions();
            m_appDirector.RefreshCurrentState();
            m_profile.SetMenuBarProfileDetails();
        }
    }
Esempio n. 8
0
    // **************************
    // 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();
        }
    }
Esempio n. 9
0
        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();
            });
        }
Esempio n. 10
0
    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();
        }
    }