Skip to content

Commit

Permalink
Did eclipse auto formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
grandecomplex committed Jan 7, 2011
1 parent 4a67afe commit cc23f45
Showing 1 changed file with 38 additions and 28 deletions.
66 changes: 38 additions & 28 deletions Android/ContactView/ContactView.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,38 +37,48 @@ public void onActivityResult(int reqCode, int resultCode, Intent data) {
String name = null;
String number = null;
switch (reqCode) {
case (PICK_CONTACT):
if (resultCode == Activity.RESULT_OK) {
Uri contactData = data.getData();
Cursor c = this.ctx.managedQuery(contactData, null, null, null, null);
if (c.moveToFirst()) {
String ContactID = c.getString(c.getColumnIndex(ContactsContract.Contacts._ID));
String hasPhone =c.getString(
c.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));

if(Integer.parseInt(hasPhone) == 1){
Cursor phoneCursor = this.ctx.managedQuery(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
null,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID+"='"+ContactID+"'",
null, null);
while(phoneCursor.moveToNext()){
number = phoneCursor.getString(phoneCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
}
}

name = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME));
JSONObject contactObject = new JSONObject();
try {
contactObject.put("name", name);
contactObject.put("phone", number);
} catch (JSONException e) {
e.printStackTrace();
case (PICK_CONTACT):
if (resultCode == Activity.RESULT_OK) {
Uri contactData = data.getData();
Cursor c = this.ctx.managedQuery(contactData, null, null, null,
null);
if (c.moveToFirst()) {
String ContactID = c.getString(c
.getColumnIndex(ContactsContract.Contacts._ID));
String hasPhone = c
.getString(c
.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));

if (Integer.parseInt(hasPhone) == 1) {
Cursor phoneCursor = this.ctx
.managedQuery(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
null,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID
+ "='" + ContactID + "'", null,
null);
while (phoneCursor.moveToNext()) {
number = phoneCursor
.getString(phoneCursor
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
}
}

this.success(new PluginResult(PluginResult.Status.OK, contactObject),this.callback);
name = c.getString(c
.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME));
JSONObject contactObject = new JSONObject();
try {
contactObject.put("name", name);
contactObject.put("phone", number);
} catch (JSONException e) {
e.printStackTrace();
}

this.success(new PluginResult(PluginResult.Status.OK,
contactObject), this.callback);
}
break;
}
break;
}
}
}

0 comments on commit cc23f45

Please sign in to comment.