use of com.hippo.ehviewer.spider.SpiderQueen in project EhViewer by seven332.
the class DownloadManager method stopCurrentDownloadInternal.
// Update in DB
// Update mDownloadListener
private DownloadInfo stopCurrentDownloadInternal() {
DownloadInfo info = mCurrentTask;
SpiderQueen spider = mCurrentSpider;
// Release spider
if (spider != null) {
spider.removeOnSpiderListener(DownloadManager.this);
SpiderQueen.releaseSpiderQueen(spider, SpiderQueen.MODE_DOWNLOAD);
}
mCurrentTask = null;
mCurrentSpider = null;
// Stop speed reminder
mSpeedReminder.stop();
if (info == null) {
return null;
}
// Update state
info.state = DownloadInfo.STATE_NONE;
// Update in DB
EhDB.putDownloadInfo(info);
// Listener
if (mDownloadListener != null) {
mDownloadListener.onCancel(info);
}
return info;
}
use of com.hippo.ehviewer.spider.SpiderQueen in project EhViewer by seven332.
the class DownloadManager method ensureDownload.
private void ensureDownload() {
if (mCurrentTask != null) {
// Only one download
return;
}
// Get download from wait list
if (!mWaitList.isEmpty()) {
DownloadInfo info = mWaitList.removeFirst();
SpiderQueen spider = SpiderQueen.obtainSpiderQueen(mContext, info, SpiderQueen.MODE_DOWNLOAD);
mCurrentTask = info;
mCurrentSpider = spider;
spider.addOnSpiderListener(this);
info.state = DownloadInfo.STATE_DOWNLOAD;
info.speed = -1;
info.remaining = -1;
info.total = -1;
info.finished = 0;
info.downloaded = 0;
info.legacy = -1;
// Update in DB
EhDB.putDownloadInfo(info);
// Start speed count
mSpeedReminder.start();
// Notify start downloading
if (mDownloadListener != null) {
mDownloadListener.onStart(info);
}
// Notify state update
List<DownloadInfo> list = getInfoListForLabel(info.label);
if (list != null) {
for (DownloadInfoListener l : mDownloadInfoListeners) {
l.onUpdate(info, list);
}
}
}
}
Aggregations