本文整理汇总了Java中rx.exceptions.OnErrorThrowable.from方法的典型用法代码示例。如果您正苦于以下问题:Java OnErrorThrowable.from方法的具体用法?Java OnErrorThrowable.from怎么用?Java OnErrorThrowable.from使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rx.exceptions.OnErrorThrowable
的用法示例。
在下文中一共展示了OnErrorThrowable.from方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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();
}
}
}
示例7: asObfuscatedTrackWhenChecked
import rx.exceptions.OnErrorThrowable; //导入方法依赖的package包/类
private Func1<Track, Track> asObfuscatedTrackWhenChecked() {
return track -> {
LOG.info("asObfuscatedTrackWhenChecked()");
if (PreferencesHandler.isObfuscationEnabled(mContext)) {
LOG.info(String.format("obfuscation is enabled. Obfuscating track with %s " +
"measurements.", "" + track.getMeasurements().size()));
try {
return TrackUtils.getObfuscatedTrack(track);
} catch (NoMeasurementsException e) {
throw OnErrorThrowable.from(e);
}
} else {
LOG.info("obfuscation is disabled.");
return track;
}
};
}
示例8: fetchSource
import rx.exceptions.OnErrorThrowable; //导入方法依赖的package包/类
@Override
public List<Video> fetchSource(String embedPageUrl) {
String body = GeneralUtils.getWebPage(embedPageUrl);
String elementHtml = GeneralUtils.jwPlayerIsolate(body);
String notVideoUrl = elementHtml.substring(elementHtml.indexOf("file: \"") + 7, elementHtml.indexOf("\","));
OkHttpClient okHttpClient = new OkHttpClient();
Request request = new Request.Builder()
.get()
.addHeader("Referer", "http://www.animebam.net/embed/17302")
.addHeader("X-Requested-With", "ShockwaveFlash/18.0.0.209")
.url(notVideoUrl)
.build();
List<Video> videos = new ArrayList<>(1);
try {
String response = okHttpClient.newCall(request).execute().toString();
videos.add(new Video(null, response.substring(response.indexOf("url=") + 4, response.lastIndexOf(".mp4") + 4)));
}catch (IOException io) {
throw OnErrorThrowable.from(new Throwable("AnimeBam video retrieval failed.", io));
}
return videos;
}
示例9: getWebPage
import rx.exceptions.OnErrorThrowable; //导入方法依赖的package包/类
public static String getWebPage (final String url) {
OkHttpClient okHttpClient = new OkHttpClient();
Request request = new Request.Builder()
.url(url)
.build();
try {
Response response = okHttpClient.newCall(request).execute();
return response.body().string();
} catch (IOException e) {
throw OnErrorThrowable.from(new Throwable("Failed to connect.", e));
}
}
示例10: call
import rx.exceptions.OnErrorThrowable; //导入方法依赖的package包/类
@Override
public UpnpServiceServiceConnection call() {
try {
return bindService();
} catch (InterruptedException e) {
throw OnErrorThrowable.from(e);
}
}
示例11: getIsLoggedIn
import rx.exceptions.OnErrorThrowable; //导入方法依赖的package包/类
public <T> Func1<T, T> getIsLoggedIn() {
return new Func1<T, T>() {
@Override
public T call(T t) {
if (isLoggedIn())
return t;
else
throw OnErrorThrowable.from(new NotLoggedInException(context.getString(R
.string.trackviews_not_logged_in)));
}
};
}
示例12: checkTermsOfUseAcceptance
import rx.exceptions.OnErrorThrowable; //导入方法依赖的package包/类
private Func1<TermsOfUse, Observable<TermsOfUse>> checkTermsOfUseAcceptance(Activity activity) {
LOGGER.info("checkTermsOfUseAcceptance()");
return new Func1<TermsOfUse, Observable<TermsOfUse>>() {
@Override
public Observable<TermsOfUse> call(TermsOfUse termsOfUse) {
User user = mUserManager.getUser();
if (user == null) {
throw OnErrorThrowable.from(new NotLoggedInException(
mContext.getString(R.string.trackviews_not_logged_in)));
}
LOGGER.info(String.format("Retrieved terms of use for user [%s] with terms of" +
" use version [%s]", user.getUsername(), user.getTermsOfUseVersion()));
boolean hasAccepted = termsOfUse
.getIssuedDate().equals(user.getTermsOfUseVersion());
// If the user has accepted, then just return the generic type
if (hasAccepted) {
return Observable.just(termsOfUse);
}
// If the input activity is not null, then create an dialog observable.
else if (activity != null) {
return createTermsOfUseDialogObservable(user, termsOfUse, activity);
}
// Otherwise, throw an exception.
else {
throw OnErrorThrowable.from(new NotAcceptedTermsOfUseException(
"The user has not accepted the terms of use"));
}
}
};
}
示例13: searchFor
import rx.exceptions.OnErrorThrowable; //导入方法依赖的package包/类
@Override
public List<Anime> searchFor(String searchTerm){
if (searchTerm == null || searchTerm.trim().isEmpty()) {
throw OnErrorThrowable.from(new Throwable("Please enter a search term."));
}
String url = BASE_URL + GeneralUtils.encodeForUtf8(searchTerm);
String responseBody = GeneralUtils.getWebPage(url);
Element searchResultsBox = isolate(responseBody);
if (!hasSearchResults(searchResultsBox)) {
throw OnErrorThrowable.from(new Throwable("No search results."));
}
Elements searchResults = seperateResults(searchResultsBox);
return parseResults(searchResults);
}
示例14: searchFor
import rx.exceptions.OnErrorThrowable; //导入方法依赖的package包/类
@Override
public List<Anime> searchFor(String searchTerm) throws OnErrorThrowable {
if (searchTerm == null || searchTerm.trim().isEmpty()) {
throw OnErrorThrowable.from(new Throwable("Please enter a search term."));
}
String url = BASE_URL + GeneralUtils.encodeForUtf8(searchTerm);
String responseBody = GeneralUtils.getWebPage(url);
Element searchResultsBox = isolate(responseBody);
if (!hasSearchResults(searchResultsBox)) {
throw OnErrorThrowable.from(new Throwable("No search results."));
}
Elements searchResults = seperateResults(searchResultsBox);
return parseResults(searchResults);
}
示例15: getTitle
import rx.exceptions.OnErrorThrowable; //导入方法依赖的package包/类
public static String getTitle (String url) {
String body = GeneralUtils.getWebPage(url.replace("anime/", "api/v1/anime/"));
String title = null;
try {
JsonParser jsonParser = new JsonFactory().createParser(body);
while (!jsonParser.isClosed()) {
jsonParser.nextToken();
if (jsonParser.getCurrentName() != null && jsonParser.getCurrentName().equals("title")) {
title = jsonParser.nextTextValue();
jsonParser.close();
}
}
} catch (Exception e) {
throw OnErrorThrowable.from(new Throwable("Hummingbird retrieval failed.", e));
}
return title;
}