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

49 lines
1.4 KiB
C#
Raw Normal View History

// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
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-03-07 20:03:21 +08:00
public 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
}
}