Compare commits
2 Commits
ab0bc3bcf9
...
00a7eff5f8
| Author | SHA1 | Date | |
|---|---|---|---|
| 00a7eff5f8 | |||
| dd88656c02 |
@ -78,10 +78,6 @@ namespace AlicizaX.UI
|
||||
{
|
||||
typedItemRender.BindData(data, index);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemRender.Bind(data, index);
|
||||
}
|
||||
|
||||
bool selected = index == choiceIndex;
|
||||
itemRender.SyncSelection(selected);
|
||||
@ -153,14 +149,14 @@ namespace AlicizaX.UI
|
||||
recyclerView.RebindVisibleDataRange(index, count);
|
||||
}
|
||||
|
||||
public virtual void NotifyItemInserted(int index)
|
||||
public virtual void NotifyItemInserted()
|
||||
{
|
||||
CoerceChoiceIndex();
|
||||
recyclerView.RequestLayout();
|
||||
recyclerView.Refresh();
|
||||
}
|
||||
|
||||
public virtual void NotifyItemRangeInserted(int index, int count)
|
||||
public virtual void NotifyItemRangeInserted(int count)
|
||||
{
|
||||
if (count <= 0)
|
||||
{
|
||||
@ -172,14 +168,14 @@ namespace AlicizaX.UI
|
||||
recyclerView.Refresh();
|
||||
}
|
||||
|
||||
public virtual void NotifyItemRemoved(int index)
|
||||
public virtual void NotifyItemRemoved()
|
||||
{
|
||||
CoerceChoiceIndex();
|
||||
recyclerView.RequestLayout();
|
||||
recyclerView.Refresh();
|
||||
}
|
||||
|
||||
public virtual void NotifyItemRangeRemoved(int index, int count)
|
||||
public virtual void NotifyItemRangeRemoved(int count)
|
||||
{
|
||||
if (count <= 0)
|
||||
{
|
||||
@ -256,7 +252,7 @@ namespace AlicizaX.UI
|
||||
}
|
||||
|
||||
list.Add(item);
|
||||
NotifyItemInserted(list.Count - 1);
|
||||
NotifyItemInserted();
|
||||
}
|
||||
|
||||
public void AddRange(IEnumerable<T> collection)
|
||||
@ -266,11 +262,10 @@ namespace AlicizaX.UI
|
||||
return;
|
||||
}
|
||||
|
||||
int startIndex = list.Count;
|
||||
list.AddRange(collection);
|
||||
if (collection is ICollection<T> itemCollection)
|
||||
{
|
||||
NotifyItemRangeInserted(startIndex, itemCollection.Count);
|
||||
NotifyItemRangeInserted(itemCollection.Count);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -280,7 +275,7 @@ namespace AlicizaX.UI
|
||||
public void Insert(int index, T item)
|
||||
{
|
||||
list.Insert(index, item);
|
||||
NotifyItemInserted(index);
|
||||
NotifyItemInserted();
|
||||
}
|
||||
|
||||
public void InsertRange(int index, IEnumerable<T> collection)
|
||||
@ -293,7 +288,7 @@ namespace AlicizaX.UI
|
||||
list.InsertRange(index, collection);
|
||||
if (collection is ICollection<T> itemCollection)
|
||||
{
|
||||
NotifyItemRangeInserted(index, itemCollection.Count);
|
||||
NotifyItemRangeInserted(itemCollection.Count);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -311,13 +306,13 @@ namespace AlicizaX.UI
|
||||
if (index < 0 || index >= GetItemCount()) return;
|
||||
|
||||
list.RemoveAt(index);
|
||||
NotifyItemRemoved(index);
|
||||
NotifyItemRemoved();
|
||||
}
|
||||
|
||||
public void RemoveRange(int index, int count)
|
||||
{
|
||||
list.RemoveRange(index, count);
|
||||
NotifyItemRangeRemoved(index, count);
|
||||
NotifyItemRangeRemoved(count);
|
||||
}
|
||||
|
||||
public void RemoveAll(Predicate<T> match)
|
||||
@ -335,7 +330,7 @@ namespace AlicizaX.UI
|
||||
|
||||
int count = list.Count;
|
||||
list.Clear();
|
||||
NotifyItemRangeRemoved(0, count);
|
||||
NotifyItemRangeRemoved(count);
|
||||
}
|
||||
|
||||
public void Reverse(int index, int count)
|
||||
|
||||
@ -11,13 +11,6 @@ namespace AlicizaX.UI
|
||||
/// </summary>
|
||||
internal interface IItemRender
|
||||
{
|
||||
/// <summary>
|
||||
/// 将指定数据绑定到当前渲染实例。
|
||||
/// </summary>
|
||||
/// <param name="data">待绑定的数据对象。</param>
|
||||
/// <param name="index">当前数据索引。</param>
|
||||
void Bind(object data, int index);
|
||||
|
||||
/// <summary>
|
||||
/// 更新当前渲染实例的选中状态。
|
||||
/// </summary>
|
||||
@ -65,13 +58,6 @@ namespace AlicizaX.UI
|
||||
/// </summary>
|
||||
internal abstract void Detach();
|
||||
|
||||
/// <summary>
|
||||
/// 以对象形式绑定数据。
|
||||
/// </summary>
|
||||
/// <param name="data">待绑定的数据对象。</param>
|
||||
/// <param name="index">当前数据索引。</param>
|
||||
internal abstract void BindObject(object data, int index);
|
||||
|
||||
/// <summary>
|
||||
/// 更新内部记录的选中状态。
|
||||
/// </summary>
|
||||
@ -85,16 +71,6 @@ namespace AlicizaX.UI
|
||||
/// </summary>
|
||||
internal abstract void UnbindInternal();
|
||||
|
||||
/// <summary>
|
||||
/// 由框架内部调用,将对象数据绑定到当前渲染实例。
|
||||
/// </summary>
|
||||
/// <param name="data">待绑定的数据对象。</param>
|
||||
/// <param name="index">当前数据索引。</param>
|
||||
void IItemRender.Bind(object data, int index)
|
||||
{
|
||||
BindObject(data, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 由框架内部调用,更新当前渲染实例的选中状态。
|
||||
/// </summary>
|
||||
@ -206,21 +182,6 @@ namespace AlicizaX.UI
|
||||
/// </summary>
|
||||
protected virtual RecyclerNavigationOptions NavigationOptions => RecyclerNavigationOptions.Circular;
|
||||
|
||||
/// <summary>
|
||||
/// 以对象形式绑定数据并执行强类型校验。
|
||||
/// </summary>
|
||||
/// <param name="data">待绑定的数据对象。</param>
|
||||
/// <param name="index">当前数据索引。</param>
|
||||
internal override void BindObject(object data, int index)
|
||||
{
|
||||
if (data is not TData itemData)
|
||||
{
|
||||
throw new InvalidCastException(
|
||||
$"ItemRender '{GetType().Name}' expected data '{typeof(TData).Name}', but got '{data?.GetType().Name ?? "null"}'.");
|
||||
}
|
||||
|
||||
BindCore(itemData, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 由框架内部调用,使用强类型数据执行绑定。
|
||||
|
||||
Loading…
Reference in New Issue
Block a user