当前位置: 首页>>代码示例>>Java>>正文


Java OnErrorThrowable.from方法代码示例

本文整理汇总了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;
}
 
开发者ID:gabriellmgomes,项目名称:akhyou,代码行数:18,代码来源:Mp4UploadSourceProvider.java

示例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;
}
 
开发者ID:gabriellmgomes,项目名称:akhyou,代码行数:18,代码来源:EngineSourceProvider.java

示例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;
}
 
开发者ID:gabriellmgomes,项目名称:akhyou,代码行数:27,代码来源:AnimeRushAnimeProvider.java

示例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;
}
 
开发者ID:gabriellmgomes,项目名称:akhyou,代码行数:27,代码来源:AnimeRushAnimeProvider.java

示例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;
}
 
开发者ID:gabriellmgomes,项目名称:akhyou,代码行数:24,代码来源:AnimeRamAnimeProvider.java

示例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();
		}
	}
}
 
开发者ID:Ecchilon,项目名称:SadPanda,代码行数:22,代码来源:DataLoader.java

示例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;
        }
    };
}
 
开发者ID:enviroCar,项目名称:enviroCar-app,代码行数:18,代码来源:TrackUploadHandler.java

示例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;
}
 
开发者ID:gabriellmgomes,项目名称:akhyou,代码行数:30,代码来源:AnimeBamSourceProvider.java

示例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));
    }
}
 
开发者ID:gabriellmgomes,项目名称:akhyou,代码行数:15,代码来源:GeneralUtils.java

示例10: call

import rx.exceptions.OnErrorThrowable; //导入方法依赖的package包/类
@Override
public UpnpServiceServiceConnection call() {
    try {
        return bindService();
    } catch (InterruptedException e) {
        throw OnErrorThrowable.from(e);
    }
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:9,代码来源:UpnpCDProvider.java

示例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)));
        }
    };
}
 
开发者ID:enviroCar,项目名称:enviroCar-app,代码行数:13,代码来源:UserHandler.java

示例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"));
            }
        }
    };
}
 
开发者ID:enviroCar,项目名称:enviroCar-app,代码行数:34,代码来源:TermsOfUseManager.java

示例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);
}
 
开发者ID:gabriellmgomes,项目名称:akhyou,代码行数:22,代码来源:AnimeRushSearchProvider.java

示例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);
}
 
开发者ID:gabriellmgomes,项目名称:akhyou,代码行数:22,代码来源:AnimeRamSearchProvider.java

示例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;
    }
 
开发者ID:gabriellmgomes,项目名称:akhyou,代码行数:27,代码来源:HummingbirdApi.java


注:本文中的rx.exceptions.OnErrorThrowable.from方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。