Search in sources :

Example 11 with Reply

use of com.github.jh3nd3rs0n.jargyle.transport.socks5.Reply 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 12 with Reply

use of com.github.jh3nd3rs0n.jargyle.transport.socks5.Reply 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 13 with Reply

use of com.github.jh3nd3rs0n.jargyle.transport.socks5.Reply in project RxCache by VictorAlbertos.

the class ProcessorProvidersTest method When_No_Evict_Cache_Then_Source_Retrieved_Is_Not_Cloud.

@Test
public void When_No_Evict_Cache_Then_Source_Retrieved_Is_Not_Cloud() {
    TestObserver observerMock = getSubscriberCompleted(true, false, true, Loader.VALID, false);
    Reply<Mock> reply = (Reply) observerMock.values().get(0);
    assertThat(reply.getSource(), is(not(Source.CLOUD)));
    assertNotNull(reply.getData());
}
Also used : Reply(io.rx_cache2.Reply) TestObserver(io.reactivex.observers.TestObserver) BaseTest(io.rx_cache2.internal.common.BaseTest) Test(org.junit.Test)

Example 14 with Reply

use of com.github.jh3nd3rs0n.jargyle.transport.socks5.Reply in project RxCache by VictorAlbertos.

the class ProcessorProvidersTest method When_First_Retrieve_Then_Source_Retrieved_Is_Cloud.

@Test
public void When_First_Retrieve_Then_Source_Retrieved_Is_Cloud() {
    TestObserver observerMock = getSubscriberCompleted(false, false, true, Loader.VALID, false);
    Reply<Mock> reply = (Reply) observerMock.values().get(0);
    assertThat(reply.getSource(), is(Source.CLOUD));
    assertNotNull(reply.getData());
}
Also used : Reply(io.rx_cache2.Reply) TestObserver(io.reactivex.observers.TestObserver) BaseTest(io.rx_cache2.internal.common.BaseTest) Test(org.junit.Test)

Example 15 with Reply

use of com.github.jh3nd3rs0n.jargyle.transport.socks5.Reply in project RxCache by VictorAlbertos.

the class ProvidersRxCacheTest method _12_When_Retrieve_Cached_Data_After_Modified_Object_On_Item_Map_Then_Object_Preserves_Initial_State.

@Test
public void _12_When_Retrieve_Cached_Data_After_Modified_Object_On_Item_Map_Then_Object_Preserves_Initial_State() {
    initProviders(false);
    TestObserver<Reply<Map<Integer, io.rx_cache2.internal.Mock>>> subscriber;
    subscriber = new TestObserver<>();
    providersRxCache.getMocksMapResponse(createObservableMocksMap(SIZE)).subscribe(subscriber);
    subscriber.awaitTerminalEvent();
    Reply<Map<Integer, io.rx_cache2.internal.Mock>> reply = subscriber.values().get(0);
    Type type = new TypeToken<Reply<Map<Integer, io.rx_cache2.internal.Mock>>>() {
    }.getType();
    Reply<Map<Integer, io.rx_cache2.internal.Mock>> replyOriginal = (Reply<Map<Integer, io.rx_cache2.internal.Mock>>) deepCopy(reply, type);
    assertThat(compare(reply, replyOriginal, type), is(true));
    reply.getData().get(0).setMessage("modified");
    assertThat(compare(reply, replyOriginal, type), is(false));
    subscriber = new TestObserver<>();
    providersRxCache.getMocksMapResponse(ProviderHelper.<Map<Integer, io.rx_cache2.internal.Mock>>withoutLoader()).subscribe(subscriber);
    subscriber.awaitTerminalEvent();
    assertThat(subscriber.errors().size(), is(0));
    assertThat(subscriber.values().size(), is(1));
    reply = subscriber.values().get(0);
    type = new TypeToken<Map<Integer, io.rx_cache2.internal.Mock>>() {
    }.getType();
    assertThat(compare(reply.getData(), replyOriginal.getData(), type), is(true));
}
Also used : Type(java.lang.reflect.Type) TypeToken(com.google.gson.reflect.TypeToken) Reply(io.rx_cache2.Reply) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

Reply (io.rx_cache2.Reply)16 Function (io.reactivex.functions.Function)9 FavoriteException (com.dante.exception.FavoriteException)7 MessageException (com.dante.exception.MessageException)7 EvictDynamicKey (io.rx_cache2.EvictDynamicKey)7 Test (org.junit.Test)7 BaseResult (com.dante.data.model.BaseResult)6 DynamicKeyGroup (io.rx_cache2.DynamicKeyGroup)6 EvictDynamicKeyGroup (io.rx_cache2.EvictDynamicKeyGroup)6 UnLimit91PornItem (com.dante.data.model.UnLimit91PornItem)4 TypeToken (com.google.gson.reflect.TypeToken)3 TestObserver (io.reactivex.observers.TestObserver)3 DynamicKey (io.rx_cache2.DynamicKey)3 BaseTest (io.rx_cache2.internal.common.BaseTest)3 Type (java.lang.reflect.Type)3 Reply (com.github.jh3nd3rs0n.jargyle.transport.socks5.Reply)2 Socks5Reply (com.github.jh3nd3rs0n.jargyle.transport.socks5.Socks5Reply)2 MeiZiTu (com.dante.data.model.MeiZiTu)1 Mm99 (com.dante.data.model.Mm99)1 PigAvVideo (com.dante.data.model.PigAvVideo)1