1 // OpenTween - Client of Twitter
2 // Copyright (c) 2007-2011 kiri_feather (@kiri_feather) <kiri.feather@gmail.com>
3 // (c) 2008-2011 Moz (@syo68k)
4 // (c) 2008-2011 takeshik (@takeshik) <http://www.takeshik.org/>
5 // (c) 2010-2011 anis774 (@anis774) <http://d.hatena.ne.jp/anis774/>
6 // (c) 2010-2011 fantasticswallow (@f_swallow) <http://twitter.com/f_swallow>
7 // (c) 2011 Egtra (@egtra) <http://dev.activebasic.com/egtra/>
8 // All rights reserved.
10 // This file is part of OpenTween.
12 // This program is free software; you can redistribute it and/or modify it
13 // under the terms of the GNU General Public License as published by the Free
14 // Software Foundation; either version 3 of the License, or (at your option)
17 // This program is distributed in the hope that it will be useful, but
18 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 // You should have received a copy of the GNU General Public License along
23 // with this program. If not, see <http://www.gnu.org/licenses/>, or write to
24 // the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
25 // Boston, MA 02110-1301, USA.
27 using System.Collections.Generic;
28 using System.Threading.Tasks;
29 using System.Xml.Serialization;
30 using OpenTween.Api.DataModel;
34 public class ListElement
37 public string Name = "";
38 public string Description = "";
39 public string Slug = "";
40 public bool IsPublic = true;
41 public int SubscriberCount = 0; //購読者数
42 public int MemberCount = 0; //リストメンバ数
43 public long UserId = 0;
44 public string Username = "";
45 public string Nickname = "";
47 protected Twitter _tw;
49 private List<UserInfo> _members = null;
52 public long Cursor { get; private set; } = -1;
58 public ListElement(TwitterList listElementData, Twitter tw)
60 this.Description = listElementData.Description;
61 this.Id = listElementData.Id;
62 this.IsPublic = (listElementData.Mode == "public");
63 this.MemberCount = listElementData.MemberCount;
64 this.Name = listElementData.Name;
65 this.SubscriberCount = listElementData.SubscriberCount;
66 this.Slug = listElementData.Slug;
67 this.Nickname = listElementData.User.Name.Trim();
68 this.Username = listElementData.User.ScreenName;
69 this.UserId = listElementData.User.Id;
74 public virtual async Task Refresh()
76 var newList = await _tw.EditList(this.Id, Name, !this.IsPublic, this.Description)
77 .ConfigureAwait(false);
79 this.Description = newList.Description;
81 this.IsPublic = newList.IsPublic;
82 this.MemberCount = newList.MemberCount;
83 this.Name = newList.Name;
84 this.SubscriberCount = newList.SubscriberCount;
85 this.Slug = newList.Slug;
86 this.Nickname = newList.Nickname;
87 this.Username = newList.Username;
88 this.UserId = newList.UserId;
92 public List<UserInfo> Members
96 if (this._members == null) this._members = new List<UserInfo>();
101 public async Task RefreshMembers()
103 var users = new List<UserInfo>();
104 this.Cursor = await this._tw.GetListMembers(this.Id, users, cursor: -1)
105 .ConfigureAwait(false);
106 this._members = users;
109 public async Task GetMoreMembers()
110 => this.Cursor = await this._tw.GetListMembers(this.Id, this._members, this.Cursor)
111 .ConfigureAwait(false);
113 public override string ToString()
114 => $"@{Username}/{Name} [{(this.IsPublic ? "public" : "Protected")}]";