本文整理汇总了Java中rx.exceptions.OnErrorThrowable类的典型用法代码示例。如果您正苦于以下问题:Java OnErrorThrowable类的具体用法?Java OnErrorThrowable怎么用?Java OnErrorThrowable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OnErrorThrowable类属于rx.exceptions包,在下文中一共展示了OnErrorThrowable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onNext
import rx.exceptions.OnErrorThrowable; //导入依赖的package包/类
public void onNext(T t) {
if (!this.done) {
if (!this.caughtUp) {
boolean stillReplay = false;
synchronized (this) {
if (!this.caughtUp) {
this.queue.offer(this.nl.next(t));
stillReplay = true;
}
}
if (stillReplay) {
replay();
return;
}
}
Subscriber<? super T> s = (Subscriber) this.subscriber.get();
try {
s.onNext(t);
} catch (Throwable ex) {
Exceptions.throwIfFatal(ex);
s.onError(OnErrorThrowable.addValueAsLastCause(ex, t));
}
}
}
示例2: fetchSource
import rx.exceptions.OnErrorThrowable; //导入依赖的package包/类
@Override
public List<Video> fetchSource(String embedPageUrl) {
String body = GeneralUtils.getWebPage(embedPageUrl);
Element playerScript = Jsoup.parse(body).select("div#player_code > script").first();
if (playerScript == null) {
throw OnErrorThrowable.from(new Throwable("MP4Upload video retrieval failed."));
}
String elementHtml = playerScript.html();
List<Video> videos = new ArrayList<>(1);
videos.add(new Video(null, elementHtml.substring(elementHtml.indexOf("'file': ") + 9, elementHtml.indexOf(".mp4'") + 4)));
return videos;
}
示例3: fetchSource
import rx.exceptions.OnErrorThrowable; //导入依赖的package包/类
@Override
public List<Video> fetchSource(String embedPageUrl) throws OnErrorThrowable {
String body = GeneralUtils.getWebPage(embedPageUrl);
String elementHtml;
try {
elementHtml = Jsoup.parse(body).select("div#ret").first().nextElementSibling().html();
} catch (Exception e) {
throw OnErrorThrowable.from(new Throwable("Engine video retrieval failed.", e));
}
List<Video> videos = new ArrayList<>(1);
videos.add(new Video(null, elementHtml.substring(18, elementHtml.indexOf("';"))));
return videos;
}
示例4: fetchAnime
import rx.exceptions.OnErrorThrowable; //导入依赖的package包/类
@Override
public Anime fetchAnime(String url) throws OnErrorThrowable{
String body = GeneralUtils.getWebPage(url);
animeBox = isolate(body);
if (!hasAnime(animeBox)) {
throw OnErrorThrowable.from(new Throwable("Failed to retrieve anime."));
}
Anime anime = new Anime()
.setProviderType(Anime.ANIME_RUSH)
.setUrl(url);
animeBox = animeBox.select("div.amin_box2").first();
anime.setTitle(parseForTitle());
animeBox = animeBox.select("div.desc_box_mid").first();
anime.setImageUrl(parseForImageUrl());
anime = parseForInformation(anime);
anime.setEpisodes(parseForEpisodes());
return anime;
}
示例5: fetchVideo
import rx.exceptions.OnErrorThrowable; //导入依赖的package包/类
@Override
public Source fetchVideo(Source source) throws OnErrorThrowable {
String pageBody = GeneralUtils.getWebPage(source.getPageUrl());
Element videoBox = isolate(pageBody)
.select("div.player-area")
.first();
source.setEmbedUrl(parseForEmbedUrl(videoBox));
if (source.getEmbedUrl().isEmpty()) {
throw OnErrorThrowable.from(new Throwable("Video removed."));
}
source.setVideos(source.getSourceProvider().fetchSource(source.getEmbedUrl()));
if (source.getVideos() == null) {
throw OnErrorThrowable.from(new Throwable("Unsupported source."));
}
if (source.getVideos().isEmpty()) {
throw OnErrorThrowable.from(new Throwable("Video retrieval failed."));
}
return source;
}
示例6: fetchAnime
import rx.exceptions.OnErrorThrowable; //导入依赖的package包/类
@Override
public Anime fetchAnime(String url) throws OnErrorThrowable {
String body = GeneralUtils.getWebPage(url);
Element animeBox = isolate(body);
Elements infoAndEpisodes = animeBox.select("tr > td > div.content");
if (!hasAnime(infoAndEpisodes)) {
throw OnErrorThrowable.from(new Throwable("Failed to retrieve anime."));
}
Anime anime = new Anime()
.setProviderType(Anime.ANIME_RAM)
.setUrl(url)
.setImageUrl(parseForImageUrl(animeBox));
anime = parseForInfo(infoAndEpisodes, anime);
anime.setEpisodes(parseForEpisodes(infoAndEpisodes));
return anime;
}
示例7: parseForSources
import rx.exceptions.OnErrorThrowable; //导入依赖的package包/类
private List<Source> parseForSources (Element sourcesBox) throws OnErrorThrowable{
Elements sourceElements = sourcesBox.select("li > a[href]");
List<Source> sources = new ArrayList<>(sourceElements.size());
for (Element sourceElement : sourceElements) {
String title = sourceElement.text();
SourceProvider sourceProvider = determineSourceProvider(title.toLowerCase());
if (sourceProvider != null) {
sources.add(new Source()
.setPageUrl(sourceElement.attr("href"))
.setTitle(title)
.setSourceProvider(sourceProvider)
);
}
}
return sources;
}
示例8: onNext
import rx.exceptions.OnErrorThrowable; //导入依赖的package包/类
@Override
public void onNext(T t) {
try {
final Object key = groupedKey(keySelector.call(t));
GroupState<K, T> group = groups.get(key);
if (group == null) {
// this group doesn't exist
if (child.isUnsubscribed()) {
// we have been unsubscribed on the outer so won't send any more groups
return;
}
group = createNewGroup(key);
}
if (group != null) {
emitItem(group, nl.next(t));
}
} catch (Throwable e) {
onError(OnErrorThrowable.addValueAsLastCause(e, t));
}
}
示例9: drainAll
import rx.exceptions.OnErrorThrowable; //导入依赖的package包/类
private int drainAll() {
int emitted = 0;
// drain it all
Object o;
while ((o = q.poll()) != null) {
if (q.isCompleted(o)) {
parentSubscriber.completeInner(this);
} else {
try {
if (!q.accept(o, parentSubscriber.actual)) {
emitted++;
}
} catch (Throwable e) {
// special error handling due to complexity of merge
onError(OnErrorThrowable.addValueAsLastCause(e, o));
}
}
}
return emitted;
}
示例10: createArtistNetworkRequest
import rx.exceptions.OnErrorThrowable; //导入依赖的package包/类
private Observable<Bitmap> createArtistNetworkRequest(final ArtInfo artInfo) {
return mLastFM.getArtistObservable(artInfo.artistName)
.map(new Func1<Artist, String>() {
@Override
public String call(Artist artist) {
String url = LastFM.GET_BEST_IMAGE.call(artist);
if (!TextUtils.isEmpty(url)) {
return url;
}
Timber.v("ArtistApiRequest: No image urls for %s", artist.getName());
throw OnErrorThrowable.from(new Exception("No artwork found for " +
artist.getName()));
}
}).flatMap(new Func1<String, Observable<Bitmap>>() {
@Override
public Observable<Bitmap> call(String s) {
return createImageObservable(mangleImageUrl(s), artInfo);
}
});
}
示例11: getAnonymousUser
import rx.exceptions.OnErrorThrowable; //导入依赖的package包/类
public static Observable<BackendUser> getAnonymousUser(Context context){
final String id = UserUtils.getDeviceIdUnique(context);
return BackendUser.logInInBackground(id,id).onErrorFlatMap(new Func1<OnErrorThrowable, Observable<? extends BackendUser>>() {
@Override
public Observable<? extends BackendUser> call(OnErrorThrowable onErrorThrowable) {
return BackendUser.signUpInBackground(id,id,id);
}
}).map(new Func1<BackendUser, BackendUser>() {
@Override
public BackendUser call(BackendUser user) {
user.put(ANONYMOUS_KEY,true);
user.saveASync();
return user;
}
});
}
示例12: getResponse
import rx.exceptions.OnErrorThrowable; //导入依赖的package包/类
public static String getResponse(HttpClientRequest<ByteBuf> request, HttpClient<ByteBuf, ByteBuf> client) {
return client.submit(request).flatMap(new Func1<HttpClientResponse<ByteBuf>, Observable<String>>() {
@Override
public Observable<String> call(HttpClientResponse<ByteBuf> response) {
return response.getContent().map(new Func1<ByteBuf, String>() {
@Override
public String call(ByteBuf byteBuf) {
return byteBuf.toString(Charset.defaultCharset());
}
});
}
}).onErrorFlatMap(new Func1<OnErrorThrowable, Observable<String>>() {
@Override
public Observable<String> call(OnErrorThrowable onErrorThrowable) {
throw onErrorThrowable;
}
}).toBlocking().first();
}
示例13: getPhotoRaw
import rx.exceptions.OnErrorThrowable; //导入依赖的package包/类
public Observable<JSONObject> getPhotoRaw(GalleryEntry gallery, ImageEntry photo) {
return Observable.just(gallery)
.flatMap(galleryEntry -> {
String showKey = galleryEntry.getShowkey();
if (showKey == null || Strings.isEmpty(showKey)) {
return getShowkey(galleryEntry, photo);
}
else {
return Observable.just(showKey);
}
})
.flatMap(showKey -> {
JSONObject json = new JSONObject();
try {
json.put("gid", gallery.getGalleryId());
json.put("page", photo.getPage());
json.put("imgkey", photo.getToken());
json.put("showkey", showKey);
}
catch (JSONException e) {
throw OnErrorThrowable.from(e);
}
return callApi("showpage", json);
});
}
示例14: getGalleryList
import rx.exceptions.OnErrorThrowable; //导入依赖的package包/类
private Observable<List<GalleryEntry>> getGalleryList(JSONArray gidlist) throws ApiCallException {
return Observable.just(gidlist)
.flatMap(jsonArray -> {
if (jsonArray.length() == 0) {
return Observable.just(Lists.newArrayList());
}
JSONObject obj = new JSONObject();
try {
obj.put("gidlist", gidlist);
}
catch (JSONException e) {
throw OnErrorThrowable.from(e);
}
return callApi("gdata", obj).observeOn(Schedulers.computation()).map(this::getEntriesFromJson);
});
}
示例15: getBody
import rx.exceptions.OnErrorThrowable; //导入依赖的package包/类
private String getBody(Request request) {
Response response = null;
try {
response = client.newCall(request).execute();
if (this.sHeader == null) {
this.sHeader = getSHeader(response.headers());
if (sHeader != null) {
return reloadWithSHeader(request);
}
}
return response.body().string();
}
catch (IOException e) {
throw OnErrorThrowable.from(e);
}
finally {
if (response != null) {
response.body().close();
}
}
}