Remove "AllowCreate" function by instead handling nulls

This commit is contained in:
Dean Herbert 2019-08-28 13:27:44 +09:00
parent c4aaab20c7
commit f18b5a3c02
2 changed files with 8 additions and 15 deletions

View File

@ -31,12 +31,12 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
protected override APIRequest<List<APIBeatmapSet>> CreateRequest() =>
new GetUserBeatmapsRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage);
protected override bool AllowCreate(APIBeatmapSet item) => item.OnlineBeatmapSetID.HasValue;
protected override Drawable CreateDrawableItem(APIBeatmapSet item) => new DirectGridPanel(item.ToBeatmapSet(Rulesets))
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
};
protected override Drawable CreateDrawableItem(APIBeatmapSet item) => !item.OnlineBeatmapSetID.HasValue
? null
: new DirectGridPanel(item.ToBeatmapSet(Rulesets))
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
};
}
}

View File

@ -116,7 +116,7 @@ namespace osu.Game.Overlays.Profile.Sections
return;
}
LoadComponentsAsync(items.Where(AllowCreate).Select(CreateDrawableItem), drawables =>
LoadComponentsAsync(items.Select(CreateDrawableItem).Where(d => d != null), drawables =>
{
missingText.Hide();
moreButton.FadeTo(items.Count == ItemsPerPage ? 1 : 0);
@ -127,13 +127,6 @@ namespace osu.Game.Overlays.Profile.Sections
});
}
/// <summary>
/// Used to check whether the item is suitable for drawable creation.
/// </summary>
/// <param name="item">An item to check</param>
/// <returns></returns>
protected virtual bool AllowCreate(T item) => true;
protected abstract APIRequest<List<T>> CreateRequest();
protected abstract Drawable CreateDrawableItem(T item);