use of com.esoxjem.movieguide.Video in project MovieGuide by esoxjem.
the class MovieDetailsFragment method showTrailers.
@Override
public void showTrailers(List<Video> trailers) {
if (trailers.isEmpty()) {
label.setVisibility(View.GONE);
this.trailers.setVisibility(View.GONE);
horizontalScrollView.setVisibility(View.GONE);
} else {
label.setVisibility(View.VISIBLE);
this.trailers.setVisibility(View.VISIBLE);
horizontalScrollView.setVisibility(View.VISIBLE);
this.trailers.removeAllViews();
LayoutInflater inflater = getActivity().getLayoutInflater();
Picasso picasso = Picasso.with(getContext());
for (Video trailer : trailers) {
View thumbContainer = inflater.inflate(R.layout.video, this.trailers, false);
ImageView thumbView = ButterKnife.findById(thumbContainer, R.id.video_thumb);
thumbView.setTag(Video.getUrl(trailer));
thumbView.requestLayout();
thumbView.setOnClickListener(this);
picasso.load(Video.getThumbnailUrl(trailer)).resizeDimen(R.dimen.video_width, R.dimen.video_height).centerCrop().placeholder(R.color.colorPrimary).into(thumbView);
this.trailers.addView(thumbContainer);
}
}
}
use of com.esoxjem.movieguide.Video in project MovieGuide by esoxjem.
the class MovieDetailsParser method parseTrailers.
public static List<Video> parseTrailers(String body) throws JSONException {
ArrayList<Video> trailers = new ArrayList<>(4);
JSONObject response = new JSONObject(body);
if (!response.isNull(RESULTS)) {
JSONArray results = response.getJSONArray(RESULTS);
for (int i = 0; i < results.length(); i++) {
Video video = new Video();
JSONObject videoJson = results.getJSONObject(i);
if (!videoJson.isNull(ID)) {
video.setId(videoJson.getString(ID));
}
if (!videoJson.isNull(NAME)) {
video.setName(videoJson.getString(NAME));
}
if (!videoJson.isNull(SITE)) {
video.setSite(videoJson.getString(SITE));
}
if (!videoJson.isNull(KEY)) {
video.setVideoId(videoJson.getString(KEY));
}
if (!videoJson.isNull(SIZE)) {
video.setSize(videoJson.getInt(SIZE));
}
if (!videoJson.isNull(TYPE)) {
video.setType(videoJson.getString(TYPE));
}
trailers.add(video);
}
}
return trailers;
}
Aggregations