Files
SteamTools/System.Common.ClientLib.Droid/Application/UI/Adapters/ViewPagerAdapter.cs
T
2021-02-20 16:45:44 +08:00

31 lines
774 B
C#

using AndroidX.Fragment.App;
using AndroidX.ViewPager2.Adapter;
namespace System.Application.UI.Adapters
{
public class ViewPagerAdapter : FragmentStateAdapter
{
public interface IHost
{
Fragment CreateFragment(int position);
int ItemCount { get; }
}
readonly IHost host;
public ViewPagerAdapter(IHost host, Fragment fragment) : base(fragment)
{
this.host = host;
}
public ViewPagerAdapter(IHost host, FragmentActivity activity) : base(activity)
{
this.host = host;
}
public override Fragment CreateFragment(int position) => host.CreateFragment(position);
public override int ItemCount => host.ItemCount;
}
}