mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-24 18:08:24 +01:00
Use lambdas in CacheManager
This commit is contained in:
parent
36265472f8
commit
a6a05fbb7f
@ -49,9 +49,7 @@ public class CacheManager {
|
||||
}
|
||||
|
||||
public Observable<File> cacheImagesFromUrls(final List<String> imageUrls) {
|
||||
return Observable.create(new Observable.OnSubscribe<File>() {
|
||||
@Override
|
||||
public void call(Subscriber<? super File> subscriber) {
|
||||
return Observable.create(subscriber -> {
|
||||
try {
|
||||
for (String imageUrl : imageUrls) {
|
||||
if (!subscriber.isUnsubscribed()) {
|
||||
@ -62,7 +60,6 @@ public class CacheManager {
|
||||
} catch (Throwable e) {
|
||||
subscriber.onError(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -75,16 +72,13 @@ public class CacheManager {
|
||||
}
|
||||
|
||||
public Observable<Boolean> clearImageCache() {
|
||||
return Observable.create(new Observable.OnSubscribe<Boolean>() {
|
||||
@Override
|
||||
public void call(Subscriber<? super Boolean> subscriber) {
|
||||
return Observable.create(subscriber -> {
|
||||
try {
|
||||
subscriber.onNext(clearImageCacheImpl());
|
||||
subscriber.onCompleted();
|
||||
} catch (Throwable e) {
|
||||
subscriber.onError(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -117,9 +111,7 @@ public class CacheManager {
|
||||
}
|
||||
|
||||
public Observable<String> getImageUrlsFromDiskCache(final String chapterUrl) {
|
||||
return Observable.create(new Observable.OnSubscribe<String>() {
|
||||
@Override
|
||||
public void call(Subscriber<? super String> subscriber) {
|
||||
return Observable.create(subscriber -> {
|
||||
try {
|
||||
String[] imageUrls = getImageUrlsFromDiskCacheImpl(chapterUrl);
|
||||
|
||||
@ -132,7 +124,6 @@ public class CacheManager {
|
||||
} catch (Throwable e) {
|
||||
subscriber.onError(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -154,15 +145,12 @@ public class CacheManager {
|
||||
}
|
||||
|
||||
public Action0 putImageUrlsToDiskCache(final String chapterUrl, final List<String> imageUrls) {
|
||||
return new Action0() {
|
||||
@Override
|
||||
public void call() {
|
||||
return () -> {
|
||||
try {
|
||||
putImageUrlsToDiskCacheImpl(chapterUrl, imageUrls);
|
||||
} catch (IOException e) {
|
||||
// Do Nothing.
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user