Exemple #1
0
    //----------------------------------------------------------------------------------------------------------------------------------------------//

    public void PopulateReCheck()
    {
        if (projectsContent.childCount > 0)
        {
            foreach (Transform child in projectsContent)
            {
                Destroy(child.gameObject);
            }
        }

        DataRef.Circles(circlesManager.activeCircleRef).GetValueAsync().ContinueWith(async(task) => {
            await new WaitForUpdate();
            DataSnapshot snapshot = task.Result;

            foreach (DataSnapshot project in snapshot.Child("Projects").Children)
            {
                int donationsMoney   = int.Parse(project.Child("DonationTotal").Value.ToString());
                int donationsMembers = int.Parse(project.Child("Members").ChildrenCount.ToString());
                string projectRef    = project.Child("Reference").Value.ToString();
                InstantiateProject(donationsMembers, donationsMoney, snapshot, projectRef);
            }

            OrganiseList();

            StartCoroutine(CheckForNewComments(0.1f));
        });
    }
Exemple #2
0
    //----------------------------------------------------------------------------------------------------------------------------------------------//

    public void GetLink(string type, string reference)
    {
        messageType = type;
        referenceID = reference;

        if (type == "Project")
        {
            DataRef.Projects(reference).GetValueAsync().ContinueWith(async(task) => {
                await new WaitForUpdate();
                DataSnapshot snapshot = task.Result;

                referenceName = snapshot.Child("ProjectName").Value.ToString();

                SetMessageInfo();
            });
        }
        else if (type == "Circle")
        {
            DataRef.Circles(reference).GetValueAsync().ContinueWith(async(task) => {
                await new WaitForUpdate();
                DataSnapshot snapshot = task.Result;

                referenceName = snapshot.Child("Name").Value.ToString();

                SetMessageInfo();
            });
        }
    }
