public static User fromJson(JSONObject json) throws JSONException { User user = new User(); user.setName(json.getString("user_name")); user.setBio(json.getString("bio")); user.setPhotoUrl(json.getString("photo_url")); user.setIsPrivate(json.getBoolean("is_private")); return user; }
public static NewVideo fromJson(JSONObject json) throws JSONException { NewVideo newVideo = new NewVideo(); if(json.has("shortcode")) { newVideo.setShortCode(json.getString("shortcode")); } if(json.has("status")) { newVideo.setStatus(AndroidStreamableUtil.toInt(json.getString("status"))); } return newVideo; }
public static VideoFile fromJson(JSONObject json) throws JSONException { VideoFile videoFile = new VideoFile(); if(json.has("url")) { videoFile.setUrl(AndroidStreamableUtil.fixUrl(json.getString("url"))); } if(json.has("width")) { videoFile.setWidth(json.getString("width")); } if(json.has("height")) { videoFile.setHeight(json.getString("height")); } return videoFile; }
public static Video fromJson(JSONObject json) throws JSONException { Video video = new Video(); if(json.has("title")) { video.setTitle(json.getString("title")); } if(json.has("url")) { video.setUrl(AndroidStreamableUtil.fixUrl(json.getString("url"))); } if(json.has("thumbnail_url")) { video.setThumbnailUrl(AndroidStreamableUtil.fixUrl(json.getString("thumbnail_url"))); } if(json.has("message")) { video.setMessage(json.getString("message")); } if(json.has("status")) { video.setStatus(AndroidStreamableUtil.toInt(json.getString("status"))); } Map<String, VideoFile> hash = new HashMap<>(); for(Iterator<String> i = json.getJSONObject("files").keys(); i.hasNext(); ){ String format = i.next(); JSONObject videoFileJson = json.getJSONObject("files").getJSONObject(format); VideoFile videoFile = VideoFile.fromJson(videoFileJson); hash.put(format, videoFile); } video.setFiles(hash); return video; }
@Override public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { try { JSONObject json = new JSONObject(new String(responseBody)); NewVideo newVideo = NewVideo.fromJson(json); callback.onSuccess(statusCode, newVideo); } catch (JSONException e){ callback.onFailure(statusCode, e); } }
@Override public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { try { JSONObject json = new JSONObject(new String(responseBody)); User user = User.fromJson(json); callback.onSuccess(statusCode, user); } catch (JSONException e){ callback.onFailure(statusCode, e); } } @Override
@Override public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { try { JSONObject json = new JSONObject(new String(responseBody)); Video newVideo = Video.fromJson(json); callback.onSuccess(statusCode, newVideo); } catch (JSONException e){ callback.onFailure(statusCode, e); } } @Override
@Override public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { try { JSONObject json = new JSONObject(new String(responseBody)); NewVideo newVideo = NewVideo.fromJson(json); callback.onSuccess(statusCode, newVideo); } catch (JSONException e){ callback.onFailure(statusCode, e); } }
@Override public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { try { JSONObject json = new JSONObject(new String(responseBody)); User user = User.fromJson(json); callback.onSuccess(statusCode, user); } catch (JSONException e){ callback.onFailure(statusCode, e); } } @Override