List of usage examples for android.content ContentValues getAsInteger
public Integer getAsInteger(String key)
From source file:org.anhonesteffort.flock.sync.addressbook.ContactFactory.java
protected static void addInstantMessaging(String path, VCard vCard, ContentValues imValues) throws InvalidComponentException { Integer type = imValues.getAsInteger(ContactsContract.CommonDataKinds.Im.TYPE); Integer protocol = imValues.getAsInteger(ContactsContract.CommonDataKinds.Im.PROTOCOL); String customProtocol = imValues.getAsString(ContactsContract.CommonDataKinds.Im.CUSTOM_PROTOCOL); String handle = imValues.getAsString(ContactsContract.CommonDataKinds.Im.DATA); if (type != null && protocol != null && handle != null) { Impp impp;//ww w .j a v a 2 s.co m switch (protocol) { case ContactsContract.CommonDataKinds.Im.PROTOCOL_AIM: impp = Impp.aim(handle); break; case ContactsContract.CommonDataKinds.Im.PROTOCOL_MSN: impp = Impp.msn(handle); break; case ContactsContract.CommonDataKinds.Im.PROTOCOL_YAHOO: impp = Impp.yahoo(handle); break; case ContactsContract.CommonDataKinds.Im.PROTOCOL_SKYPE: impp = Impp.skype(handle); break; case ContactsContract.CommonDataKinds.Im.PROTOCOL_ICQ: impp = Impp.icq(handle); break; case ContactsContract.CommonDataKinds.Im.PROTOCOL_QQ: impp = new Impp("qq", handle); break; case ContactsContract.CommonDataKinds.Im.PROTOCOL_GOOGLE_TALK: impp = new Impp("google-talk", handle); break; case ContactsContract.CommonDataKinds.Im.PROTOCOL_NETMEETING: impp = new Impp("netmeeting", handle); break; case ContactsContract.CommonDataKinds.Im.PROTOCOL_CUSTOM: impp = new Impp(customProtocol, handle); break; default: impp = Impp.xmpp(handle); break; } impp.addType(ImppType.PERSONAL); vCard.addImpp(impp); } else { Log.e(TAG, "im type, protocol, or handle is null, not adding anything"); throw new InvalidComponentException("im type, protocol, or handle is null", false, CardDavConstants.CARDDAV_NAMESPACE, path); } }
From source file:com.antew.redditinpictures.library.reddit.LoginResponse.java
@Override public void processHttpResponse(Context context) { ContentResolver resolver = context.getContentResolver(); // Delete old logins resolver.delete(RedditContract.Login.CONTENT_URI, null, null); RedditLoginResponse response = JsonDeserializer.deserialize(result.getJson(), RedditLoginResponse.class); if (response == null) { Ln.e("Error parsing Reddit login response"); return;//from ww w .j a v a 2 s.com } // The username isn't sent back with the login response, so we have it passed // through from the login request String username = BundleUtil.getString(result.getExtraData(), RedditContract.Login.USERNAME, null); if (response.getLoginResponse() != null && response.getLoginResponse().getData() != null) { response.getLoginResponse().getData().setUsername(username); } ContentValues loginValues = response.getContentValues(); Intent loginNotify = new Intent(Constants.Broadcast.BROADCAST_LOGIN_COMPLETE); loginNotify.putExtra(Constants.Extra.EXTRA_USERNAME, username); Integer loginSuccess = loginValues.getAsInteger(RedditContract.Login.SUCCESS); if (loginSuccess != null && loginSuccess == 1) { loginNotify.putExtra(Constants.Extra.EXTRA_SUCCESS, true); resolver.insert(RedditContract.Login.CONTENT_URI, loginValues); } else { loginNotify.putExtra(Constants.Extra.EXTRA_SUCCESS, false); loginNotify.putExtra(Constants.Extra.EXTRA_ERROR_MESSAGE, loginValues.getAsString(RedditContract.Login.ERROR_MESSAGE)); loginNotify.putExtra(Constants.Extra.EXTRA_USERNAME, username); } LocalBroadcastManager.getInstance(context).sendBroadcast(loginNotify); }
From source file:org.anhonesteffort.flock.sync.addressbook.ContactFactory.java
protected static void addPhoneNumber(String path, VCard vCard, ContentValues phoneNumberValues) throws InvalidComponentException { Integer type = phoneNumberValues.getAsInteger(ContactsContract.CommonDataKinds.Phone.TYPE); String label = phoneNumberValues.getAsString(ContactsContract.CommonDataKinds.Phone.LABEL); String number = phoneNumberValues.getAsString(ContactsContract.CommonDataKinds.Phone.NUMBER); Boolean isPrimary = phoneNumberValues.getAsBoolean(ContactsContract.CommonDataKinds.Phone.IS_PRIMARY); Boolean isSuperPrimary = phoneNumberValues .getAsBoolean(ContactsContract.CommonDataKinds.Phone.IS_SUPER_PRIMARY); if (type != null && number != null) { Telephone telephone = new Telephone(number); switch (type) { case ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE: telephone.addType(TelephoneType.CELL); break; case ContactsContract.CommonDataKinds.Phone.TYPE_WORK: telephone.addType(TelephoneType.WORK); break; case ContactsContract.CommonDataKinds.Phone.TYPE_HOME: telephone.addType(TelephoneType.HOME); break; case ContactsContract.CommonDataKinds.Phone.TYPE_FAX_WORK: telephone.addType(TelephoneType.FAX); telephone.addType(TelephoneType.WORK); break; case ContactsContract.CommonDataKinds.Phone.TYPE_FAX_HOME: telephone.addType(TelephoneType.FAX); telephone.addType(TelephoneType.HOME); break; case ContactsContract.CommonDataKinds.Phone.TYPE_PAGER: telephone.addType(TelephoneType.PAGER); break; case ContactsContract.CommonDataKinds.Phone.TYPE_MAIN: telephone.addType(TelephoneType.PREF); break; default://from w ww . ja va 2 s . com if (label != null) telephone.addType(TelephoneType.get(labelToPropertyName(label))); } if (isPrimary != null && isPrimary) telephone.addType(TelephoneType.PREF); else if (isSuperPrimary != null && isSuperPrimary) telephone.addType(TelephoneType.PREF); vCard.addTelephoneNumber(telephone); } else { Log.e(TAG, "phone type or number is null, not adding anything"); throw new InvalidComponentException("phone type or number is null", false, CardDavConstants.CARDDAV_NAMESPACE, path); } }
From source file:org.anhonesteffort.flock.sync.addressbook.ContactFactory.java
protected static void addPostalAddress(String path, VCard vCard, ContentValues addressValues) throws InvalidComponentException { Integer addressType = addressValues.getAsInteger(ContactsContract.CommonDataKinds.StructuredPostal.TYPE); String formattedAddress = addressValues .getAsString(ContactsContract.CommonDataKinds.StructuredPostal.FORMATTED_ADDRESS); String label = addressValues.getAsString(ContactsContract.CommonDataKinds.StructuredPostal.LABEL); String street = addressValues.getAsString(ContactsContract.CommonDataKinds.StructuredPostal.STREET); String poBox = addressValues.getAsString(ContactsContract.CommonDataKinds.StructuredPostal.POBOX); String neighborhood = addressValues .getAsString(ContactsContract.CommonDataKinds.StructuredPostal.NEIGHBORHOOD); String city = addressValues.getAsString(ContactsContract.CommonDataKinds.StructuredPostal.CITY); String region = addressValues.getAsString(ContactsContract.CommonDataKinds.StructuredPostal.REGION); String postcode = addressValues.getAsString(ContactsContract.CommonDataKinds.StructuredPostal.POBOX); String country = addressValues.getAsString(ContactsContract.CommonDataKinds.StructuredPostal.COUNTRY); if (addressType != null && formattedAddress != null) { Address address = new Address(); address.setLabel(formattedAddress); switch (addressType) { case ContactsContract.CommonDataKinds.StructuredPostal.TYPE_HOME: address.addType(AddressType.HOME); break; case ContactsContract.CommonDataKinds.StructuredPostal.TYPE_WORK: address.addType(AddressType.WORK); break; case ContactsContract.CommonDataKinds.StructuredPostal.TYPE_CUSTOM: if (label != null) AddressType.get(label);//from w w w .j a va 2s. c o m break; } if (street != null) address.setStreetAddress(street); if (poBox != null) address.setPoBox(poBox); if (neighborhood != null) address.setExtendedAddress(neighborhood); if (city != null) address.setLocality(city); if (region != null) address.setRegion(region); if (postcode != null) address.setPostalCode(postcode); if (country != null) address.setCountry(country); vCard.addAddress(address); } else { Log.e(TAG, "im address type or formatted address is null, not adding anything"); throw new InvalidComponentException("im address type or formatted address is null", false, CardDavConstants.CARDDAV_NAMESPACE, path); } }
From source file:at.bitfire.ical4android.AndroidTaskList.java
protected void populate(ContentValues values) { syncId = values.getAsString(TaskLists._SYNC_ID); name = values.getAsString(TaskLists.LIST_NAME); if (values.containsKey(TaskLists.LIST_COLOR)) color = values.getAsInteger(TaskLists.LIST_COLOR); if (values.containsKey(TaskLists.SYNC_ENABLED)) isSynced = values.getAsInteger(TaskLists.SYNC_ENABLED) != 0; if (values.containsKey(TaskLists.VISIBLE)) isVisible = values.getAsInteger(TaskLists.VISIBLE) != 0; }
From source file:at.bitfire.ical4android.AndroidCalendar.java
protected void populate(ContentValues info) { name = info.getAsString(Calendars.NAME); displayName = info.getAsString(Calendars.CALENDAR_DISPLAY_NAME); if (info.containsKey(Calendars.CALENDAR_COLOR)) color = info.getAsInteger(Calendars.CALENDAR_COLOR); isSynced = info.getAsInteger(Calendars.SYNC_EVENTS) != 0; isVisible = info.getAsInteger(Calendars.VISIBLE) != 0; }
From source file:com.partypoker.poker.engagement.reach.EngagementReachContent.java
/** * Parse a campaign./* ww w .jav a 2 s.co m*/ * @param campaignId already parsed campaign id. * @param values content data. * @throws JSONException if payload parsing failure. */ EngagementReachContent(com.microsoft.azure.engagement.reach.CampaignId campaignId, ContentValues values) throws JSONException { /* Parse base fields */ mCampaignId = campaignId; mDlc = values.getAsInteger(DLC); mDlcId = values.getAsString(DLC_ID); mCategory = values.getAsString(CATEGORY); Long expiry = values.getAsLong(TTL); if (expiry != null) { expiry *= 1000L; if (parseBoolean(values, USER_TIME_ZONE)) expiry -= TimeZone.getDefault().getOffset(expiry); } mExpiry = expiry; if (values.containsKey(PAYLOAD)) setPayload(new JSONObject(values.getAsString(PAYLOAD))); }
From source file:de.uni_koblenz_landau.apow.db.SyncDBHelper.java
/** * Updates patient table with given values. * @param values Values//from ww w .j a v a 2s . c o m * @return Affected rows */ private int updatePatientTable(ContentValues values) { // check if uuid exists in table int affectedRows = 0; int id = values.getAsInteger("patient_id"); int dirty = isPatientDirty(id); // row not in table if (dirty == -1) { // insert mDatabase.insert("patient", null, values); affectedRows++; } else if (dirty == 0) { // replace mDatabase.update("patient", values, "patient_id = " + id, null); affectedRows++; } else if (dirty == 1) { // replace mDatabase.update("patient", values, "patient_id = " + id, null); setPatientDirty(id, false); } return affectedRows; }
From source file:org.anhonesteffort.flock.sync.calendar.EventFactory.java
protected static void addAttendee(String path, Calendar component, ContentValues attendeeValues) throws InvalidComponentException { VEvent vEvent = (VEvent) component.getComponent(VEvent.VEVENT); if (vEvent == null) { Log.e(TAG, "unable to add attendee to component with no VEVENT"); throw new InvalidComponentException("unable to add attendee to component with no VEVENT", false, CalDavConstants.CALDAV_NAMESPACE, path); }//from w w w . jav a 2 s. c o m String email = attendeeValues.getAsString(CalendarContract.Attendees.ATTENDEE_EMAIL); String name = attendeeValues.getAsString(CalendarContract.Attendees.ATTENDEE_NAME); Integer type = attendeeValues.getAsInteger(CalendarContract.Attendees.ATTENDEE_TYPE); Integer relationship = attendeeValues.getAsInteger(CalendarContract.Attendees.ATTENDEE_RELATIONSHIP); Integer status = attendeeValues.getAsInteger(CalendarContract.Attendees.ATTENDEE_STATUS); if (StringUtils.isEmpty(email)) { Log.e(TAG, "attendee email is null or empty"); throw new InvalidComponentException("attendee email is null or empty", false, CalDavConstants.CALDAV_NAMESPACE, path); } try { Attendee attendee = new Attendee(new URI("mailto", email, null)); ParameterList attendeeParams = attendee.getParameters(); attendeeParams.add(CuType.INDIVIDUAL); if (StringUtils.isNotEmpty(name)) attendeeParams.add(new Cn(name)); if (relationship != null && relationship == CalendarContract.Attendees.RELATIONSHIP_ORGANIZER) attendeeParams.add(Role.CHAIR); else if (type != null && type == CalendarContract.Attendees.TYPE_REQUIRED) attendeeParams.add(Role.REQ_PARTICIPANT); else attendeeParams.add(Role.OPT_PARTICIPANT); if (status != null) { switch (status) { case CalendarContract.Attendees.ATTENDEE_STATUS_INVITED: attendeeParams.add(PartStat.NEEDS_ACTION); break; case CalendarContract.Attendees.ATTENDEE_STATUS_ACCEPTED: attendeeParams.add(PartStat.ACCEPTED); break; case CalendarContract.Attendees.ATTENDEE_STATUS_DECLINED: attendeeParams.add(PartStat.DECLINED); break; case CalendarContract.Attendees.ATTENDEE_STATUS_TENTATIVE: attendeeParams.add(PartStat.TENTATIVE); break; } } vEvent.getProperties().add(attendee); } catch (URISyntaxException e) { Log.e(TAG, "caught exception while adding email to attendee", e); throw new InvalidComponentException("caught exception while adding email to attendee", false, CalDavConstants.CALDAV_NAMESPACE, path, e); } }
From source file:com.csipsimple.utils.Columns.java
public JSONObject contentValueToJSON(ContentValues cv) { JSONObject json = new JSONObject(); try {// ww w . j a va 2 s .co m for (int i = 0; i < names.length; i++) { if (!cv.containsKey(names[i])) { continue; } switch (types[i]) { case STRING: json.put(names[i], cv.getAsString(names[i])); break; case INT: json.put(names[i], cv.getAsInteger(names[i])); break; case LONG: json.put(names[i], cv.getAsLong(names[i])); break; case FLOAT: json.put(names[i], cv.getAsFloat(names[i])); break; case DOUBLE: json.put(names[i], cv.getAsDouble(names[i])); break; case BOOLEAN: json.put(names[i], cv.getAsBoolean(names[i])); break; } } } catch (JSONException e) { throw new RuntimeException(e); } return json; }