Exemple #3
0
    //----------------------------------------------------------------------------------------------------------------------------------------------//

    private void AddToCircleTotal(int value)
    {
        DataRef.Circles("Bucket Circle New Zealand").Child("TotalMembers").SetValueAsync(value.ToString()).ContinueWith(async(task) => {
            await new WaitForUpdate();
            if (task.IsCanceled || task.IsFaulted)
            {
                return;
            }
        });
    }
    //----------------------------------------------------------------------------------------------------------------------------------------------//

    private void SetTotalMembers(string circleRef, int value)
    {
        DataRef.Circles(circleRef).Child("TotalMembers").SetValueAsync(value.ToString()).ContinueWith(async(task) => {
            await new WaitForUpdate();
            if (task.IsFaulted || task.IsCanceled)
            {
                print(task.Exception);
                return;
            }
        });
    }
    //----------------------------------------------------------------------------------------------------------------------------------------------//

    private void RemoveReferences(string circleRef, string projectRef, string userRef)
    {
        DataRef.Circles(circleRef).Child("Projects").Child(projectRef).Child("Members").Child(userRef).RemoveValueAsync().ContinueWith(async(task) => {
            await new WaitForUpdate();
            if (task.IsFaulted || task.IsCanceled)
            {
                print(task.Exception);
                return;
            }
        });
    }
    //----------------------------------------------------------------------------------------------------------------------------------------------//

    private void SetProjectTotal(string circleRef, string projectRef, string value)
    {
        DataRef.Circles(circleRef).Child("Projects").Child(projectRef).Child("DonationTotal").SetValueAsync(value).ContinueWith(async(task) => {
            await new WaitForUpdate();
            if (task.IsFaulted || task.IsCanceled)
            {
                print(task.Exception);
                return;
            }
        });
    }
    //----------------------------------------------------------------------------------------------------------------------------------------------//

    private void SetData(string circleRef, string child, string value)
    {
        DataRef.Circles(circleRef).Child(child).SetValueAsync(value).ContinueWith(async(task) => {
            await new WaitForUpdate();
            if (task.IsFaulted || task.IsCanceled)
            {
                print(task.Exception);
                return;
            }
        });
    }
    //----------------------------------------------------------------------------------------------------------------------------------------------//

    private void GetInstance()
    {
        pushKey   = DataRef.Circles(circlesManager.activeCircleRef).Child("Comments").Push().Key;
        date      = DateTime.Now.ToString("MMMM") + " " + DateTime.Now.Day.ToString() + " at " + DateTime.Now.ToString("hh") + ":" + DateTime.Now.Minute.ToString() + " " + DateTime.Now.ToString("tt");
        timestamp = (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond).ToString();
        comment   = displayText.text;
        user      = DataRef.CurrentUser().Key.ToString();

        SetValue("User", user);
        SetValue("Date", date);
        SetValue("Timestamp", timestamp);
        SetValue("Comment", comment);

        inputField.text = "";
    }
    //----------------------------------------------------------------------------------------------------------------------------------------------//

    private void SetPreviewInformation()
    {
        DataRef.Circles(activeCircle).GetValueAsync().ContinueWith(async(task) => {
            await new WaitForUpdate();
            DataSnapshot snapshot = task.Result;

            circlePreview.transform.GetChild(1).GetChild(0).GetChild(0).GetComponent <Text> ().text = snapshot.Child("Name").Value.ToString();
            Sprite img = Resources.Load <Sprite> ("2D/Groups/" + snapshot.Child("SecondaryPictureID").Value.ToString());
            circlePreview.transform.GetChild(1).GetChild(1).GetChild(0).GetChild(0).GetComponent <Image> ().sprite = img;
            circlePreview.transform.GetChild(1).GetChild(1).GetChild(0).GetChild(0).GetComponent <ScaleImageToCircle> ().Scale();
            circlePreview.transform.GetChild(1).GetChild(2).GetChild(1).GetComponent <Text> ().text = snapshot.Child("About").Value.ToString();

            circlePreview.SetActive(true);
        });
    }
    //----------------------------------------------------------------------------------------------------------------------------------------------//

    public void JoinCircle(string circleRef)
    {
        string userRef = userAuth.transform.GetComponent <DataGetSet> ().currentUserID;

        DataRef.CurrentUser().Child("Circles").Child(circleRef).SetValueAsync(circleRef).ContinueWith(async(task) => {
            await new WaitForUpdate();
            if (task.IsFaulted || task.IsCanceled)
            {
                print(task.Exception);
                return;
            }
        });

        DataRef.Circles(circleRef).Child("Members").Child(userRef).SetValueAsync(userRef).ContinueWith(async(task) => {
            await new WaitForUpdate();
            if (task.IsFaulted || task.IsCanceled)
            {
                print(task.Exception);
                return;
            }
        });

        DataRef.Circles(circleRef).Child("TotalMembers").GetValueAsync().ContinueWith(async(task) => {
            await new WaitForUpdate();
            if (task.IsFaulted || task.IsCanceled)
            {
                print(task.Exception);
                return;
            }
            DataSnapshot snapshot = task.Result;

            int totalMembers = int.Parse(snapshot.Value.ToString());
            int newTotal     = totalMembers + 1;

            SetTotalMembers(circleRef, newTotal);

            List <string> circles = new List <string> ();
            foreach (Transform circle in circlesContent)
            {
                circles.Add(circle.gameObject.name);
            }
            circles.Add(circleRef);
            circles.Sort();

            PopulateCircleList(circles.IndexOf(circleRef));
        });
    }
    //----------------------------------------------------------------------------------------------------------------------------------------------//

    private void AddReferenceForCreator(string circleRef, string userRef)
    {
        DataRef.Circles(circleRef).Child("Members").Child(userRef).SetValueAsync(userRef).ContinueWith(async(task) => {
            await new WaitForUpdate();
            if (task.IsFaulted || task.IsCanceled)
            {
                print(task.Exception);
                return;
            }
        });

        DataRef.CurrentUser().Child("Circles").Child(circleRef).SetValueAsync(circleRef).ContinueWith(async(task) => {
            await new WaitForUpdate();
            if (task.IsFaulted || task.IsCanceled)
            {
                print(task.Exception);
                return;
            }
        });
    }
    //----------------------------------------------------------------------------------------------------------------------------------------------//

    public void StartCommentCheck()
    {
        if (breakCycle == true)
        {
            breakCycle = false;
            PopulateReCheck();
        }
        else
        {
            DataRef.Circles(circlesManager.activeCircleRef).Child("Comments").GetValueAsync().ContinueWith(async(task) => {
                await new WaitForUpdate();
                DataSnapshot snapshot = task.Result;

                if (int.Parse(snapshot.ChildrenCount.ToString()) != commentsContent.childCount)
                {
                    PopulateReCheck();
                }
                else
                {
                    StartCoroutine(CheckForNewComments(0.1f));
                }
            });
        }
    }
    //----------------------------------------------------------------------------------------------------------------------------------------------//

    private void SetValue(string child, string value)
    {
        DataRef.Circles(circlesManager.activeCircleRef).Child("Comments").Child(pushKey).Child(child).SetValueAsync(value).ContinueWith(async(taskSet) => { await new WaitForUpdate(); });
    }
    //----------------------------------------------------------------------------------------------------------------------------------------------//

    private void GetInformation()
    {
        DataRef.Circles(circleRef).GetValueAsync().ContinueWith(async(task) => {
            await new WaitForUpdate();
            if (task.IsFaulted || task.IsCanceled)
            {
                print(task.Exception);
                return;
            }
            DataSnapshot snapshot = task.Result;

            title           = snapshot.Child("Name").Value.ToString();
            about           = snapshot.Child("About").Value.ToString();
            accessType      = snapshot.Child("Access").Value.ToString();
            int tempMembers = int.Parse(snapshot.Child("TotalMembers").Value.ToString());
            int tempDonated = int.Parse(snapshot.Child("TotalDonated").Value.ToString());

            if (tempMembers < 100)
            {
                totalMembers = (tempMembers).ToString();
            }
            else
            {
                totalMembers = String.Format("{0:0,0}", (tempMembers));
            }
            if (tempDonated < 10000)
            {
                totalDonated = (tempDonated / 100).ToString();
            }
            else
            {
                totalDonated = String.Format("{0:0,0}", (tempDonated / 100));
            }

            members.Clear();
            projects.Clear();

            foreach (DataSnapshot snap in snapshot.Child("Members").Children)
            {
                members.Add(snap.Value.ToString());
            }
            if (snapshot.Child("Projects").HasChildren)
            {
                foreach (DataSnapshot snap in snapshot.Child("Projects").Children)
                {
                    projects.Add(snap.Child("Reference").Value.ToString());
                }
            }

            SetHudDisplay();

            if (circleRef == "Bucket Circle New Zealand")
            {
                if (load)
                {
                    SetMainDisplay();
                    load = false;
                }
            }
            else
            {
                load = false;
            }
        });
    }
    //----------------------------------------------------------------------------------------------------------------------------------------------//

    private void GetCircleInformation(string circleReference)
    {
        StartCoroutine(FadeLoad(1.0f, true, 1.0f));
        loading         = true;
        activeCircleRef = circleReference;

        //debug.UpdateReport (circleReference, circleReference + ": Getting Circle information...", debug.orange);

        DataRef.Circles(circleReference).GetValueAsync().ContinueWith(async(task) => {
            if (task.IsCanceled || task.IsFaulted)
            {
                await new WaitForUpdate();
                //debug.UpdateReport (circleReference, circleReference + ": Failed to get Circle information.", debug.red);
            }
            await new WaitForUpdate();
            DataSnapshot snapshot = task.Result;

            //debug.UpdateReport (circleReference, circleReference + ": Accessed Circle information. Loading information to screen...", debug.orange);

            string name            = snapshot.Child("Name").Value.ToString();
            string description     = snapshot.Child("About").Value.ToString();
            string pictureID       = snapshot.Child("PictureID").Value.ToString();
            string secondPictureID = snapshot.Child("SecondaryPictureID").Value.ToString();
            string totalDonated    = snapshot.Child("TotalDonated").Value.ToString();

            mainTitle.text    = name;
            aboutTitle.text   = name;
            about.text        = description;
            Sprite img1       = Resources.Load <Sprite> ("2D/Groups/" + pictureID);
            pictureOne.sprite = img1;
            Sprite img2       = Resources.Load <Sprite> ("2D/Groups/" + secondPictureID);
            pictureTwo.sprite = img2;
            pictureTwo.transform.GetComponent <ScaleImageToCircle> ().Scale();
            if (circleReference == "Bucket Circle New Zealand")
            {
                pictureTwo.transform.GetComponent <RectTransform> ().anchoredPosition = new Vector3(0.0f, -95.0f, 0.0f);
            }
            else if (circleReference == "DOC Supporters")
            {
                pictureTwo.transform.GetComponent <RectTransform> ().anchoredPosition = new Vector3(0.0f, 40.0f, 0.0f);
            }
            else if (circleReference == "Predator Free Brooklyn")
            {
                pictureTwo.transform.GetComponent <RectTransform> ().anchoredPosition = new Vector3(0.0f, 0.0f, 0.0f);
            }
            else
            {
                pictureTwo.transform.GetComponent <RectTransform> ().anchoredPosition = new Vector3(0.0f, 0.0f, 0.0f);
            }
            donated.text = "$" + (int.Parse(totalDonated) / 100).ToString();
            donatedFunds = int.Parse(totalDonated);

            //debug.UpdateReport (circleReference, circleReference + ": Loaded information to screen.", debug.green);

            if (begunChecks == false)
            {
                begunChecks = true;
                transform.GetComponent <CommentManager> ().StartCommentCheck();
                StartMemberCheck();
                projectHolder.transform.GetComponent <CircleProjectSearch> ().PopulateReCheck();
                loading = false;
            }
            else
            {
                transform.GetComponent <CommentManager> ().breakCycle = true;
                breakCycle = true;
                projectHolder.transform.GetComponent <CircleProjectSearch> ().breakCycle = true;
                loading = false;
            }
        });
    }
