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