Java Code Examples for com.socks.jiandan.model.Video#setImgUrl()

The following examples show how to use com.socks.jiandan.model.Video#setImgUrl() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Request4Video.java    From JianDan_OkHttpWithVolley with Apache License 2.0 4 votes vote down vote up
@Override
protected Response<ArrayList<Video>> parseNetworkResponse(NetworkResponse response) {

    try {
        String jsonStr = new String(response.data, HttpHeaderParser.parseCharset(response.headers));
        JSONObject jsonObject = new JSONObject(jsonStr);

        if ("ok".equals(jsonObject.optString("status"))) {

            JSONArray commentsArray = jsonObject.optJSONArray("comments");
            ArrayList<Video> videos = new ArrayList<>();

            for (int i = 0; i < commentsArray.length(); i++) {

                JSONObject commentObject = commentsArray.getJSONObject(i);
                JSONObject videoObject = commentObject.optJSONArray("videos").optJSONObject(0);

                if (videoObject != null) {
                    Video video = new Video();
                    video.setTitle(videoObject.optString("title"));
                    String videoSource = videoObject.optString("video_source");
                    video.setComment_ID(commentObject.optString("comment_ID"));
                    video.setVote_positive(commentObject.optString("vote_positive"));
                    video.setVote_negative(commentObject.optString("vote_negative"));
                    video.setVideo_source(videoSource);

                    if (videoSource.equals("youku")) {
                        video.setUrl(videoObject.optString("link"));
                        video.setDesc(videoObject.optString("description"));
                        video.setImgUrl(videoObject.optString("thumbnail"));
                        video.setImgUrl4Big(videoObject.optString("thumbnail_v2"));
                    } else if (videoSource.equals("56")) {
                        video.setUrl(videoObject.optString("url"));
                        video.setDesc(videoObject.optString("desc"));
                        video.setImgUrl4Big(videoObject.optString("img"));
                        video.setImgUrl(videoObject.optString("mimg"));
                    } else if (videoSource.equals("tudou")) {
                        video.setUrl(videoObject.optString("playUrl"));
                        video.setImgUrl(videoObject.optString("picUrl"));
                        video.setImgUrl4Big(videoObject.optString("picUrl"));
                        video.setDesc(videoObject.optString("description"));
                    }

                    videos.add(video);
                }
            }

            return Response.success(videos, HttpHeaderParser.parseCacheHeaders(response));
        } else {
            return Response.success(new ArrayList<Video>(), HttpHeaderParser.parseCacheHeaders(response));
        }
    } catch (Exception e) {
        e.printStackTrace();
        return Response.error(new ParseError(e));
    }
}
 
Example 2
Source File: Request4Video.java    From JianDan with Apache License 2.0 4 votes vote down vote up
@Override
protected Response<ArrayList<Video>> parseNetworkResponse(NetworkResponse response) {

    try {
        String jsonStr = new String(response.data, HttpHeaderParser.parseCharset(response.headers));
        JSONObject jsonObject = new JSONObject(jsonStr);

        if ("ok".equals(jsonObject.optString("status"))) {

            JSONArray commentsArray = jsonObject.optJSONArray("comments");
            ArrayList<Video> videos = new ArrayList<>();

            for (int i = 0; i < commentsArray.length(); i++) {

                JSONObject commentObject = commentsArray.getJSONObject(i);
                JSONObject videoObject = commentObject.optJSONArray("videos").optJSONObject(0);

                if (videoObject != null) {
                    Video video = new Video();
                    video.setTitle(videoObject.optString("title"));
                    String videoSource = videoObject.optString("video_source");
                    video.setComment_ID(commentObject.optString("comment_ID"));
                    video.setVote_positive(commentObject.optString("vote_positive"));
                    video.setVote_negative(commentObject.optString("vote_negative"));
                    video.setVideo_source(videoSource);

                    if (videoSource.equals("youku")) {
                        video.setUrl(videoObject.optString("link"));
                        video.setDesc(videoObject.optString("description"));
                        video.setImgUrl(videoObject.optString("thumbnail"));
                        video.setImgUrl4Big(videoObject.optString("thumbnail_v2"));
                    } else if (videoSource.equals("56")) {
                        video.setUrl(videoObject.optString("url"));
                        video.setDesc(videoObject.optString("desc"));
                        video.setImgUrl4Big(videoObject.optString("img"));
                        video.setImgUrl(videoObject.optString("mimg"));
                    } else if (videoSource.equals("tudou")) {
                        video.setUrl(videoObject.optString("playUrl"));
                        video.setImgUrl(videoObject.optString("picUrl"));
                        video.setImgUrl4Big(videoObject.optString("picUrl"));
                        video.setDesc(videoObject.optString("description"));
                    }

                    videos.add(video);
                }
            }

            return Response.success(videos, HttpHeaderParser.parseCacheHeaders(response));
        } else {
            return Response.success(new ArrayList<Video>(), HttpHeaderParser.parseCacheHeaders(response));
        }
    } catch (Exception e) {
        e.printStackTrace();
        return Response.error(new ParseError(e));
    }
}
 
