取消进步的基础上,图像请求的Andr​​oid - 图像装载机排球,毕加索 [英] Cancelling the Image Request Android on the basis of progress - Image loader Volley , Picasso

查看:141
本文介绍了取消进步的基础上,图像请求的Andr​​oid - 图像装载机排球,毕加索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有用于图像加载和缓存和管理图像请求在Github上提供许多流行的图像加载器。

There are many popular Image loader available in Github for image loading and caching and Managing Image Request.


  1. 通用​​图像装载机

  2. 排球

  3. 毕加索

  4. 壁画(添加增强

  1. Universal Image Loader
  2. Volley
  3. Picasso
  4. Fresco (added enhancement )

我碰到的要求来,如果在的ImageView 如果不再连接到窗口请求(批次和飞行)将被取消。

I came across the requirement if the Imageview if no longer attached to window the request (batch and flight ) will be cancelled .

然而滚动部件例如列表视图 分别和GridView ImageView的频繁连接并从窗户脱落,所以在队列中的请求被取消

However the scrolling widget like Listview and Gridview the Imageview is frequently attached and detached from window and so the request in queue are canceled respectively .

我担心的是,他们没有任何机制来跟踪图像请求的进展在上述所有库。如果的ImageView 是分离的要求应该的进展的基础上被取消,如果字节流过已经完成的工作的75%,那么它不应该被取消,这反过来将降低网络带宽,降低网络呼叫,因为通常用户始终处于滚动控件滚动很像列表视图的GridView

My concern is that their no mechanism to trace the progress of image request in all above library .If Imageview is detached the request should be cancelled on the basis of progress , if the byte stream a had already done 75% of work then it should not be cancelled , which in turn will reduce the network bandwidth and decrease network call , as usually user always scroll a lot in Scrolling Widget like Listview and Gridview etc ..

这是我与排球的理解:

public boolean removeContainerAndCancelIfNecessary(ImageContainer container) {

    /* logic to check progress of Request */
    mContainers.remove(container);
    if (mContainers.size() == 0) {

        mRequest.cancel();
        return true;
    }
    return false;
}

这是我与毕加索的理解:

private void cancelExistingRequest(Object target) {

    checkMain();
    Action action = targetToAction.remove(target);
    if (action != null) {

        action.cancel();
        dispatcher.dispatchCancel(action);
    }
    if (target instanceof ImageView) {

        ImageView targetImageView = (ImageView) target;
        DeferredRequestCreator deferredRequestCreator = targetToDeferredRequestCreator.remove(targetImageView);
        if (deferredRequestCreator != null) {

            deferredRequestCreator.cancel();
        }
    }
}

这是我与环球图像装载机的理解:
我也没弄清楚通用映像加载许可证取消内嵌请求。

void cancelDisplayTaskFor(ImageAware imageAware) {

    cacheKeysForImageAwares.remove(imageAware.getId());
} 

请让我知道解决这个问题只有网络请求的可能性。如果图像已经缓存,然后我们将取消该请求。

Please let me know the possibility to solve it for Network Request only . In case the image is already cached then we will cancel the request .

电池性能在Android中真正重要的

Battery performance is really important in Android

推荐答案

我不能说排球和毕加索,但我可以说的是如何UIL的作品。

I can't say about Volley and Picasso but I can say how UIL works.

UIL任务处理过程中不断检查ImageView的。如果任务变得不实际(ImageView的再循环(再利用),或者它是由GC回收),然后UIL停止任务此ImageView的。

UIL constantly checks ImageView during task processing. If task becomes non-actual (ImageView is recycled (reused) or it's collected by GC) then UIL stops task for this ImageView.

样,如果在下载图像任务变得不实际是什么?如果有被下载的图像数据的小于75%UIL将中止下载。如果超过75% - 然后UIL完成下载(即UIL缓存映像文件中的磁盘缓存),然后取消任务

What about if task becomes non-actual while downloading image? UIL aborts downloading if there was downloaded less than 75% of image data. If more than 75% - then UIL completes downloading (i.e. UIL caches image file in disk cache) and then cancels task.

这篇关于取消进步的基础上,图像请求的Andr​​oid - 图像装载机排球,毕加索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