在这篇使用说明中,我将给大家介绍OrangeUI中的图片下载管理者DownloadPictureManager的使用。
DownloadPictureManager用于下载图片,并将图片缓存到本地。
内部工作机制:
创建线程,然后在线程中创建HttpControl来一一下载图片,
HttpControl,需要指定DownloadPictureHttpControlClass,
您可以使用uIdHttpControl.pas或uNativeHttpControl.pas,
下载图片后缓存到下载目录,并将下载数据保存到UrlPictureList.dat,
属性有:
DownloadDir:Boolean;//下载根目录
默认下载目录为EXE目录下面的OrangeUIDownloadPictures,
如果不存在,则创建
GroupName:Boolean;//分组名称
用于区分每个DownloadPictureManager的下载目录和缓存保存目录
方法有:
//下载网络图片
function DownloadPicture(
//链接
const Url:String;
//图片
const DrawPicture:TObject=nil;
//附加数据
const Data:Pointer=nil;
//文件路径
const FilePath:String='';
//后缀
const FileExt:String=''
):TUrlPicture;
事件有:
//检查下载下来的数据流
OnCheckDownloadStream:TCheckDownloadStreamEvent
//下载失败事件
OnDownloadError:TDownloadPictureErrorEvent
//下载成功事件
OnDownloadSucc:TDownloadPictureSuccEvent