Search in sources :

Example 6 with VideosResponse

use of com.zype.fire.api.Model.VideosResponse in project zype-firebuilder by zype.

the class ZypeApi method searchVideos.

public VideosResponse searchVideos(String query) {
    try {
        HashMap<String, String> params = new HashMap<>();
        params.put(APP_KEY, ZypeSettings.APP_KEY);
        params.put(PER_PAGE, String.valueOf(PER_PAGE_DEFAULT));
        params.put(QUERY, query);
        Response response = apiImpl.getVideos(1, params).execute();
        if (response.isSuccessful()) {
            return (VideosResponse) response.body();
        } else {
            return null;
        }
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
}
Also used : Response(retrofit2.Response) VideoFavoritesResponse(com.zype.fire.api.Model.VideoFavoritesResponse) ChannelResponse(com.zype.fire.api.Model.ChannelResponse) DevicePinResponse(com.zype.fire.api.Model.DevicePinResponse) VideosResponse(com.zype.fire.api.Model.VideosResponse) AppResponse(com.zype.fire.api.Model.AppResponse) VideoResponse(com.zype.fire.api.Model.VideoResponse) VideoEntitlementsResponse(com.zype.fire.api.Model.VideoEntitlementsResponse) PlaylistsResponse(com.zype.fire.api.Model.PlaylistsResponse) ProgramResponse(com.zype.fire.api.Model.ProgramResponse) AccessTokenResponse(com.zype.fire.api.Model.AccessTokenResponse) ZobjectContentResponse(com.zype.fire.api.Model.ZobjectContentResponse) PlanResponse(com.zype.fire.api.Model.PlanResponse) PlaylistResponse(com.zype.fire.api.Model.PlaylistResponse) AccessTokenInfoResponse(com.zype.fire.api.Model.AccessTokenInfoResponse) ZobjectTopPlaylistResponse(com.zype.fire.api.Model.ZobjectTopPlaylistResponse) ConsumerResponse(com.zype.fire.api.Model.ConsumerResponse) HashMap(java.util.HashMap) IOException(java.io.IOException) VideosResponse(com.zype.fire.api.Model.VideosResponse)

Example 7 with VideosResponse

use of com.zype.fire.api.Model.VideosResponse in project zype-firebuilder by zype.

the class ContentLoader method getPlaylistVideosFeedObservable.

public Observable<Pair> getPlaylistVideosFeedObservable(Object contentContainerAsObject) {
    ContentContainer contentContainer = (ContentContainer) contentContainerAsObject;
    int nextPage = contentContainer.getExtraValueAsInt(ExtraKeys.NEXT_PAGE);
    if (nextPage <= 0) {
        Log.e(TAG, "getPlaylistVideosFeedObservable(): incorrect page: " + nextPage);
        return Observable.just(Pair.create(contentContainerAsObject, ""));
    }
    VideosResponse response = ZypeDataDownloaderHelper.loadPlaylistVideos(contentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG), nextPage);
    if (response != null) {
        if (response.pagination.current == response.pagination.pages) {
            contentContainer.setExtraValue(ExtraKeys.NEXT_PAGE, -1);
        } else {
            contentContainer.setExtraValue(ExtraKeys.NEXT_PAGE, response.pagination.next);
        }
        Log.d(TAG, "getPlaylistVideosFeedObservable(): size=" + response.videoData.size());
        GsonBuilder builder = new GsonBuilder();
        Gson gson = builder.create();
        String feed = gson.toJson(response.videoData);
        return Observable.just(Pair.create(contentContainerAsObject, feed));
    } else {
        Log.e(TAG, "getPlaylistVideosFeedObservable(): no videos found");
        return Observable.just(Pair.create(contentContainerAsObject, ""));
    }
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) ContentContainer(com.amazon.android.model.content.ContentContainer) Gson(com.google.gson.Gson) VideosResponse(com.zype.fire.api.Model.VideosResponse)

Aggregations

VideosResponse (com.zype.fire.api.Model.VideosResponse)7 Gson (com.google.gson.Gson)4 GsonBuilder (com.google.gson.GsonBuilder)4 VideoData (com.zype.fire.api.Model.VideoData)4 HashMap (java.util.HashMap)4 Response (retrofit2.Response)4 Context (android.content.Context)2 TextUtils (android.text.TextUtils)2 Log (android.util.Log)2 Content (com.amazon.android.model.content.Content)2 ContentContainer (com.amazon.android.model.content.ContentContainer)2 ZypeContentTranslator (com.amazon.android.model.translators.ZypeContentTranslator)2 Recipe (com.amazon.android.recipe.Recipe)2 DynamicParser (com.amazon.dynamicparser.DynamicParser)2 AccessTokenInfoResponse (com.zype.fire.api.Model.AccessTokenInfoResponse)2 AccessTokenResponse (com.zype.fire.api.Model.AccessTokenResponse)2 AppResponse (com.zype.fire.api.Model.AppResponse)2 ChannelResponse (com.zype.fire.api.Model.ChannelResponse)2 ConsumerResponse (com.zype.fire.api.Model.ConsumerResponse)2 DevicePinResponse (com.zype.fire.api.Model.DevicePinResponse)2