use of io.rx_cache2.EvictDynamicKey in project 91Pop by DanteAndroid.
the class AppApiHelper method loadPorn91VideoRecentUpdates.
@Override
public Observable<BaseResult<List<UnLimit91PornItem>>> loadPorn91VideoRecentUpdates(String next, int page, boolean cleanCache, boolean isLoadMoreCleanCache) {
DynamicKeyGroup dynamicKeyGroup = new DynamicKeyGroup(next, page);
EvictDynamicKey evictDynamicKey = new EvictDynamicKey(cleanCache || isLoadMoreCleanCache);
Observable<String> categoryPage = noLimit91PornServiceApi.recentUpdates(next, page, HeaderUtils.getIndexHeader(addressHelper));
return cacheProviders.getRecentUpdates(categoryPage, dynamicKeyGroup, evictDynamicKey).map(new Function<Reply<String>, String>() {
@Override
public String apply(Reply<String> responseBody) throws Exception {
return responseBody.getData();
}
}).map(new Function<String, BaseResult<List<UnLimit91PornItem>>>() {
@Override
public BaseResult<List<UnLimit91PornItem>> apply(String s) throws Exception {
return Parse91PronVideo.parseHot(s);
}
});
}
use of io.rx_cache2.EvictDynamicKey in project 91Pop by DanteAndroid.
the class AppApiHelper method loadPorn91VideoByCategory.
@Override
public Observable<BaseResult<List<UnLimit91PornItem>>> loadPorn91VideoByCategory(String category, String viewType, int page, String m, boolean cleanCache, boolean isLoadMoreCleanCache) {
// RxCache条件区别
String condition;
if (TextUtils.isEmpty(m)) {
condition = category;
} else {
condition = category + m;
}
DynamicKeyGroup dynamicKeyGroup = new DynamicKeyGroup(condition, page);
EvictDynamicKey evictDynamicKey = new EvictDynamicKey(cleanCache || isLoadMoreCleanCache);
Observable<String> categoryPage = noLimit91PornServiceApi.getCategoryPage(category, viewType, page, m, HeaderUtils.getIndexHeader(addressHelper));
return cacheProviders.getCategoryPage(categoryPage, dynamicKeyGroup, evictDynamicKey).map(new Function<Reply<String>, String>() {
@Override
public String apply(Reply<String> responseBody) throws Exception {
return responseBody.getData();
}
}).map(new Function<String, BaseResult<List<UnLimit91PornItem>>>() {
@Override
public BaseResult<List<UnLimit91PornItem>> apply(String s) throws Exception {
return Parse91PronVideo.parseHot(s);
}
});
}
use of io.rx_cache2.EvictDynamicKey in project 91Pop by DanteAndroid.
the class AppApiHelper method loadPigAvVideoUrl.
@Override
public Observable<PigAvVideo> loadPigAvVideoUrl(String url, String pId, boolean pullToRefresh) {
if (TextUtils.isEmpty(pId)) {
pId = "aaa1";
pullToRefresh = true;
}
DynamicKey dynamicKey = new DynamicKey(pId);
return cacheProviders.cacheWithNoLimitTime(pigAvServiceApi.pigAvVideoUrl(url), dynamicKey, new EvictDynamicKey(pullToRefresh)).map(new Function<Reply<String>, String>() {
@Override
public String apply(Reply<String> stringReply) throws Exception {
return stringReply.getData();
}
}).map(new Function<String, PigAvVideo>() {
@Override
public PigAvVideo apply(String s) throws Exception {
return ParsePigAv.parserVideoUrl(s).getData();
}
});
}
use of io.rx_cache2.EvictDynamicKey in project 91Pop by DanteAndroid.
the class AppApiHelper method loadPorn91authorVideos.
@Override
public Observable<BaseResult<List<UnLimit91PornItem>>> loadPorn91authorVideos(String uid, String type, int page, boolean cleanCache) {
// RxCache条件区别
String condition = null;
if (!TextUtils.isEmpty(uid)) {
condition = uid;
}
DynamicKeyGroup dynamicKeyGroup = new DynamicKeyGroup(condition, page);
EvictDynamicKey evictDynamicKey = new EvictDynamicKey(cleanCache);
Observable<String> stringObservable = noLimit91PornServiceApi.authorVideos(uid, type, page);
return cacheProviders.authorVideos(stringObservable, dynamicKeyGroup, evictDynamicKey).map(new Function<Reply<String>, String>() {
@Override
public String apply(Reply<String> responseBody) throws Exception {
return responseBody.getData();
}
}).map(new Function<String, BaseResult<List<UnLimit91PornItem>>>() {
@Override
public BaseResult<List<UnLimit91PornItem>> apply(String s) throws Exception {
return Parse91PronVideo.parseAuthorVideos(s);
}
});
}
use of io.rx_cache2.EvictDynamicKey in project RxCache by VictorAlbertos.
the class ProvidersDynamicsKeysRxCacheTest method Pagination_With_Evict_Cache_By_Page.
@Test
public void Pagination_With_Evict_Cache_By_Page() {
TestObserver<Reply<List<io.rx_cache2.internal.Mock>>> observer;
observer = providersRxCache.getMocksDynamicKeyEvictPage(Observable.just(createMocks(SIZE)), new DynamicKey(1), new EvictDynamicKey(true)).test();
observer.awaitTerminalEvent();
observer = providersRxCache.getMocksDynamicKeyEvictPage(Observable.just(createMocks(SIZE)), new DynamicKey(2), new EvictDynamicKey(true)).test();
observer.awaitTerminalEvent();
observer = providersRxCache.getMocksDynamicKeyEvictPage(ProviderHelper.<List<io.rx_cache2.internal.Mock>>withoutLoader(), new DynamicKey(1), new EvictDynamicKey(true)).test();
observer.awaitTerminalEvent();
assertThat(observer.errors().size(), is(1));
assertThat(observer.values().size(), is(0));
observer = providersRxCache.getMocksDynamicKeyEvictPage(ProviderHelper.<List<io.rx_cache2.internal.Mock>>withoutLoader(), new DynamicKey(2), new EvictDynamicKey(false)).test();
observer.awaitTerminalEvent();
assertThat(observer.errors().size(), is(0));
assertThat(observer.values().size(), is(1));
}
Aggregations