示例#1
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            LoadingProgressBar.Visibility = Visibility.Visible;
            string screenName = string.Empty;
            string msg = string.Empty;
            if (NavigationContext.QueryString.TryGetValue("screenName", out msg))
            {
                screenName = msg;
            }
            _selectedUser = await UserManager.ShowUser(screenName, null, App.userAccountEntity);
            SetButtonEnabled(_selectedUser);
            _selectedUser = await UserManager.ShowUser(_selectedUser.ScreenName, _selectedUser.UserID, App.userAccountEntity);
            DataContext = _selectedUser;
            if (_selectedUser.IsCurrentUser)
            {
                UserIsFollowing.Text = "ユーザーは君だよ!";
            }
            else
            {
                UserIsFollowing.Text = _selectedUser.IsFollowing
                    ? "@" + _selectedUser.ScreenName + "をフォローしています"
                    : "@" + _selectedUser.ScreenName + "をフォローしていません";
            }
            await BindToUserTimeline(App.userAccountEntity);
            await BindToUserFollowerGallery(App.userAccountEntity);
            await BindToUserFollowingGallery(App.userAccountEntity);
            await BindPictureGallery(App.userAccountEntity);
            LoadingProgressBar.Visibility = Visibility.Collapsed;

        }
示例#2
0
 private void SetButtonEnabled(UserEntity selectedUser)
 {
     var followButton = (ApplicationBarIconButton)ApplicationBar.Buttons[0];
     var unfollowButton = (ApplicationBarIconButton)ApplicationBar.Buttons[1];
     var secretMailButton = (ApplicationBarIconButton)ApplicationBar.Buttons[3];
     followButton.IsEnabled = !selectedUser.IsFollowing &&
                              selectedUser.IsNotCurrentUser;
     unfollowButton.IsEnabled = selectedUser.IsFollowing &&
                                selectedUser.IsNotCurrentUser;
     secretMailButton.IsEnabled = selectedUser.IsNotCurrentUser &&
                                  selectedUser.IsFollowing;
 }
示例#3
0
        public static List<UserEntity> ParseUserList(String json, UserAccountEntity userAccountEntity)
        {
            var userEntities = new List<UserEntity>();
            JArray a = JArray.Parse(json);
            foreach (var jToken in a)
            {
                var o = (JObject) jToken;
                var user = new UserEntity
                {
                    CoverImage = (String)o["cover_image_url_https"] ?? string.Empty,
                    CreatedAt = (String) o["created_at"] == null ? 0 : FixTime((String) o["created_at"]),
                    Description = (String) o["description"] ?? string.Empty,
                    FavoritesCount =
                        (String) o["favorites_count"] == null ? 0 : long.Parse((String) o["favorites_count"]),
                    FollowersCount =
                        (String) o["followers_count"] == null ? 0 : long.Parse((String) o["followers_count"]),
                    FriendsCount = (String) o["friends_count"] == null ? 0 : long.Parse((String) o["friends_count"]),
                    IsFollowing =
                        (String) o["following"] != null &&
                        (!((String) o["following"]).Equals("underdevelopment") && Boolean.Parse((String) o["following"])),
                    IsFollowRequest =
                        (String) o["follow_request_sent"] != null &&
                        (!((String) o["follow_request_sent"]).Equals("underdevelopment") &&
                         Boolean.Parse((String) o["follow_request_sent"])),
                    IsProtected = (String) o["protected"] != null && Boolean.Parse((String) o["protected"]),
                    Location = (String) o["location"] ?? string.Empty,
                    Name = Regex.Replace((String) o["name"], @"\t|\n|\r", ""),
                    ProfileImage = (String) o["profile_image_url_https"],
                    ScreenName = (String) o["screen_name"],
                    StatusCount = (String) o["statuses_count"] == null ? 0 : long.Parse((String) o["statuses_count"]),
                    URL = (String) o["url"] ?? string.Empty,
                    UserID = long.Parse((String) o["id"])
                };
                user.IsNotFollowing = !user.IsFollowing;
                if (userAccountEntity != null && userAccountEntity.GetUserEntity() != null)
                {
                    user.IsCurrentUser = user.UserID == userAccountEntity.GetUserEntity().UserID;
                    user.IsNotCurrentUser = !user.IsCurrentUser;
                }

                userEntities.Add(user);
            }
            return userEntities;
        }
示例#4
0
 public UserAccountEntity()
 {
     string accessToken;
     string refreshToken;
     try
     {
         accessToken = (string) AppSettings["accessToken"];
     }
     catch (KeyNotFoundException e)
     {
         accessToken = string.Empty;
     }
     try
     {
         refreshToken = (string) AppSettings["refreshToken"];
     }
     catch (KeyNotFoundException e)
     {
         refreshToken = string.Empty;
     }
     _data = new AccountData(accessToken, refreshToken, 3600);
     _entity = null;
     _isCalled = false;
 }
示例#5
0
 public void SetUserEntity(UserEntity entity)
 {
     _entity = entity;
 }
示例#6
0
 public static UserEntity Parse(String json, UserAccountEntity userAccountEntity)
 {
     JObject o = JObject.Parse(json);
     var user = new UserEntity
     {
         CoverImage = (String)o["cover_image_url_https"] ?? string.Empty,
         CreatedAt = (String) o["created_at"] == null ? 0 : FixTime((String) o["created_at"]),
         Description = (String) o["description"] ?? string.Empty,
         FavoritesCount = (String) o["favorites_count"] == null ? 0 : long.Parse((String) o["favorites_count"]),
         FollowersCount = (String) o["followers_count"] == null ? 0 : long.Parse((String) o["followers_count"]),
         FriendsCount = (String) o["friends_count"] == null ? 0 : long.Parse((String) o["friends_count"]),
         IsFollowing =
             (String) o["following"] != null &&
             (!((String) o["following"]).Equals("underdevelopment") && Boolean.Parse((String) o["following"])),
         IsFollowRequest =
             (String) o["follow_request_sent"] != null &&
             (!((String) o["follow_request_sent"]).Equals("underdevelopment") &&
              Boolean.Parse((String) o["follow_request_sent"])),
         IsProtected = (String) o["protected"] != null && Boolean.Parse((String) o["protected"]),
         Location = (String) o["location"] ?? string.Empty,
         Name = Regex.Replace((String) o["name"], @"\t|\n|\r", ""),
         ProfileImage = (String) o["profile_image_url_https"],
         ScreenName = (String) o["screen_name"],
         StatusCount = (String) o["statuses_count"] == null ? 0 : long.Parse((String) o["statuses_count"]),
         URL = (String) o["url"] ?? string.Empty,
         UserID = long.Parse((String) o["id"])
     };
     user.IsNotFollowing = !user.IsFollowing;
     if (userAccountEntity == null || userAccountEntity.GetUserEntity() == null) return user;
     user.IsCurrentUser = user.UserID == userAccountEntity.GetUserEntity().UserID;
     user.IsNotCurrentUser = !user.IsCurrentUser;
     return user;
 }