Minor refactor on caches

This commit is contained in:
inorichi
2016-01-28 01:01:55 +01:00
parent d8ab8f297f
commit 74c32f9e16
3 changed files with 77 additions and 120 deletions
@@ -93,7 +93,7 @@ public abstract class Source extends BaseSource {
}
public Observable<List<Page>> getCachedPageListOrPullFromNetwork(final String chapterUrl) {
return chapterCache.getPageUrlsFromDiskCache(getChapterCacheKey(chapterUrl))
return chapterCache.getPageListFromCache(getChapterCacheKey(chapterUrl))
.onErrorResumeNext(throwable -> {
return pullPageListFromNetwork(chapterUrl);
})
@@ -168,7 +168,7 @@ public abstract class Source extends BaseSource {
return getImageProgressResponse(page)
.flatMap(resp -> {
try {
chapterCache.putImageToDiskCache(page.getImageUrl(), resp);
chapterCache.putImageToCache(page.getImageUrl(), resp);
} catch (IOException e) {
return Observable.error(e);
}
@@ -182,7 +182,7 @@ public abstract class Source extends BaseSource {
public void savePageList(String chapterUrl, List<Page> pages) {
if (pages != null)
chapterCache.putPageUrlsToDiskCache(getChapterCacheKey(chapterUrl), pages);
chapterCache.putPageListToCache(getChapterCacheKey(chapterUrl), pages);
}
protected List<Page> convertToPages(List<String> pageUrls) {