Giter Site home page Giter Site logo

Comments (8)

Aspsine avatar Aspsine commented on July 28, 2024

首先,感谢你的宝贵意见。周末比较忙,没来的急回复。在零碎的时间里仔细考虑了一下你的建议。

在java命名规则中以new打头的方法,newSomeThing(),都会返回一个SomeThing的对象。比如volley的newRequestQueue(...)返回一个RequestQueue对象,Executors.newFixedThreadPool(...)返回一个ThreadPoolExecutor对象。
在MultiThreadDownload这个项目中,最好是对DownloadManager维护一个单例,以便对下载进行控制以及下载状态的回调。
而在Volley中,Volley的Request是可以自定义的,而不同的Request可能差别很大。比如如果把下载图片的Request和web api的Request公用一个RequestQueue来进行调度,可能在某些情况下会有问题。所以Volley本身对于Request没有维护一个单例,而是把这个任务交给开发者来完成,显得更加灵活。

所以我会考虑改成:
DownloadManager.init(context);
DownloadManager.init(context, config);

from multithreaddownload.

mattxzhang avatar mattxzhang commented on July 28, 2024

点击暂停,就异常终止闪退了

from multithreaddownload.

Aspsine avatar Aspsine commented on July 28, 2024

@mattxzhang
可以提供一下机型么?
如果可以帮助我调试一下,告诉我具体什么错误?
当然,你直接修复pull request那就更好了。

from multithreaddownload.

mattxzhang avatar mattxzhang commented on July 28, 2024

机型是小米2,系统5.0.2,就是下载时点击暂停就异常终止了,你的代码暂时没看,只是先看下效果

from multithreaddownload.

mattxzhang avatar mattxzhang commented on July 28, 2024

刚又试了下,不是机型的问题,操作步骤就是频繁点击(暂停,开始),滚动,就闪退了,测试了其他手机都是如此

from multithreaddownload.

Aspsine avatar Aspsine commented on July 28, 2024

@mattxzhang
你的安装包是在论坛下载的还是在github的页面上下载的?论坛下载的可能版本有点旧。我这边测试没有问题。我手头mx5 5.0.1,galaxy nexus 4.3.2, huawei c8815 miui, huawei honor 6 4.4 都没问题。

from multithreaddownload.

mattxzhang avatar mattxzhang commented on July 28, 2024

github页面下载的demo.apk,只需要频繁点击下载-暂停,就崩溃了,很好复现

from multithreaddownload.

Aspsine avatar Aspsine commented on July 28, 2024

@mattxzhang
谢谢持续反馈,我今天用同事的MX4也测试到了。问题已经定位。
奇怪的是我的几个手机都没问题。
当时在设计“取消下载”和“暂停下载”这两个功能的时候。最初是使用信号量的,但是当HttpURLConnection 处于阻塞状态,使用信号量就没办法及时暂停回调。
所以,我尝试了一种很暴力的办法直接调用disconnect()来close HttpURLConnection 所以依赖的Socket,来catch相应的Exception再配合信号量来确认状态进行回调。测试下来,在我的四个手机上以及GenyMotion的虚拟机上也没有问题,回调很及时。没想到还是出了问题。

两周内我会重构一次,到时候api可能会有所调整。
再次感谢。

我已经将此问题移到 #25

from multithreaddownload.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.