List of usage examples for android.content ContentValues getAsInteger
public Integer getAsInteger(String key)
From source file:com.granita.icloudcalsync.resource.LocalAddressBook.java
protected void populatePostalAddress(Contact c, ContentValues row) { Address address = new Address(); address.setLabel(row.getAsString(StructuredPostal.FORMATTED_ADDRESS)); switch (row.getAsInteger(StructuredPostal.TYPE)) { case StructuredPostal.TYPE_HOME: address.addType(AddressType.HOME); break;/*from w ww. j ava 2 s . co m*/ case StructuredPostal.TYPE_WORK: address.addType(AddressType.WORK); break; case StructuredPostal.TYPE_CUSTOM: String customType = row.getAsString(StructuredPostal.LABEL); if (StringUtils.isNotEmpty(customType)) address.addType(AddressType.get(labelToXName(customType))); break; } address.setStreetAddress(row.getAsString(StructuredPostal.STREET)); address.setPoBox(row.getAsString(StructuredPostal.POBOX)); address.setExtendedAddress(row.getAsString(StructuredPostal.NEIGHBORHOOD)); address.setLocality(row.getAsString(StructuredPostal.CITY)); address.setRegion(row.getAsString(StructuredPostal.REGION)); address.setPostalCode(row.getAsString(StructuredPostal.POSTCODE)); address.setCountry(row.getAsString(StructuredPostal.COUNTRY)); c.getAddresses().add(address); }
From source file:com.granita.icloudcalsync.resource.LocalAddressBook.java
protected void populateSipAddress(Contact c, ContentValues row) throws RemoteException { try {/*from w w w .j ava 2 s . c om*/ Impp impp = new Impp("sip:" + row.getAsString(SipAddress.SIP_ADDRESS)); switch (row.getAsInteger(SipAddress.TYPE)) { case SipAddress.TYPE_HOME: impp.addType(ImppType.HOME); break; case SipAddress.TYPE_WORK: impp.addType(ImppType.WORK); break; case SipAddress.TYPE_CUSTOM: String customType = row.getAsString(SipAddress.LABEL); if (StringUtils.isNotEmpty(customType)) impp.addType(ImppType.get(labelToXName(customType))); } c.getImpps().add(impp); } catch (IllegalArgumentException e) { Log.e(TAG, "Illegal SIP URI", e); } }
From source file:com.granita.icloudcalsync.resource.LocalCalendar.java
void populateAttendee(Event event, ContentValues values) throws RemoteException { try {//from ww w .j a va2 s . c om Attendee attendee = new Attendee(new URI("mailto", values.getAsString(Attendees.ATTENDEE_EMAIL), null)); ParameterList params = attendee.getParameters(); String cn = values.getAsString(Attendees.ATTENDEE_NAME); if (cn != null) params.add(new Cn(cn)); // type int type = values.getAsInteger(Attendees.ATTENDEE_TYPE); params.add((type == Attendees.TYPE_RESOURCE) ? CuType.RESOURCE : CuType.INDIVIDUAL); // role int relationship = values.getAsInteger(Attendees.ATTENDEE_RELATIONSHIP); switch (relationship) { case Attendees.RELATIONSHIP_ORGANIZER: params.add(Role.CHAIR); break; case Attendees.RELATIONSHIP_ATTENDEE: case Attendees.RELATIONSHIP_PERFORMER: case Attendees.RELATIONSHIP_SPEAKER: params.add((type == Attendees.TYPE_REQUIRED) ? Role.REQ_PARTICIPANT : Role.OPT_PARTICIPANT); break; case Attendees.RELATIONSHIP_NONE: params.add(Role.NON_PARTICIPANT); } // status switch (values.getAsInteger(Attendees.ATTENDEE_STATUS)) { case Attendees.ATTENDEE_STATUS_INVITED: params.add(PartStat.NEEDS_ACTION); break; case Attendees.ATTENDEE_STATUS_ACCEPTED: params.add(PartStat.ACCEPTED); break; case Attendees.ATTENDEE_STATUS_DECLINED: params.add(PartStat.DECLINED); break; case Attendees.ATTENDEE_STATUS_TENTATIVE: params.add(PartStat.TENTATIVE); break; } event.getAttendees().add(attendee); } catch (URISyntaxException ex) { Log.e(TAG, "Couldn't parse attendee information, ignoring", ex); } }
From source file:at.bitfire.davdroid.resource.LocalAddressBook.java
protected void populateEmailAddress(Contact c, ContentValues row) { ezvcard.property.Email email = new ezvcard.property.Email(row.getAsString(Email.ADDRESS)); if (row.containsKey(Email.TYPE)) switch (row.getAsInteger(Email.TYPE)) { case Email.TYPE_HOME: email.addType(EmailType.HOME); break; case Email.TYPE_WORK: email.addType(EmailType.WORK); break; case Email.TYPE_MOBILE: email.addType(Contact.EMAIL_TYPE_MOBILE); break; case Email.TYPE_CUSTOM: String customType = row.getAsString(Email.LABEL); if (StringUtils.isNotEmpty(customType)) email.addType(EmailType.get(labelToXName(customType))); }/*w ww. j av a 2 s . c o m*/ if (row.getAsInteger(Email.IS_PRIMARY) != 0) email.addType(EmailType.PREF); c.getEmails().add(email); }
From source file:at.bitfire.davdroid.resource.LocalAddressBook.java
protected void populateSipAddress(Contact c, ContentValues row) { try {//from w w w . j a va 2 s .com Impp impp = new Impp("sip:" + row.getAsString(SipAddress.SIP_ADDRESS)); if (row.containsKey(SipAddress.TYPE)) switch (row.getAsInteger(SipAddress.TYPE)) { case SipAddress.TYPE_HOME: impp.addType(ImppType.HOME); break; case SipAddress.TYPE_WORK: impp.addType(ImppType.WORK); break; case SipAddress.TYPE_CUSTOM: String customType = row.getAsString(SipAddress.LABEL); if (StringUtils.isNotEmpty(customType)) impp.addType(ImppType.get(labelToXName(customType))); } c.getImpps().add(impp); } catch (IllegalArgumentException e) { Log.e(TAG, "Illegal SIP URI", e); } }
From source file:at.bitfire.davdroid.resource.LocalAddressBook.java
protected void populatePhoneNumber(Contact c, ContentValues row) { ezvcard.property.Telephone number = new ezvcard.property.Telephone(row.getAsString(Phone.NUMBER)); switch (row.getAsInteger(Phone.TYPE)) { case Phone.TYPE_HOME: number.addType(TelephoneType.HOME); break;/*w w w . j a va 2 s.c o m*/ case Phone.TYPE_MOBILE: number.addType(TelephoneType.CELL); break; case Phone.TYPE_WORK: number.addType(TelephoneType.WORK); break; case Phone.TYPE_FAX_WORK: number.addType(TelephoneType.FAX); number.addType(TelephoneType.WORK); break; case Phone.TYPE_FAX_HOME: number.addType(TelephoneType.FAX); number.addType(TelephoneType.HOME); break; case Phone.TYPE_PAGER: number.addType(TelephoneType.PAGER); break; case Phone.TYPE_CALLBACK: number.addType(Contact.PHONE_TYPE_CALLBACK); break; case Phone.TYPE_CAR: number.addType(TelephoneType.CAR); break; case Phone.TYPE_COMPANY_MAIN: number.addType(Contact.PHONE_TYPE_COMPANY_MAIN); break; case Phone.TYPE_ISDN: number.addType(TelephoneType.ISDN); break; case Phone.TYPE_MAIN: number.addType(TelephoneType.PREF); break; case Phone.TYPE_OTHER_FAX: number.addType(TelephoneType.FAX); break; case Phone.TYPE_RADIO: number.addType(Contact.PHONE_TYPE_RADIO); break; case Phone.TYPE_TELEX: number.addType(TelephoneType.TEXTPHONE); break; case Phone.TYPE_TTY_TDD: number.addType(TelephoneType.TEXT); break; case Phone.TYPE_WORK_MOBILE: number.addType(TelephoneType.CELL); number.addType(TelephoneType.WORK); break; case Phone.TYPE_WORK_PAGER: number.addType(TelephoneType.PAGER); number.addType(TelephoneType.WORK); break; case Phone.TYPE_ASSISTANT: number.addType(Contact.PHONE_TYPE_ASSISTANT); break; case Phone.TYPE_MMS: number.addType(Contact.PHONE_TYPE_MMS); break; case Phone.TYPE_CUSTOM: String customType = row.getAsString(Phone.LABEL); if (StringUtils.isNotEmpty(customType)) number.addType(TelephoneType.get(labelToXName(customType))); } if (row.getAsInteger(Phone.IS_PRIMARY) != 0) number.addType(TelephoneType.PREF); c.getPhoneNumbers().add(number); }
From source file:at.bitfire.davdroid.resource.LocalAddressBook.java
protected void populatePostalAddress(Contact c, ContentValues row) { Address address = new Address(); address.setLabel(row.getAsString(StructuredPostal.FORMATTED_ADDRESS)); if (row.containsKey(StructuredPostal.TYPE)) switch (row.getAsInteger(StructuredPostal.TYPE)) { case StructuredPostal.TYPE_HOME: address.addType(AddressType.HOME); break; case StructuredPostal.TYPE_WORK: address.addType(AddressType.WORK); break; case StructuredPostal.TYPE_CUSTOM: String customType = row.getAsString(StructuredPostal.LABEL); if (StringUtils.isNotEmpty(customType)) address.addType(AddressType.get(labelToXName(customType))); break; }// ww w . ja v a 2 s .c o m address.setStreetAddress(row.getAsString(StructuredPostal.STREET)); address.setPoBox(row.getAsString(StructuredPostal.POBOX)); address.setExtendedAddress(row.getAsString(StructuredPostal.NEIGHBORHOOD)); address.setLocality(row.getAsString(StructuredPostal.CITY)); address.setRegion(row.getAsString(StructuredPostal.REGION)); address.setPostalCode(row.getAsString(StructuredPostal.POSTCODE)); address.setCountry(row.getAsString(StructuredPostal.COUNTRY)); c.getAddresses().add(address); }
From source file:at.bitfire.davdroid.resource.LocalAddressBook.java
protected void populateEvent(Contact c, ContentValues row) { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", Locale.US); try {//from ww w . jav a 2s . co m Date date = formatter.parse(row.getAsString(CommonDataKinds.Event.START_DATE)); switch (row.getAsInteger(CommonDataKinds.Event.TYPE)) { case CommonDataKinds.Event.TYPE_ANNIVERSARY: c.anniversary = new Anniversary(date); break; case CommonDataKinds.Event.TYPE_BIRTHDAY: c.birthDay = new Birthday(date); break; } } catch (ParseException e) { Log.w(TAG, "Couldn't parse local birthday/anniversary date", e); } }
From source file:com.granita.icloudcalsync.resource.LocalAddressBook.java
protected void populateEvent(Contact c, ContentValues row) throws RemoteException { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", Locale.US); try {/* ww w . ja v a 2 s . c om*/ Date date = formatter.parse(row.getAsString(CommonDataKinds.Event.START_DATE)); switch (row.getAsInteger(CommonDataKinds.Event.TYPE)) { case CommonDataKinds.Event.TYPE_ANNIVERSARY: c.setAnniversary(new Anniversary(date)); break; case CommonDataKinds.Event.TYPE_BIRTHDAY: c.setBirthDay(new Birthday(date)); break; } } catch (ParseException e) { Log.w(TAG, "Couldn't parse local birthday/anniversary date", e); } }
From source file:com.partypoker.poker.engagement.reach.EngagementReachAgent.java
/** * Parse a content.//w w w. j av a2s .co m * @param campaignId already parsed campaign id. * @param values content values. * @return content. * @throws Exception parsing problem. */ private EngagementReachContent parseContent(com.microsoft.azure.engagement.reach.CampaignId campaignId, ContentValues values) throws Exception { switch (campaignId.getKind()) { case ANNOUNCEMENT: if ((values.getAsInteger(DLC) & FLAG_DLC_CONTENT) == FLAG_DLC_CONTENT) return new EngagementAnnouncement(campaignId, values, mInjectedParams); return new EngagementNotifAnnouncement(campaignId, values, mInjectedParams); case POLL: return new EngagementPoll(campaignId, values); case DATAPUSH: return new com.microsoft.azure.engagement.reach.EngagementDataPush(campaignId, values, mInjectedParams); default: throw new IllegalArgumentException("Invalid campaign id"); } }