Merge pull request #32 from willshen/master

A couple cleanup and bug fix in the code base
This commit is contained in:
macdonst 2011-12-01 10:11:44 -08:00
commit 26408fabe4
3 changed files with 20 additions and 26 deletions

View File

@ -1054,7 +1054,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
if (organizations != null) {
for (int i=0; i<organizations.length(); i++) {
JSONObject org = (JSONObject)organizations.get(i);
String orgId = getJsonString(org, "id");;
String orgId = getJsonString(org, "id");
// This is a new organization so do a DB insert
if (orgId==null) {
ContentValues contentValues = new ContentValues();
@ -1094,7 +1094,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
if (ims != null) {
for (int i=0; i<ims.length(); i++) {
JSONObject im = (JSONObject)ims.get(i);
String imId = getJsonString(im, "id");;
String imId = getJsonString(im, "id");
// This is a new IM so do a DB insert
if (imId==null) {
ContentValues contentValues = new ContentValues();
@ -1150,7 +1150,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
if (websites != null) {
for (int i=0; i<websites.length(); i++) {
JSONObject website = (JSONObject)websites.get(i);
String websiteId = getJsonString(website, "id");;
String websiteId = getJsonString(website, "id");
// This is a new website so do a DB insert
if (websiteId==null) {
ContentValues contentValues = new ContentValues();
@ -1603,10 +1603,8 @@ public class ContactAccessorSdk5 extends ContactAccessor {
}
} catch (RemoteException e) {
Log.e(LOG_TAG, e.getMessage(), e);
newId = null;
} catch (OperationApplicationException e) {
Log.e(LOG_TAG, e.getMessage(), e);
newId = null;
}
return newId;
}

View File

@ -322,14 +322,13 @@ public class FileUtils extends Plugin {
* @param newName for the file directory to be called, if null use existing file name
* @param move if false do a copy, if true do a move
* @return a Entry object
* @throws FileExistsException
* @throws NoModificationAllowedException
* @throws IOException
* @throws InvalidModificationException
* @throws EncodingException
* @throws JSONException
*/
private JSONObject transferTo(String fileName, JSONObject newParent, String newName, boolean move) throws JSONException, FileExistsException, NoModificationAllowedException, IOException, InvalidModificationException, EncodingException {
private JSONObject transferTo(String fileName, JSONObject newParent, String newName, boolean move) throws JSONException, NoModificationAllowedException, IOException, InvalidModificationException, EncodingException {
// Check for invalid file name
if (newName != null && newName.contains(":")) {
throw new EncodingException("Bad file name");
@ -528,10 +527,9 @@ public class FileUtils extends Plugin {
* @return a DirectoryEntry object
* @throws JSONException
* @throws IOException
* @throws NoModificationAllowedException
* @throws InvalidModificationException
*/
private JSONObject moveDirectory(File srcDir, File destinationDir) throws JSONException, FileExistsException, NoModificationAllowedException, InvalidModificationException {
private JSONObject moveDirectory(File srcDir, File destinationDir) throws JSONException, InvalidModificationException {
// Renaming a file to an existing directory should fail
if (destinationDir.exists() && destinationDir.isFile()) {
throw new InvalidModificationException("Can't rename a file to a directory");

View File

@ -18,8 +18,8 @@
*/
package com.phonegap;
import java.io.EOFException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.http.HttpEntity;
@ -56,14 +56,13 @@ public class HttpHandler {
return entity;
}
private void writeToDisk(HttpEntity entity, String file) throws EOFException
private void writeToDisk(HttpEntity entity, String file) throws IllegalStateException, IOException
/**
* writes a HTTP entity to the specified filename and location on disk
*/
{
int i=0;
String FilePath="/sdcard/" + file;
try {
InputStream in = entity.getContent();
byte buff[] = new byte[1024];
FileOutputStream out=
@ -77,6 +76,5 @@ public class HttpHandler {
} while (true);
out.flush();
out.close();
} catch (Exception e) { e.printStackTrace(); }
}
}