77 lines
1.5 KiB
C#
77 lines
1.5 KiB
C#
using System.Collections;
|
|
using Android.Views;
|
|
using System.ComponentModel;
|
|
using System.Collections.ObjectModel;
|
|
|
|
namespace TYTD.Mobile;
|
|
|
|
public class ObservableCollectionRecyclerViewAdapter<T> : IList<T>
|
|
{
|
|
private ObservableCollection<T> _coll=new ObservableCollection<T>();
|
|
public int Count {get{return _coll.Count;}}
|
|
|
|
public bool IsReadOnly {get{return false;}}
|
|
|
|
public T this[int index] { get {return _coll[index];} set {_coll[index]=value;} }
|
|
|
|
public ObservableCollectionRecyclerViewAdapter(RecylerView,Action<View,T> viewCb)
|
|
{
|
|
|
|
}
|
|
public void Add(T item)
|
|
{
|
|
_coll.Add(item);
|
|
}
|
|
public void Clear()
|
|
{
|
|
_coll.Clear();
|
|
}
|
|
public void AddRange(IEnumerable<T> items)
|
|
{
|
|
foreach(var item in items)
|
|
{
|
|
_coll.Add(item);
|
|
}
|
|
}
|
|
|
|
public int IndexOf(T item)
|
|
{
|
|
return _coll.IndexOf(item);
|
|
}
|
|
|
|
public void Insert(int index, T item)
|
|
{
|
|
_coll.Insert(index,item);
|
|
}
|
|
|
|
public void RemoveAt(int index)
|
|
{
|
|
_coll.RemoveAt(index);
|
|
}
|
|
|
|
public bool Contains(T item)
|
|
{
|
|
return _coll.Contains(item);
|
|
}
|
|
|
|
public void CopyTo(T[] array, int arrayIndex)
|
|
{
|
|
_coll.CopyTo(array,arrayIndex);
|
|
}
|
|
|
|
public bool Remove(T item)
|
|
{
|
|
_coll.Remove(item);
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public IEnumerator<T> GetEnumerator()
|
|
{
|
|
return _coll.GetEnumerator();
|
|
}
|
|
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
{
|
|
return _coll.GetEnumerator();
|
|
}
|
|
} |