public void Start()
    {
        loggedInUser      = GameObject.Find("LoggedUserText").GetComponent <Text>();
        loggedInUser.text = NOT_LOGGED_IN;

        authServiceManager = new AuthServiceManager();
        authServiceManager.GetInstance();
        authServiceManager.OnSignInSuccess = OnAuthSericeSignInSuccess;
        authServiceManager.OnSignInFailed  = OnAuthSericeSignInFailed;

        if (authServiceManager.GetCurrentUser() != null)
        {
            user = authServiceManager.GetCurrentUser();
            loggedInUser.text = user.IsAnonymous() ? LOGGED_IN_ANONYMOUSLY : string.Format(LOGGED_IN, user.DisplayName);
        }
        else
        {
            SignInWithHuaweiAccount();
        }

        cloudDBManager = new CloudDBManager();
        cloudDBManager.Initialize();
        cloudDBManager.GetInstance();
        cloudDBManager.OnExecuteQuerySuccess = OnExecuteQuerySuccess;
        cloudDBManager.OnExecuteQueryFailed  = OnExecuteQueryFailed;
    }
Beispiel #2
0
        private async void SetupUI()
        {
            PreferenceHelper.Init(this);
            loadingCircle.Visibility = ViewStates.Visible;

            if (File.Exists(ideasdbPath))
            {
                var cachedDb = await DBAssist.DeserializeDBAsync <List <Category> >(ideasdbPath);

                if (cachedDb != null)
                {
                    Global.Categories = cachedDb;
                    categoryList.AddRange(cachedDb);
                    SetupList();
                    CloudDBManager.StartLowkeyInvalidation();
                }

                else
                {
                    File.Delete(ideasdbPath);
                    SetupUI();
                }
            }

            else
            {
                var snack = Snackbar.Make(bookmarksFab, "Getting ideas from server. Please wait.", Snackbar.LengthIndefinite);
                snack.Show();
                var db = await CloudDBManager.DownloadDB(SetupUI, snack);

                if (db != null)
                {
                    Global.Categories = db;
                    snack.Dismiss();
                    categoryList = db;
                    SetupList();
                }
                else
                {
                    loadingCircle.Visibility = ViewStates.Gone;
                }
            }
        }