Search in sources :

Example 1 with SpiderInfo

use of com.hippo.ehviewer.spider.SpiderInfo in project EhViewer by seven332.

the class DownloadManager method resetAllReadingProgress.

@SuppressLint("StaticFieldLeak")
public void resetAllReadingProgress() {
    LinkedList<DownloadInfo> list = new LinkedList<>(mAllInfoList);
    new AsyncTask<Void, Void, Void>() {

        @Override
        protected Void doInBackground(Void... voids) {
            GalleryInfo galleryInfo = new GalleryInfo();
            for (DownloadInfo downloadInfo : list) {
                galleryInfo.gid = downloadInfo.gid;
                galleryInfo.token = downloadInfo.token;
                galleryInfo.title = downloadInfo.title;
                galleryInfo.thumb = downloadInfo.thumb;
                galleryInfo.category = downloadInfo.category;
                galleryInfo.posted = downloadInfo.posted;
                galleryInfo.uploader = downloadInfo.uploader;
                galleryInfo.rating = downloadInfo.rating;
                UniFile downloadDir = SpiderDen.getGalleryDownloadDir(galleryInfo);
                if (downloadDir == null) {
                    continue;
                }
                UniFile file = downloadDir.findFile(".ehviewer");
                if (file == null) {
                    continue;
                }
                SpiderInfo spiderInfo = SpiderInfo.read(file);
                if (spiderInfo == null) {
                    continue;
                }
                spiderInfo.startPage = 0;
                try {
                    spiderInfo.write(file.openOutputStream());
                } catch (IOException e) {
                    Log.e(TAG, "Can't write SpiderInfo", e);
                }
            }
            return null;
        }
    }.executeOnExecutor(IoThreadPoolExecutor.getInstance());
}
Also used : UniFile(com.hippo.unifile.UniFile) DownloadInfo(com.hippo.ehviewer.dao.DownloadInfo) GalleryInfo(com.hippo.ehviewer.client.data.GalleryInfo) IOException(java.io.IOException) LinkedList(java.util.LinkedList) SpiderInfo(com.hippo.ehviewer.spider.SpiderInfo) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 GalleryInfo (com.hippo.ehviewer.client.data.GalleryInfo)1 DownloadInfo (com.hippo.ehviewer.dao.DownloadInfo)1 SpiderInfo (com.hippo.ehviewer.spider.SpiderInfo)1 UniFile (com.hippo.unifile.UniFile)1 IOException (java.io.IOException)1 LinkedList (java.util.LinkedList)1