Skip to content

Commit

Permalink
1239
Browse files Browse the repository at this point in the history
  • Loading branch information
kavithaRajagopalan committed Feb 9, 2013
1 parent 0efcb36 commit 41bb557
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@ public void setPhoto(Child child) throws IOException, JSONException {

}

public void getPhotoFromServer(Child child, PhotoCaptureHelper photoCaptureHelper, String currentPhotoKey) throws IOException {
HttpResponse httpResponse = getPhoto(child);
public void getPhotoFromServer(Child child, PhotoCaptureHelper photoCaptureHelper, String fileName) throws IOException {
HttpResponse httpResponse = getPhoto(child, fileName);
Bitmap bitmap = BitmapFactory.decodeStream(httpResponse.getEntity().getContent());
savePhoto(bitmap, photoCaptureHelper, currentPhotoKey);
savePhoto(bitmap, photoCaptureHelper, fileName);
}


Expand Down Expand Up @@ -230,9 +230,9 @@ public void savePhoto(Bitmap bitmap, PhotoCaptureHelper photoCaptureHelper, Stri
}
}

public HttpResponse getPhoto(Child child) throws IOException {
public HttpResponse getPhoto(Child child, String fileName) throws IOException {
return fluentRequest
.path(String.format("/children/%s/photo/%s", child.optString("_id"), child.optString("current_photo_key")))
.path(String.format("/children/%s/photo/%s", child.optString("_id"), fileName))
.context(context)
.get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ private void addPhotoToPhotoKeys(String fileName) throws JSONException {
} else {
child.getJSONArray(PHOTO_KEYS).put(fileName);
}
child.put(formField.getId(), fileName);
}

protected String createCaptureFileName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public void shouldFetchPrimaryPhotoFromServer() throws JSONException, IOExceptio
Child child = new Child("id1", "user1", "{ '_id' : '1234abcd' ,'current_photo_key' : 'image_file_name'}");
getFakeHttpLayer().setDefaultHttpResponse(200, "image stream");

new ChildService(mockContext(), repository, mockFluentRequest).getPhoto(child);
new ChildService(mockContext(), repository, mockFluentRequest).getPhoto(child, "image_file_name");

verify(mockFluentRequest).path("/children/1234abcd/photo/image_file_name");
}
Expand Down

0 comments on commit 41bb557

Please sign in to comment.