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();
}
});
}
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);
}
});
}
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());
}
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());
}
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));
}
Aggregations