本文整理汇总了Java中android.provider.ContactsContract.CommonDataKinds.StructuredPostal.TYPE_WORK属性的典型用法代码示例。如果您正苦于以下问题:Java StructuredPostal.TYPE_WORK属性的具体用法?Java StructuredPostal.TYPE_WORK怎么用?Java StructuredPostal.TYPE_WORK使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.provider.ContactsContract.CommonDataKinds.StructuredPostal
的用法示例。
在下文中一共展示了StructuredPostal.TYPE_WORK属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getType
private String getType(Integer type, String label) {
if (type == null) {
throw new InvalidCursorTypeException();
}
switch (type) {
case StructuredPostal.TYPE_HOME:
return "home";
case StructuredPostal.TYPE_WORK:
return "work";
case StructuredPostal.TYPE_OTHER:
return "other";
default:
return label;
}
}
示例2: getAndroidAddressType
public static int getAndroidAddressType(AddressType type) {
switch (type) {
case TYPE_CUSTOM:
return StructuredPostal.TYPE_CUSTOM;
case TYPE_HOME:
return StructuredPostal.TYPE_HOME;
case TYPE_OTHER:
return StructuredPostal.TYPE_OTHER;
case TYPE_WORK:
return StructuredPostal.TYPE_WORK;
default:
return StructuredPostal.TYPE_OTHER;
}
}
示例3: getAddressType
public static AddressType getAddressType(int androidType) {
switch (androidType) {
case StructuredPostal.TYPE_CUSTOM:
return AddressType.TYPE_CUSTOM;
case StructuredPostal.TYPE_HOME:
return AddressType.TYPE_HOME;
case StructuredPostal.TYPE_OTHER:
return AddressType.TYPE_OTHER;
case StructuredPostal.TYPE_WORK:
return AddressType.TYPE_WORK;
default:
return AddressType.TYPE_OTHER;
}
}
示例4: populatePostalAddresses
protected void populatePostalAddresses(Contact c) throws RemoteException {
@Cleanup Cursor cursor = providerClient.query(dataURI(), new String[] {
/* 0 */ StructuredPostal.FORMATTED_ADDRESS, StructuredPostal.TYPE, StructuredPostal.LABEL,
/* 3 */ StructuredPostal.STREET, StructuredPostal.POBOX, StructuredPostal.NEIGHBORHOOD,
/* 6 */ StructuredPostal.CITY, StructuredPostal.REGION, StructuredPostal.POSTCODE,
/* 9 */ StructuredPostal.COUNTRY
}, StructuredPostal.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
new String[] { String.valueOf(c.getLocalID()), StructuredPostal.CONTENT_ITEM_TYPE }, null);
while (cursor != null && cursor.moveToNext()) {
Address address = new Address();
address.setLabel(cursor.getString(0));
switch (cursor.getInt(1)) {
case StructuredPostal.TYPE_HOME:
address.addType(AddressType.HOME);
break;
case StructuredPostal.TYPE_WORK:
address.addType(AddressType.WORK);
break;
case StructuredPostal.TYPE_CUSTOM:
String customType = cursor.getString(2);
if (!StringUtils.isEmpty(customType))
address.addType(AddressType.get(labelToXName(customType)));
break;
}
address.setStreetAddress(cursor.getString(3));
address.setPoBox(cursor.getString(4));
address.setExtendedAddress(cursor.getString(5));
address.setLocality(cursor.getString(6));
address.setRegion(cursor.getString(7));
address.setPostalCode(cursor.getString(8));
address.setCountry(cursor.getString(9));
c.getAddresses().add(address);
}
}
示例5: getStructuredPostalTypeLabel
private String getStructuredPostalTypeLabel(int type, String label) {
switch (type) {
case StructuredPostal.TYPE_HOME:
return getString(R.string.label_hometag);
case StructuredPostal.TYPE_WORK:
return getString(R.string.label_worktag);
case StructuredPostal.TYPE_OTHER:
return getString(R.string.label_othertag);
default:
return StructuredPostal.getTypeLabel(this.getResources(), type, label).toString();
}
}
示例6: buildAddress
protected Builder buildAddress(Builder builder, Address address) {
/* street po.box (extended)
* region
* postal code city
* country
*/
String formattedAddress = address.getLabel();
if (StringUtils.isEmpty(formattedAddress)) {
String lineStreet = StringUtils.join(new String[] { address.getStreetAddress(), address.getPoBox(), address.getExtendedAddress() }, " "),
lineLocality = StringUtils.join(new String[] { address.getPostalCode(), address.getLocality() }, " ");
List<String> lines = new LinkedList<String>();
if (lineStreet != null)
lines.add(lineStreet);
if (address.getRegion() != null && !address.getRegion().isEmpty())
lines.add(address.getRegion());
if (lineLocality != null)
lines.add(lineLocality);
formattedAddress = StringUtils.join(lines, "\n");
}
int typeCode = 0;
String typeLabel = null;
for (AddressType type : address.getTypes())
if (type == AddressType.HOME)
typeCode = StructuredPostal.TYPE_HOME;
else if (type == AddressType.WORK)
typeCode = StructuredPostal.TYPE_WORK;
if (typeCode == 0)
if (address.getTypes().isEmpty())
typeCode = StructuredPostal.TYPE_OTHER;
else {
typeCode = StructuredPostal.TYPE_CUSTOM;
typeLabel = xNameToLabel(address.getTypes().iterator().next().getValue());
}
builder = builder
.withValue(Data.MIMETYPE, StructuredPostal.CONTENT_ITEM_TYPE)
.withValue(StructuredPostal.FORMATTED_ADDRESS, formattedAddress)
.withValue(StructuredPostal.TYPE, typeCode)
.withValue(StructuredPostal.STREET, address.getStreetAddress())
.withValue(StructuredPostal.POBOX, address.getPoBox())
.withValue(StructuredPostal.NEIGHBORHOOD, address.getExtendedAddress())
.withValue(StructuredPostal.CITY, address.getLocality())
.withValue(StructuredPostal.REGION, address.getRegion())
.withValue(StructuredPostal.POSTCODE, address.getPostalCode())
.withValue(StructuredPostal.COUNTRY, address.getCountry());
if (typeLabel != null)
builder = builder.withValue(StructuredPostal.LABEL, typeLabel);
return builder;
}