91 lines
2.0 KiB
C#
91 lines
2.0 KiB
C#
|
|
using UnityEngine;
|
|||
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Text;
|
|||
|
|
using System;
|
|||
|
|
|
|||
|
|
namespace Thousandto.Plugins.Common
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 数据类,适配器,用于适配各种数据,这是一个基类
|
|||
|
|
/// </summary>
|
|||
|
|
public abstract class ListItemAdapter
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// <缓存的内容, 数据, 返回>, 用于实例化Item
|
|||
|
|
/// </summary>
|
|||
|
|
public Func<ItemHolder, object, ItemHolder> Instantiate;
|
|||
|
|
|
|||
|
|
public virtual void AddData(object obj, object sender = null)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 返回数据总个数
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public virtual int GetCount()
|
|||
|
|
{
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public virtual List<int> GetIndexs(int channel)
|
|||
|
|
{
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public virtual int GetReverseNextIndex(int index)
|
|||
|
|
{
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public virtual int GetNextIndex(int index)
|
|||
|
|
{
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public virtual int GetChannelId(int index)
|
|||
|
|
{
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 返回指定序号的数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="index"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public virtual object GetData(int index)
|
|||
|
|
{
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public ItemHolder GetView(int index, ItemHolder holder)
|
|||
|
|
{
|
|||
|
|
var count = GetCount();
|
|||
|
|
if(index >= count)
|
|||
|
|
{
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var data = GetData(index);
|
|||
|
|
if (data == null)
|
|||
|
|
{
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
if (holder == null)
|
|||
|
|
{
|
|||
|
|
holder = new ItemHolder();
|
|||
|
|
holder = Instantiate(null, data);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
holder = Instantiate(holder, data);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return holder;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|