2025-03-12 20:59:12 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
2025-11-20 15:40:38 +08:00
|
|
|
namespace AlicizaX.UI
|
2025-03-12 20:59:12 +08:00
|
|
|
{
|
2025-11-20 15:40:38 +08:00
|
|
|
public class LoopAdapter<T> : Adapter<T> where T : ISimpleViewData
|
2025-03-12 20:59:12 +08:00
|
|
|
{
|
|
|
|
|
public LoopAdapter(RecyclerView recyclerView) : base(recyclerView)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public LoopAdapter(RecyclerView recyclerView, List<T> list) : base(recyclerView, list)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int GetItemCount()
|
|
|
|
|
{
|
2026-03-31 15:18:50 +08:00
|
|
|
return GetRealCount() > 0 ? int.MaxValue : 0;
|
2025-03-12 20:59:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int GetRealCount()
|
|
|
|
|
{
|
|
|
|
|
return list == null ? 0 : list.Count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnBindViewHolder(ViewHolder viewHolder, int index)
|
|
|
|
|
{
|
2026-03-31 15:18:50 +08:00
|
|
|
if (list == null || list.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-12 20:59:12 +08:00
|
|
|
index %= list.Count;
|
|
|
|
|
base.OnBindViewHolder(viewHolder, index);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|