java加载网图并缓存下来_java – 图像未被缓存在本地(使用通用图像加载程序) – 缓慢的图像加载时间...

问题描述:

我正在创建一个可滚动列表的文章,缩略图由我的sqlite数据库填充.一般来说,它是“工作”,除了缓慢:

图像加载非常缓慢…我以为使用“Universal Image Loader”缓存设备上的图像,这将使它们似乎只是滚动到视图,如果你已经查看了(或至少接近).但是 – 当您向上/向下拖动时,图像中没有任何图像,然后3-5秒钟后,图像开始弹出(就像重新下载它们)

我正在更改缩略图框的可见性,但是这是完美无缺的 – 它们似乎没有改变 – 它们只是滚动到视图中,不闪烁或任何东西. (但是图像不会再出现几秒钟).

我已经通过删除我的PHP脚本,滚动后…当我回滚到上一个点,图像不显示 – 让我假设它从我的PHP脚本加载每一次.

但是根据the docs:“UsingFreqLimitedMemoryCache(超过缓存大小限制时,最常使用的位图被删除) – 默认使用”

细节:

在我的ArticleEntryAdapter.js中我有:

@Override

public View getView(final int position,final View convertView,final ViewGroup parent) {

// We need to get the best view (re-used if possible) and then

// retrieve its corresponding ViewHolder,which optimizes lookup efficiency

final View view = getWorkingView(convertView);

final ViewHolder viewHolder = getViewHolder(view);

final Article article = getItem(position);

// Set the title

viewHolder.titleView.setText(article.title);

//Set the subtitle (subhead) or description

if(article.subtitle != null)

{

viewHolder.subTitleView.setText(article.subtitle);

}

else if(article.description != null)

{

viewHolder.subTitleView.setText(article.description);

}

ImageLoader imageLoader = ImageLoader.getInstance();

imageLoader.displayImage("",viewHolder.thumbView); //clears prevIoUs one

if(article.filepath != null && article.filepath.length() != 0) {

imageLoader.displayImage(

"http://img.sltdb.com/processes/resize.PHP?image=" + article.filepath + "&size=100&quality=70",viewHolder.thumbView

);

viewHolder.thumbView.setVisibility(View.VISIBLE);

} else {

viewHolder.thumbView.setVisibility(View.GONE);

}

return view;

}

只要图像不正确 – 它不是经常的,但有时滚动时,我会看到相同的图像2,当我看文章时,它们并不完全相关(即没有机会实际使用相同的图像)所以 – 我滚开它,并回来,它不再是不正确的图像.

注意:我是Java / Android的新手 – 您可能已经注意到了.

每个注释请求的更多代码:

private View getWorkingView(final View convertView) {

// The workingView is basically just the convertView re-used if possible

// or inflated new if not possible

View workingView = null;

if(null == convertView) {

final Context context = getContext();

final LayoutInflater inflater = (LayoutInflater)context.getSystemService

(Context.LAYOUT_INFLATER_SERVICE);

workingView = inflater.inflate(articleItemLayoutResource,null);

} else {

workingView = convertView;

}

return workingView;

}

更新:

我的清单文件有:

但是我发现的缓存文件夹完全是空的:

mnt

-sdcard

-Android

-data

-com.mysite.news

-cache

-uil-images

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值