Skip to content

Commit

Permalink
[#1239] kavitha|yekkanti Refactored code
Browse files Browse the repository at this point in the history
  • Loading branch information
kishoreyekkanti committed Feb 11, 2013
1 parent 40d4f94 commit 84e8d29
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,14 @@ public Child apply(Map content) {
public void setPhoto(Child child) throws IOException, JSONException {
PhotoCaptureHelper photoCaptureHelper = new PhotoCaptureHelper(context);

JSONArray photoKeys = new JSONArray(child.optString("photo_keys"));
JSONArray photoKeys = child.optJSONArray("photo_keys");
if(photoKeys != null){
getPhotoFromServerIfNeeded(child, photoCaptureHelper, photoKeys);
}

}

private void getPhotoFromServerIfNeeded(Child child, PhotoCaptureHelper photoCaptureHelper, JSONArray photoKeys) throws JSONException, IOException {
for(int i = 0; i < photoKeys.length(); i++){
String photoKey = photoKeys.get(i).toString();
try {
Expand All @@ -192,7 +199,6 @@ public void setPhoto(Child child) throws IOException, JSONException {
getPhotoFromServer(child, photoCaptureHelper, photoKey);
}
}

}

public void getPhotoFromServer(Child child, PhotoCaptureHelper photoCaptureHelper, String fileName) throws IOException {
Expand Down

0 comments on commit 84e8d29

Please sign in to comment.