Exemple #16
0
    //----------------------------------------------------------------------------------------------------------------------------------------------//

    public void SaveNewUserData(string userID)
    {
        DataRef.CurrentUser().Child("Username").SetValueAsync(username.text).ContinueWith(async(task) => {
            await new WaitForUpdate();
            if (task.IsCanceled || task.IsFaulted)
            {
                return;
            }
        });
        DataRef.CurrentUser().Child("CreatedDate").SetValueAsync(DateTime.Now.ToString()).ContinueWith(async(task) => {
            await new WaitForUpdate();
            if (task.IsCanceled || task.IsFaulted)
            {
                return;
            }
        });
        DataRef.CurrentUser().Child("Balance").SetValueAsync("0").ContinueWith(async(task) => {
            await new WaitForUpdate();
            if (task.IsCanceled || task.IsFaulted)
            {
                return;
            }
        });
        DataRef.CurrentUser().Child("stripe").Child("pin").SetValueAsync(pinNumber.text).ContinueWith(async(task) => {
            await new WaitForUpdate();
            if (task.IsCanceled || task.IsFaulted)
            {
                return;
            }
        });
        DataRef.CurrentUser().Child("PictureID").SetValueAsync("Animal_Kiwi").ContinueWith(async(task) => {
            await new WaitForUpdate();
            if (task.IsCanceled || task.IsFaulted)
            {
                return;
            }
        });
        DataRef.CurrentUser().Child("Permissions").SetValueAsync("Default").ContinueWith(async(task) => {
            await new WaitForUpdate();
            if (task.IsCanceled || task.IsFaulted)
            {
                return;
            }
        });
        DataRef.CurrentUser().Child("DonationTotal").SetValueAsync("0").ContinueWith(async(task) => {
            await new WaitForUpdate();
            if (task.IsCanceled || task.IsFaulted)
            {
                return;
            }
        });
        DataRef.CurrentUser().Child("Circles").Child("Bucket Circle New Zealand").SetValueAsync("Bucket Circle New Zealand").ContinueWith(async(task) => {
            await new WaitForUpdate();
            if (task.IsCanceled || task.IsFaulted)
            {
                return;
            }
        });
        DataRef.CurrentUser().Child("Onboarded").Child("Bucket Circle New Zealand").SetValueAsync("false").ContinueWith(async(task) => {
            await new WaitForUpdate();
            if (task.IsCanceled || task.IsFaulted)
            {
                return;
            }
        });
        DataRef.Circles("Bucket Circle New Zealand").Child("Members").Child(userID.ToString()).SetValueAsync(userID.ToString()).ContinueWith(async(task) => {
            await new WaitForUpdate();
            if (task.IsCanceled || task.IsFaulted)
            {
                return;
            }
        });

        DataRef.Circles("Bucket Circle New Zealand").Child("TotalMembers").GetValueAsync().ContinueWith(async(task) => {
            await new WaitForUpdate();
            if (task.IsCanceled || task.IsFaulted)
            {
                return;
            }
            DataSnapshot snapshot = task.Result;
            int totalMembers      = int.Parse(snapshot.Value.ToString());
            int newTotal          = totalMembers + 1;

            AddToCircleTotal(newTotal);
        });

        DataRef.General().Child("TotalDonors").GetValueAsync().ContinueWith(async(task) => {
            await new WaitForUpdate();
            if (task.IsCanceled || task.IsFaulted)
            {
                return;
            }
            DataSnapshot snapshot = task.Result;
            int totalusers        = int.Parse(snapshot.Value.ToString());
            int newUsers          = totalusers + 1;

            AddToTotalSet("TotalDonors", newUsers);
        });

        GetComponent <DataGetSet> ().GetUserInfo();
        activityManager.SetAlertNewDonor(username.text, userID);

        activityManager.StartActivityProcess();
        circlesManager.StartCircleProcess();
    }