Esempio n. 1
0
 public FullProfileView(string name)
     : base(UITableViewStyle.Grouped, null, true)
 {
     user = User.FromName (name);
     if (user == null)
         User.FetchUser (name, u => ProcessUserReturn (u));
     else
         CreateUI ();
 }
Esempio n. 2
0
 public FullProfileView(long id)
     : base(UITableViewStyle.Grouped, null, true)
 {
     user = User.FromId (id);
     if (user == null)
         User.FetchUser (id, u => ProcessUserReturn (u));
     else
         CreateUI ();
 }
Esempio n. 3
0
        public ShortProfileView(RectangleF rect, long userId, bool discloseButton)
            : base(rect)
        {
            BackgroundColor = UIColor.Clear;

            user = User.FromId (userId);
            if (user == null){
                Console.WriteLine ("userid={0}", userId);
                return;
            }

            // Pics are 73x73, but we will add a border.
            profilePic = new UIImageView (new RectangleF (10, 10, 73, 73));
            profilePic.BackgroundColor = UIColor.Clear;

            profilePic.Image = ImageStore.RequestProfilePicture (-userId, user.PicUrl, this);
            AddSubview (profilePic);

            url = UIButton.FromType (UIButtonType.Custom);
            url.Font = urlFont;
            url.Font = urlFont;
            url.LineBreakMode = UILineBreakMode.TailTruncation;
            url.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
            url.TitleShadowOffset = new SizeF (0, 1);

            url.SetTitle (user.Url, UIControlState.Normal);
            url.SetTitle (user.Url, UIControlState.Highlighted);
            url.SetTitleColor (UIColor.FromRGB (0x32, 0x4f, 0x85), UIControlState.Normal);
            url.SetTitleColor (UIColor.Red, UIControlState.Highlighted);
            url.SetTitleShadowColor (UIColor.White, UIControlState.Normal);
            url.Frame = new RectangleF (TextX, 70, rect.Width-TextX, urlSize);

            url.AddTarget (delegate { if (UrlTapped != null) UrlTapped (); }, UIControlEvent.TouchUpInside);

            AddSubview (url);

            if (discloseButton){
                var button = UIButton.FromType (UIButtonType.DetailDisclosure);
                button.Frame = new RectangleF (290, 36, 20, 20);
                AddSubview (button);
                button.TouchDown += delegate { Tapped (); };
            }
        }
Esempio n. 4
0
        public StreamedViewController(string title, string url, User reference)
            : base(true)
        {
            this.url = url;

            this.StreamedTitle = title;
            this.ReferenceUser = reference;

            this.NavigationItem.Title = title;
            EnableSearch = true;

            if (reference != null && reference.Id > ImageStore.TempStartId){
                User.FetchUser (reference.Screenname, u => UserUpdated (u));
            }
        }
Esempio n. 5
0
 public StreamedTimelineViewController(string title, string url, string countStr, int count, string sinceStr, string pageStr, User reference)
     : base(title, url, reference)
 {
     this.countStr = countStr;
     this.sinceStr = sinceStr;
     this.pageStr = pageStr;
     this.expectedCount = count;
 }
Esempio n. 6
0
        // Used to update asynchronously our display when we get enough information about the tweet detail
        public void UpdateFromUserId(long userId)
        {
            user = User.FromId (userId);
            if (user == null){
                Console.WriteLine ("Could nto find user ID={0}", userId);
                return;
            }

            var pic = ImageStore.RequestProfilePicture (-userId, user.PicUrl, this);
            if (pic != ImageStore.DefaultImage)
                profilePic.Image = pic;

            url.AddTarget (delegate { if (UrlTapped != null) UrlTapped (); }, UIControlEvent.TouchUpInside);
            url.SetTitle (user.Url, UIControlState.Normal);
            url.SetTitle (user.Url, UIControlState.Highlighted);
            SetNeedsDisplay ();
        }
Esempio n. 7
0
 public void UpdateFromUser(User user)
 {
     if (user == this.user)
         return;
     this.user = user;
     TextLabel.Text = user.Screenname;
     DetailTextLabel.Text = user.Name;
     ImageView.Image = ImageStore.RequestProfilePicture (user.Id, user.PicUrl, this);
     SetNeedsDisplay ();
 }
Esempio n. 8
0
 public StreamedUserViewController(string title, string url, User reference)
     : base(title, url, reference)
 {
 }
Esempio n. 9
0
 void ProcessUserReturn(User user)
 {
     if (user == null){
         Root = Util.MakeError (Locale.GetText ("Could not get information on user"));
         return;
     }
     this.user = user;
     CreateUI ();
 }
Esempio n. 10
0
 public static TimelineRootElement MakeFavorites(string nestedCaption, string caption, string url, User reference)
 {
     return new TimelineRootElement (nestedCaption, caption, url, null, 20, null, "page=", reference);
 }
