本文整理汇总了Java中android.provider.ContactsContract.CommonDataKinds.StructuredPostal类的典型用法代码示例。如果您正苦于以下问题:Java StructuredPostal类的具体用法?Java StructuredPostal怎么用?Java StructuredPostal使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StructuredPostal类属于android.provider.ContactsContract.CommonDataKinds包,在下文中一共展示了StructuredPostal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insertAddress
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; //导入依赖的package包/类
/**
* Add an address to a list of database actions to be performed
*
* @param ops the list of database actions
* @param address the item to be inserted
*/
private void insertAddress(ArrayList<ContentProviderOperation> ops,
JSONObject address) {
ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0)
.withValue(ContactsContract.Data.MIMETYPE, CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE)
.withValue(CommonDataKinds.StructuredPostal.TYPE, getAddressType(getJsonString(address, "type")))
.withValue(CommonDataKinds.StructuredPostal.FORMATTED_ADDRESS, getJsonString(address, "formatted"))
.withValue(CommonDataKinds.StructuredPostal.STREET, getJsonString(address, "streetAddress"))
.withValue(CommonDataKinds.StructuredPostal.CITY, getJsonString(address, "locality"))
.withValue(CommonDataKinds.StructuredPostal.REGION, getJsonString(address, "region"))
.withValue(CommonDataKinds.StructuredPostal.POSTCODE, getJsonString(address, "postalCode"))
.withValue(CommonDataKinds.StructuredPostal.COUNTRY, getJsonString(address, "country"))
.withValue(CommonDataKinds.StructuredPostal.LABEL, getJsonString(address, "type"))
.build());
}
示例2: getAddressType
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; //导入依赖的package包/类
/**
* Converts a string from the W3C Contact API to it's Android int value.
* @param string
* @return Android int value
*/
private int getAddressType(String string) {
int type = CommonDataKinds.StructuredPostal.TYPE_OTHER;
if (string != null) {
String lowerType = string.toLowerCase(Locale.getDefault());
if ("work".equals(lowerType)) {
return CommonDataKinds.StructuredPostal.TYPE_WORK;
}
else if ("other".equals(lowerType)) {
return CommonDataKinds.StructuredPostal.TYPE_OTHER;
}
else if ("home".equals(lowerType)) {
return CommonDataKinds.StructuredPostal.TYPE_HOME;
}
return CommonDataKinds.StructuredPostal.TYPE_CUSTOM;
}
return type;
}
示例3: createAddressContentValues
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; //导入依赖的package包/类
private ContentValues createAddressContentValues(final JSONObject address, final int typeConstant,
final String type) throws JSONException {
ContentValues contentValues = new ContentValues();
contentValues.put(Data.MIMETYPE, StructuredPostal.CONTENT_ITEM_TYPE);
contentValues.put(StructuredPostal.STREET, address.optString("streetAddress"));
contentValues.put(StructuredPostal.CITY, address.optString("locality"));
contentValues.put(StructuredPostal.REGION, address.optString("region"));
contentValues.put(StructuredPostal.POSTCODE, address.optString("postalCode"));
contentValues.put(StructuredPostal.COUNTRY, address.optString("countryName"));
if (type != null) {
contentValues.put(StructuredPostal.TYPE, typeConstant);
// If a custom type, add a label
if (typeConstant == BaseTypes.TYPE_CUSTOM) {
contentValues.put(StructuredPostal.LABEL, type);
}
}
if (address.has("pref")) {
contentValues.put(Data.IS_SUPER_PRIMARY, address.getBoolean("pref") ? 1 : 0);
}
return contentValues;
}
示例4: initColumnNameConstantsMap
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; //导入依赖的package包/类
private void initColumnNameConstantsMap() {
if (mColumnNameConstantsMap != null) {
return;
}
mColumnNameConstantsMap = new HashMap<String, String>();
mColumnNameConstantsMap.put("name", StructuredName.DISPLAY_NAME);
mColumnNameConstantsMap.put("givenname", StructuredName.GIVEN_NAME);
mColumnNameConstantsMap.put("familyname", StructuredName.FAMILY_NAME);
mColumnNameConstantsMap.put("honorificprefix", StructuredName.PREFIX);
mColumnNameConstantsMap.put("honorificsuffix", StructuredName.SUFFIX);
mColumnNameConstantsMap.put("additionalname", CUSTOM_DATA_COLUMN);
mColumnNameConstantsMap.put("nickname", Nickname.NAME);
mColumnNameConstantsMap.put("adr", StructuredPostal.STREET);
mColumnNameConstantsMap.put("email", Email.ADDRESS);
mColumnNameConstantsMap.put("url", Website.URL);
mColumnNameConstantsMap.put("category", GroupMembership.GROUP_ROW_ID);
mColumnNameConstantsMap.put("tel", Phone.NUMBER);
mColumnNameConstantsMap.put("org", Organization.COMPANY);
mColumnNameConstantsMap.put("jobTitle", Organization.TITLE);
mColumnNameConstantsMap.put("note", Note.NOTE);
mColumnNameConstantsMap.put("impp", Im.DATA);
mColumnNameConstantsMap.put("sex", CUSTOM_DATA_COLUMN);
mColumnNameConstantsMap.put("genderidentity", CUSTOM_DATA_COLUMN);
mColumnNameConstantsMap.put("key", CUSTOM_DATA_COLUMN);
}
示例5: updateAddress
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; //导入依赖的package包/类
public ContactOperations updateAddress(String city, String country,
String neighborhood, String pobox, String postcode, String region,
String street, String label, boolean isPrimary,
boolean isSuperPrimary, Uri uri) {
mValues.clear();
mValues.put(StructuredPostal.CITY, city);
mValues.put(StructuredPostal.COUNTRY, country);
mValues.put(StructuredPostal.NEIGHBORHOOD, neighborhood);
mValues.put(StructuredPostal.POBOX, pobox);
mValues.put(StructuredPostal.POSTCODE, postcode);
mValues.put(StructuredPostal.REGION, region);
mValues.put(StructuredPostal.STREET, street);
mValues.put(StructuredPostal.LABEL, label);
mValues.put(StructuredPostal.IS_PRIMARY, isPrimary ? 1 : 0);
mValues.put(StructuredPostal.IS_SUPER_PRIMARY, isSuperPrimary ? 1 : 0);
addUpdateOp(uri);
return this;
}
示例6: addPostal
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; //导入依赖的package包/类
@Override
public boolean addPostal(ContactStruct contact, Cursor postals, boolean removeMatches) {
String address = postals.getString(postals
.getColumnIndex(StructuredPostal.FORMATTED_ADDRESS));
String poBox = postals.getString(postals.getColumnIndex(StructuredPostal.POBOX));
String street = postals.getString(postals.getColumnIndex(StructuredPostal.STREET));
String nbrhood = postals.getString(postals.getColumnIndex(StructuredPostal.NEIGHBORHOOD));
String city = postals.getString(postals.getColumnIndex(StructuredPostal.CITY));
String state = postals.getString(postals.getColumnIndex(StructuredPostal.REGION));
String postCode = postals.getString(postals.getColumnIndex(StructuredPostal.POSTCODE));
String country = postals.getString(postals.getColumnIndex(StructuredPostal.COUNTRY));
String label = postals.getString(postals.getColumnIndexOrThrow(StructuredPostal.LABEL));
int type = postals.getInt(postals.getColumnIndexOrThrow(StructuredPostal.TYPE));
boolean primary = (postals.getInt(postals
.getColumnIndexOrThrow(StructuredPostal.IS_PRIMARY)) != 0);
if (!TextUtils.isEmpty(address)
&& isPostalNew(contact, address, poBox, street, nbrhood, city, state, postCode,
type, removeMatches)) {
contact.addAddress(type, address, poBox, nbrhood, street, city, state, postCode,
country, label, primary);
return true;
}
return false;
}
示例7: valuesPostal
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; //导入依赖的package包/类
private ContentValues valuesPostal(Address postal) {
ContentValues val = new ContentValues();
val.put(Data.MIMETYPE, StructuredPostal.CONTENT_ITEM_TYPE);
val.put(StructuredPostal.POBOX, postal.getPoBox());
val.put(StructuredPostal.NEIGHBORHOOD, postal.getExtended());
val.put(StructuredPostal.STREET, postal.getStreet());
val.put(StructuredPostal.CITY, postal.getCity());
val.put(StructuredPostal.REGION, postal.getState());
val.put(StructuredPostal.POSTCODE, postal.getPostalCode());
val.put(StructuredPostal.COUNTRY, postal.getCountry());
val.put(StructuredPostal.FORMATTED_ADDRESS, postal.toString());
val.put(StructuredPostal.IS_PRIMARY, postal.isPrimary() ? 1 : 0);
val.put(StructuredPostal.LABEL, postal.getLabel());
val.put(StructuredPostal.TYPE, postal.getType());
return val;
}
示例8: updatePostal
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; //导入依赖的package包/类
private boolean updatePostal(Address postal, String rawContactId, Context ctx) {
// seek for raw contact + formatted address = same
String[] proj = new String[] {
StructuredPostal.RAW_CONTACT_ID, Data.MIMETYPE, StructuredPostal.FORMATTED_ADDRESS
};
String where = StructuredPostal.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=? AND "
+ StructuredPostal.FORMATTED_ADDRESS + "=?";
String[] args = new String[] {
rawContactId, StructuredPostal.CONTENT_ITEM_TYPE, postal.toString()
};
ContentValues values = valuesPostal(postal);
values.put(StructuredPostal.RAW_CONTACT_ID, rawContactId);
return updateDataRow(ctx, proj, where, args, values);
}
示例9: fillFromCursor
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; //导入依赖的package包/类
private void fillFromCursor() {
Integer type = getInt(StructuredPostal.TYPE);
label = getType(type, getString(StructuredPostal.LABEL));
formattedAddress = getString(StructuredPostal.FORMATTED_ADDRESS);
poBox = getString(StructuredPostal.POBOX);
street = getString(StructuredPostal.STREET);
neighborhood = getString(StructuredPostal.NEIGHBORHOOD);
city = getString(StructuredPostal.CITY);
region = getString(StructuredPostal.REGION);
postcode = getString(StructuredPostal.POSTCODE);
country = getString(StructuredPostal.COUNTRY);
}
示例10: getType
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; //导入依赖的package包/类
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;
}
}
示例11: initAddressTypesMap
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; //导入依赖的package包/类
private void initAddressTypesMap() {
if (mAddressTypesMap != null) {
return;
}
mAddressTypesMap = new HashMap<String, Integer>();
mAddressTypesMap.put("home", StructuredPostal.TYPE_HOME);
mAddressTypesMap.put("work", StructuredPostal.TYPE_WORK);
}
示例12: addAddress
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; //导入依赖的package包/类
public ContactOperations addAddress(String city, String country,
String label, int androidAddressType, String neighborhood,
String pobox, String postcode, String region, String street,
boolean isPrimary, boolean isSuperPrimary) {
mValues.clear();
mValues.put(StructuredPostal.CITY, city);
mValues.put(StructuredPostal.COUNTRY, country);
mValues.put(StructuredPostal.MIMETYPE,
StructuredPostal.CONTENT_ITEM_TYPE);
if (!TextUtils.isEmpty(label)) {
mValues.put(StructuredPostal.LABEL, label);
}
if (isSuperPrimary) {
mValues.put(Email.IS_SUPER_PRIMARY, 1);
}
if (isPrimary) {
mValues.put(Email.IS_PRIMARY, 1);
}
mValues.put(StructuredPostal.NEIGHBORHOOD, neighborhood);
mValues.put(StructuredPostal.POBOX, pobox);
mValues.put(StructuredPostal.POSTCODE, postcode);
mValues.put(StructuredPostal.REGION, region);
mValues.put(StructuredPostal.STREET, street);
addInsertOp();
return this;
}
示例13: getAndroidAddressType
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; //导入依赖的package包/类
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;
}
}
示例14: getAddressType
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; //导入依赖的package包/类
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;
}
}
示例15: populatePostalAddresses
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; //导入依赖的package包/类
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);
}
}