Search in sources :

Example 6 with EvictDynamicKey

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);
        }
    });
}
Also used : Function(io.reactivex.functions.Function) BaseResult(com.dante.data.model.BaseResult) EvictDynamicKey(io.rx_cache2.EvictDynamicKey) Reply(io.rx_cache2.Reply) EvictDynamicKeyGroup(io.rx_cache2.EvictDynamicKeyGroup) DynamicKeyGroup(io.rx_cache2.DynamicKeyGroup) UnLimit91PornItem(com.dante.data.model.UnLimit91PornItem) FavoriteException(com.dante.exception.FavoriteException) MessageException(com.dante.exception.MessageException)

Example 7 with EvictDynamicKey

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);
        }
    });
}
Also used : Function(io.reactivex.functions.Function) BaseResult(com.dante.data.model.BaseResult) EvictDynamicKey(io.rx_cache2.EvictDynamicKey) Reply(io.rx_cache2.Reply) EvictDynamicKeyGroup(io.rx_cache2.EvictDynamicKeyGroup) DynamicKeyGroup(io.rx_cache2.DynamicKeyGroup) UnLimit91PornItem(com.dante.data.model.UnLimit91PornItem) FavoriteException(com.dante.exception.FavoriteException) MessageException(com.dante.exception.MessageException)

Example 8 with EvictDynamicKey

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();
        }
    });
}
Also used : Function(io.reactivex.functions.Function) PigAvVideo(com.dante.data.model.PigAvVideo) EvictDynamicKey(io.rx_cache2.EvictDynamicKey) Reply(io.rx_cache2.Reply) DynamicKey(io.rx_cache2.DynamicKey) EvictDynamicKey(io.rx_cache2.EvictDynamicKey) FavoriteException(com.dante.exception.FavoriteException) MessageException(com.dante.exception.MessageException)

Example 9 with EvictDynamicKey

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);
        }
    });
}
Also used : Function(io.reactivex.functions.Function) BaseResult(com.dante.data.model.BaseResult) EvictDynamicKey(io.rx_cache2.EvictDynamicKey) Reply(io.rx_cache2.Reply) EvictDynamicKeyGroup(io.rx_cache2.EvictDynamicKeyGroup) DynamicKeyGroup(io.rx_cache2.DynamicKeyGroup) UnLimit91PornItem(com.dante.data.model.UnLimit91PornItem) FavoriteException(com.dante.exception.FavoriteException) MessageException(com.dante.exception.MessageException)

Example 10 with EvictDynamicKey

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));
}
Also used : EvictDynamicKey(io.rx_cache2.EvictDynamicKey) Reply(io.rx_cache2.Reply) EvictDynamicKey(io.rx_cache2.EvictDynamicKey) DynamicKey(io.rx_cache2.DynamicKey) Test(org.junit.Test)

Aggregations

EvictDynamicKey (io.rx_cache2.EvictDynamicKey)11 Reply (io.rx_cache2.Reply)7 FavoriteException (com.dante.exception.FavoriteException)6 MessageException (com.dante.exception.MessageException)6 Function (io.reactivex.functions.Function)6 DynamicKey (io.rx_cache2.DynamicKey)6 BaseResult (com.dante.data.model.BaseResult)4 UnLimit91PornItem (com.dante.data.model.UnLimit91PornItem)4 DynamicKeyGroup (io.rx_cache2.DynamicKeyGroup)4 EvictDynamicKeyGroup (io.rx_cache2.EvictDynamicKeyGroup)4 Test (org.junit.Test)4 Method (java.lang.reflect.Method)3 PigAvVideo (com.dante.data.model.PigAvVideo)1 VideoResult (com.dante.data.model.VideoResult)1 ConfigProvider (io.rx_cache2.ConfigProvider)1