1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 10:57:30 +08:00
osu-lazer/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs

46 lines
1.3 KiB
C#
Raw Normal View History

2018-02-25 21:48:39 +08:00
using osu.Framework.Configuration;
using osu.Framework.Graphics;
2018-02-25 21:48:39 +08:00
using osu.Game.Online.API.Requests;
using osu.Game.Users;
using System.Linq;
2018-02-26 03:46:46 +08:00
namespace osu.Game.Overlays.Profile.Sections.Recent
2018-02-25 21:48:39 +08:00
{
2018-02-26 03:46:46 +08:00
internal class PaginatedRecentActivityContainer : PaginatedContainer
2018-02-25 21:48:39 +08:00
{
public PaginatedRecentActivityContainer(Bindable<User> user, string header, string missing)
: base(user, header, missing)
{
ItemsPerPage = 5;
}
protected override void ShowMore()
{
base.ShowMore();
2018-02-25 21:48:39 +08:00
var req = new GetUserRecentActivitiesRequest(User.Value.Id, VisiblePages++ * ItemsPerPage);
2018-02-25 21:48:39 +08:00
req.Success += activities =>
{
ShowMoreButton.FadeTo(activities.Count == ItemsPerPage ? 1 : 0);
ShowMoreLoading.Hide();
2018-02-25 21:48:39 +08:00
if (!activities.Any() && VisiblePages == 1)
{
MissingText.Show();
return;
}
2018-02-25 21:48:39 +08:00
MissingText.Hide();
2018-02-25 21:48:39 +08:00
foreach (RecentActivity activity in activities)
{
2018-02-26 03:46:46 +08:00
ItemsContainer.Add(new DrawableRecentActivity(activity));
}
};
2018-02-25 21:48:39 +08:00
Api.Queue(req);
}
2018-02-25 21:48:39 +08:00
}
}