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

51 lines
1.4 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.Overlays.Profile.Sections.Recent;
2018-02-25 21:48:39 +08:00
using osu.Game.Users;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.Overlays.Profile.Sections
{
class PaginatedRecentActivityContainer : PaginatedContainer
{
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)
{
ItemsContainer.Add(new DrawableRecentActivity(activity, User));
}
};
2018-02-25 21:48:39 +08:00
Api.Queue(req);
}
2018-02-25 21:48:39 +08:00
}
}