Example 3
Source File: VideoParser.java    From JianDanRxJava with Apache License 2.0 4 votes vote down vote up
@Nullable
public ArrayList<Video> parse(Response response) {

    try {
        String jsonStr = response.body().string();
        JSONObject jsonObject = new JSONObject(jsonStr);

        if ("ok".equals(jsonObject.optString("status"))) {

            JSONArray commentsArray = jsonObject.optJSONArray("comments");
            ArrayList<Video> videos = new ArrayList<>();

            for (int i = 0; i < commentsArray.length(); i++) {

                JSONObject commentObject = commentsArray.getJSONObject(i);
                JSONObject videoObject = commentObject.optJSONArray("videos").optJSONObject(0);

                if (videoObject != null) {
                    Video video = new Video();
                    video.setTitle(videoObject.optString("title"));
                    String videoSource = videoObject.optString("video_source");
                    video.setComment_ID(commentObject.optString("comment_ID"));
                    video.setVote_positive(commentObject.optString("vote_positive"));
                    video.setVote_negative(commentObject.optString("vote_negative"));
                    video.setVideo_source(videoSource);

                    if (videoSource.equals("youku")) {
                        video.setUrl(videoObject.optString("link"));
                        video.setDesc(videoObject.optString("description"));
                        video.setImgUrl(videoObject.optString("thumbnail"));
                        video.setImgUrl4Big(videoObject.optString("thumbnail_v2"));
                    } else if (videoSource.equals("56")) {
                        video.setUrl(videoObject.optString("url"));
                        video.setDesc(videoObject.optString("desc"));
                        video.setImgUrl4Big(videoObject.optString("img"));
                        video.setImgUrl(videoObject.optString("mimg"));
                    } else if (videoSource.equals("tudou")) {
                        video.setUrl(videoObject.optString("playUrl"));
                        video.setImgUrl(videoObject.optString("picUrl"));
                        video.setImgUrl4Big(videoObject.optString("picUrl"));
                        video.setDesc(videoObject.optString("description"));
                    }

                    videos.add(video);
                }
            }

            return videos;
        } else {
            return new ArrayList<>();
        }
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
 
Example 4
Source File: VideoParser.java    From JianDan_OkHttp with Apache License 2.0 4 votes vote down vote up
@Nullable
public ArrayList<Video> parse(Response response) {

    code = wrapperCode(response.code());
    try {
        String jsonStr = response.body().string();
        JSONObject jsonObject = new JSONObject(jsonStr);

        if ("ok".equals(jsonObject.optString("status"))) {

            JSONArray commentsArray = jsonObject.optJSONArray("comments");
            ArrayList<Video> videos = new ArrayList<>();

            for (int i = 0; i < commentsArray.length(); i++) {

                JSONObject commentObject = commentsArray.getJSONObject(i);
                JSONObject videoObject = commentObject.optJSONArray("videos").optJSONObject(0);

                if (videoObject != null) {
                    Video video = new Video();
                    video.setTitle(videoObject.optString("title"));
                    String videoSource = videoObject.optString("video_source");
                    video.setComment_ID(commentObject.optString("comment_ID"));
                    video.setVote_positive(commentObject.optString("vote_positive"));
                    video.setVote_negative(commentObject.optString("vote_negative"));
                    video.setVideo_source(videoSource);

                    if (videoSource.equals("youku")) {
                        video.setUrl(videoObject.optString("link"));
                        video.setDesc(videoObject.optString("description"));
                        video.setImgUrl(videoObject.optString("thumbnail"));
                        video.setImgUrl4Big(videoObject.optString("thumbnail_v2"));
                    } else if (videoSource.equals("56")) {
                        video.setUrl(videoObject.optString("url"));
                        video.setDesc(videoObject.optString("desc"));
                        video.setImgUrl4Big(videoObject.optString("img"));
                        video.setImgUrl(videoObject.optString("mimg"));
                    } else if (videoSource.equals("tudou")) {
                        video.setUrl(videoObject.optString("playUrl"));
                        video.setImgUrl(videoObject.optString("picUrl"));
                        video.setImgUrl4Big(videoObject.optString("picUrl"));
                        video.setDesc(videoObject.optString("description"));
                    }

                    videos.add(video);
                }
            }

            return videos;
        } else {
            return new ArrayList<>();
        }
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
 
Example 5
Source File: Request4Video.java    From JianDan_OkHttp with Apache License 2.0 4 votes vote down vote up
@Override
protected Response<ArrayList<Video>> parseNetworkResponse(NetworkResponse response) {

    try {
        String jsonStr = new String(response.data, HttpHeaderParser.parseCharset(response.headers));
        JSONObject jsonObject = new JSONObject(jsonStr);

        if ("ok".equals(jsonObject.optString("status"))) {

            JSONArray commentsArray = jsonObject.optJSONArray("comments");
            ArrayList<Video> videos = new ArrayList<>();

            for (int i = 0; i < commentsArray.length(); i++) {

                JSONObject commentObject = commentsArray.getJSONObject(i);
                JSONObject videoObject = commentObject.optJSONArray("videos").optJSONObject(0);

                if (videoObject != null) {
                    Video video = new Video();
                    video.setTitle(videoObject.optString("title"));
                    String videoSource = videoObject.optString("video_source");
                    video.setComment_ID(commentObject.optString("comment_ID"));
                    video.setVote_positive(commentObject.optString("vote_positive"));
                    video.setVote_negative(commentObject.optString("vote_negative"));
                    video.setVideo_source(videoSource);

                    if (videoSource.equals("youku")) {
                        video.setUrl(videoObject.optString("link"));
                        video.setDesc(videoObject.optString("description"));
                        video.setImgUrl(videoObject.optString("thumbnail"));
                        video.setImgUrl4Big(videoObject.optString("thumbnail_v2"));
                    } else if (videoSource.equals("56")) {
                        video.setUrl(videoObject.optString("url"));
                        video.setDesc(videoObject.optString("desc"));
                        video.setImgUrl4Big(videoObject.optString("img"));
                        video.setImgUrl(videoObject.optString("mimg"));
                    } else if (videoSource.equals("tudou")) {
                        video.setUrl(videoObject.optString("playUrl"));
                        video.setImgUrl(videoObject.optString("picUrl"));
                        video.setImgUrl4Big(videoObject.optString("picUrl"));
                        video.setDesc(videoObject.optString("description"));
                    }

                    videos.add(video);
                }
            }

            return Response.success(videos, HttpHeaderParser.parseCacheHeaders(response));
        } else {
            return Response.success(new ArrayList<Video>(), HttpHeaderParser.parseCacheHeaders(response));
        }
    } catch (Exception e) {
        e.printStackTrace();
        return Response.error(new ParseError(e));
    }
}