Esempio n. 11
0
        // Populates a Tweet object with cached and useful user information
        static void PopulateUser(Tweet tweet, User user)
        {
            if (tweet.Retweeter != null){
                tweet.UserId = tweet.RetweeterId;
                tweet.Screename = tweet.Retweeter;
                tweet.PicUrl = tweet.RetweeterPicUrl;

                tweet.RetweeterId = user.Id;
                tweet.Retweeter = user.Screenname;
                tweet.RetweeterPicUrl = user.PicUrl;
            } else {
                tweet.UserId = user.Id;
                tweet.Screename = user.Screenname;
                tweet.PicUrl = user.PicUrl;
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Creates an IEnumerable of the tweets, does not store in the database.
        /// </summary>
        /// <remarks>
        /// If the referenceUser is null, the users are parsed from the stream
        /// and stored on the database, if not, the tweet information is copied
        /// from the reference user.
        /// </remarks>
        public static IEnumerable<Tweet> TweetsFromStream(Stream stream, User referenceUser)
        {
            JsonValue root;

            try {
                root = JsonValue.Load (stream);
            } catch (Exception e) {
                Console.WriteLine (e);
                yield break;
            }

            var usersSeen = referenceUser == null ? new HashSet<long> () : null;
            var user = referenceUser == null ? new User () : referenceUser;

            foreach (JsonObject jentry in root){
                if (referenceUser == null){
                    var juser = jentry ["user"];
                    ParseUser ((JsonObject) juser, user, usersSeen);
                }

                var tweet = FromJsonEntry (jentry, user);
                if (referenceUser == null && tweet.Retweeter != null){
                    ParseUser ((JsonObject)(jentry ["retweeted_status"]["user"]), user, usersSeen);
                }
                if (tweet != null)
                    yield return tweet;
            }
        }
Esempio n. 13
0
        // Returns an IEnumerable of tweets when parsing search
        // results from twitter.   The returned Tweet objects are
        // not really complete and have the UserId busted (negative
        // numbers) since the userids returned by twitter for
        // searches have no relationship with the rest of the system
        public static IEnumerable<Tweet> TweetsFromSearchResults(Stream stream, User reference)
        {
            JsonValue root;

            try {
                root = JsonValue.Load (stream);
            } catch (Exception e) {
                Console.WriteLine (e);
                yield break;
            }

            foreach (JsonObject result in root ["results"]){
                Tweet tweet;

                try {
                    tweet = new Tweet () {
                        CreatedAt = ParseCreationSearch (result),
                        Id = (long) result ["id"],
                        Text = ParseText (result),
                        Source = Util.StripHtml (HttpUtility.HtmlDecode (result ["source"]) ?? ""),
                        UserId = serial++,
                        Screename = reference == null ? (string) result ["from_user"] : reference.Screenname,
                        PicUrl = reference == null ? (string) result ["profile_image_url"] : reference.PicUrl
                    };
                } catch (Exception e){
                    Console.WriteLine (e);
                    tweet = null;
                }
                if (tweet != null)
                    yield return tweet;
            }
        }
Esempio n. 14
0
        //
        // Alternative version that just parses the users and tweets and returns them as lists
        // I thought it would be useful, but it is not.   The JSon parsing is too fast, we
        // only get bogged down with the actual sqlite insert
        //
        public static void ParseJson(Stream stream, int localAccount, TweetKind kind, out List<User> users, out List<Tweet> tweets)
        {
            JsonValue root;
            string userKey;

            try {
                root = JsonValue.Load (stream);
                if (kind == TweetKind.Direct)
                    userKey = "sender";
                else
                    userKey = "user";
            } catch (Exception e) {
                Console.WriteLine (e);
                tweets = null;
                users = null;
                return;
            }

            users = new List<User> (root.Count/4);
            tweets = new List<Tweet> (root.Count);

            var start = DateTime.UtcNow;

            var usersSeen = new HashSet<long> ();
            var user = new User ();
            foreach (JsonObject jentry in root){
                var juser = jentry [userKey];
                bool result;

                try {
                    user.UpdateFromJson ((JsonObject) juser);
                    if (!usersSeen.Contains (user.Id)){
                        usersSeen.Add (user.Id);
                        users.Add (user);
                        user = new User ();
                    }
                } catch {
                    continue;
                }

                var tweet = new Tweet ();
                if (kind == TweetKind.Direct)
                    result = tweet.TryPopulateDirect (jentry);
                else
                    result = tweet.TryPopulate (jentry);

                if (result){
                    PopulateUser (tweet, user);
                    tweets.Add (tweet);
                }

                // Repeat user loading for the retweet info
                if (tweet.Retweeter != null){
                    user.UpdateFromJson ((JsonObject)(jentry ["retweeted_status"]["user"]));
                    if (!usersSeen.Contains (user.Id)){
                        usersSeen.Add (user.Id);
                        users.Add (user);
                        user = new User ();
                    }
                }
            }
            var end = DateTime.UtcNow;
            Util.Log ("Parsing time for tweet stream: {0} for {1} tweets", end-start, tweets.Count);
        }
Esempio n. 15
0
 public FollowElement(User u, string caption, string url)
     : base(caption)
 {
 }
Esempio n. 16
0
 protected virtual void UserUpdated(User u)
 {
     if (u == null)
         return;
     ReferenceUser = u;
     UpdateUserInfo ();
 }
Esempio n. 17
0
 public TimelineRootElement(string nestedCaption, string caption, string url, string countStr, int count, string sinceStr, string pageStr, User reference)
     : base(caption)
 {
     this.nestedCaption = nestedCaption;
     this.UserReference = reference;
     this.url = url;
     this.pageStr = pageStr;
     this.countStr = countStr;
     this.sinceStr = sinceStr;
     this.count = count;
 }
Esempio n. 18
0
 public UserElement(User user)
     : base(user.Screenname)
 {
     User = user;
 }
Esempio n. 19
0
 public static TimelineRootElement MakeTimeline(string nestedCaption, string caption, string url, User reference)
 {
     return new TimelineRootElement (nestedCaption, caption, url, "count=", 50, "since_id=", null, reference);
 }
Esempio n. 20
0
 public UserRootElement(User reference, string caption, string url)
     : base(caption)
 {
     this.reference = reference;
     this.url = url;
 }