private void Start()
    {
        trans = GetComponent <RectTransform>();

        Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(t =>
        {
            var dependencyStatus = t.Result;
            if (dependencyStatus == Firebase.DependencyStatus.Available)
            {
                FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://animated-twitter-feed.firebaseio.com/");
                Debug.Log("firebase initialized successfully");
                FirebaseDatabase.DefaultInstance.GetReference("tweets").GetValueAsync().ContinueWithOnMainThread(task =>
                {
                    if (task.IsFaulted)
                    {
                        Debug.LogError("failed to retrive firebase database");
                    }
                    else if (task.IsCompleted)
                    {
                        Debug.Log("firebase database snapshot retrieved successfully");
                        DataSnapshot snapshot = task.Result;
                        int i = 0;

                        foreach (var tweetData in snapshot.Children)
                        {
                            var tweet = Instantiate(tweetPrefab) as GameObject;
                            tweets.Add(tweet.GetComponent <RectTransform>());
                            tweet.transform.SetParent(transform, false);

                            if (i == 0)
                            {
                                var positionSetter      = tweet.AddComponent <PositionSetter>();
                                positionSetter.Position = conversationStartPosition;
                                tweet.GetComponent <AnimationController>().PlayOnAwake = true;
                            }

                            var tweetController           = tweet.GetComponent <TweetController>();
                            tweetController.Name.text     = tweetData.Child("name").Value as string;
                            tweetController.Username.text = tweetData.Child("username").Value as string;
                            tweetController.Body.text     = AutoTags.AddTags(tweetData.Child("body").Value as string);
                            tweetController.Date.text     = tweetData.Child("date").Value as string;
                            var profileImageUrl           = tweetData.Child("profile_image").Value as string;
                            StartCoroutine(loadProfileImage(profileImageUrl, tweetController.ProfileImage));

                            i++;
                        }

                        longPressTrigger.onLongPress += () => StartCoroutine(SkipTweet());
                        StartCoroutine(Initialize());
                    }
                });
            }
            else
            {
                UnityEngine.Debug.LogError(System.String.Format(
                                               "Could not resolve all Firebase dependencies: {0}", dependencyStatus));
            }
        });
    }
Exemplo n.º 2
0
 public bool ElementsConteinLinc2()
 {
     for (int i = 0; i < AutoTags.Count(); i++)
     {
         if (AutoTags[i].GetAttribute("href") != null)
         {
             ;
         }
         else
         {
             return(false);
         }
     }
     return(true);
 }