List of usage examples for android.content ContentValues getAsInteger
public Integer getAsInteger(String key)
From source file:at.bitfire.ical4android.AndroidEvent.java
protected void populateReminder(ContentValues row) { VAlarm alarm = new VAlarm(new Dur(0, 0, -row.getAsInteger(Reminders.MINUTES), 0)); PropertyList props = alarm.getProperties(); props.add(Action.DISPLAY);//from w w w .j av a 2 s . c om props.add(new Description(event.summary)); event.getAlarms().add(alarm); }
From source file:com.csipsimple.backup.Columns.java
public JSONObject contentValueToJSON(ContentValues cv) { JSONObject json = new JSONObject(); for (int i = 0; i < names.size(); i++) { if (!cv.containsKey(names.get(i))) { continue; }/* www . j a v a 2 s . c o m*/ try { String name = names.get(i); switch (types.get(i)) { case STRING: json.put(name, cv.getAsString(name)); break; case INT: json.put(name, cv.getAsInteger(name)); break; case LONG: json.put(name, cv.getAsLong(name)); break; case FLOAT: json.put(name, cv.getAsFloat(name)); break; case DOUBLE: json.put(name, cv.getAsDouble(name)); break; case BOOLEAN: json.put(name, cv.getAsBoolean(name)); break; default: Log.w("Col", "Invalid type, can't unserialize " + types.get(i)); } } catch (JSONException e) { Log.e("Col", "Invalid type, can't unserialize ", e); } } return json; }
From source file:com.csipsimple.ui.favorites.FavAdapter.java
@Override public void bindView(View view, final Context context, Cursor cursor) { ContentValues cv = new ContentValues(); DatabaseUtils.cursorRowToContentValues(cursor, cv); int type = ContactsWrapper.TYPE_CONTACT; if (cv.containsKey(ContactsWrapper.FIELD_TYPE)) { type = cv.getAsInteger(ContactsWrapper.FIELD_TYPE); }//from ww w. ja v a 2 s . c om showViewForType(view, type); if (type == ContactsWrapper.TYPE_GROUP) { // Get views TextView tv = (TextView) view.findViewById(R.id.header_text); ImageView icon = (ImageView) view.findViewById(R.id.header_icon); PresenceStatusSpinner presSpinner = (PresenceStatusSpinner) view .findViewById(R.id.header_presence_spinner); // Get datas SipProfile acc = new SipProfile(cursor); final Long profileId = cv.getAsLong(BaseColumns._ID); final String groupName = acc.android_group; final String displayName = acc.display_name; final String wizard = acc.wizard; final boolean publishedEnabled = (acc.publish_enabled == 1); final String domain = acc.getDefaultDomain(); // Bind datas to view tv.setText(displayName); icon.setImageResource(WizardUtils.getWizardIconRes(wizard)); presSpinner.setProfileId(profileId); // Extra menu view if not already set ViewGroup menuViewWrapper = (ViewGroup) view.findViewById(R.id.header_cfg_spinner); MenuCallback newMcb = new MenuCallback(context, profileId, groupName, domain, publishedEnabled); MenuBuilder menuBuilder; if (menuViewWrapper.getTag() == null) { final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); ActionMenuPresenter mActionMenuPresenter = new ActionMenuPresenter(mContext); mActionMenuPresenter.setReserveOverflow(true); menuBuilder = new MenuBuilder(context); menuBuilder.setCallback(newMcb); MenuInflater inflater = new MenuInflater(context); inflater.inflate(R.menu.fav_menu, menuBuilder); menuBuilder.addMenuPresenter(mActionMenuPresenter); ActionMenuView menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(menuViewWrapper); UtilityWrapper.getInstance().setBackgroundDrawable(menuView, null); menuViewWrapper.addView(menuView, layoutParams); menuViewWrapper.setTag(menuBuilder); } else { menuBuilder = (MenuBuilder) menuViewWrapper.getTag(); menuBuilder.setCallback(newMcb); } menuBuilder.findItem(R.id.share_presence).setTitle( publishedEnabled ? R.string.deactivate_presence_sharing : R.string.activate_presence_sharing); menuBuilder.findItem(R.id.set_sip_data).setVisible(!TextUtils.isEmpty(groupName)); } else if (type == ContactsWrapper.TYPE_CONTACT) { ContactInfo ci = ContactsWrapper.getInstance().getContactInfo(context, cursor); ci.userData = cursor.getPosition(); // Get views TextView tv = (TextView) view.findViewById(R.id.contact_name); QuickContactBadge badge = (QuickContactBadge) view.findViewById(R.id.quick_contact_photo); TextView statusText = (TextView) view.findViewById(R.id.status_text); ImageView statusImage = (ImageView) view.findViewById(R.id.status_icon); // Bind if (ci.contactId != null) { tv.setText(ci.displayName); badge.assignContactUri(ci.callerInfo.contactContentUri); ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(context, badge.getImageView(), ci.callerInfo, R.drawable.ic_contact_picture_holo_dark); statusText.setVisibility(ci.hasPresence ? View.VISIBLE : View.GONE); statusText.setText(ci.status); statusImage.setVisibility(ci.hasPresence ? View.VISIBLE : View.GONE); statusImage.setImageResource(ContactsWrapper.getInstance().getPresenceIconResourceId(ci.presence)); } View v; v = view.findViewById(R.id.contact_view); v.setTag(ci); v.setOnClickListener(mPrimaryActionListener); v = view.findViewById(R.id.secondary_action_icon); v.setTag(ci); v.setOnClickListener(mSecondaryActionListener); } else if (type == ContactsWrapper.TYPE_CONFIGURE) { // We only bind if it's the correct type View v = view.findViewById(R.id.configure_view); v.setOnClickListener(this); ConfigureObj cfg = new ConfigureObj(); cfg.profileId = cv.getAsLong(BaseColumns._ID); v.setTag(cfg); } }
From source file:com.fututel.ui.favorites.FavAdapter.java
@Override public void bindView(View view, final Context context, Cursor cursor) { ContentValues cv = new ContentValues(); DatabaseUtils.cursorRowToContentValues(cursor, cv); int type = ContactsWrapper.TYPE_CONTACT; if (cv.containsKey(ContactsWrapper.FIELD_TYPE)) { type = cv.getAsInteger(ContactsWrapper.FIELD_TYPE); }// w w w .j a v a 2s . c o m showViewForType(view, type); if (type == ContactsWrapper.TYPE_GROUP) { // Get views TextView tv = (TextView) view.findViewById(R.id.header_text); ImageView icon = (ImageView) view.findViewById(R.id.header_icon); PresenceStatusSpinner presSpinner = (PresenceStatusSpinner) view .findViewById(R.id.header_presence_spinner); // Get datas SipProfile acc = new SipProfile(cursor); final Long profileId = cv.getAsLong(BaseColumns._ID); final String groupName = acc.android_group; final String displayName = acc.display_name; final String wizard = acc.wizard; final boolean publishedEnabled = (acc.publish_enabled == 1); final String domain = acc.getDefaultDomain(); // Bind datas to view tv.setText(displayName); icon.setImageResource(WizardUtils.getWizardIconRes(wizard)); presSpinner.setProfileId(profileId); // Extra menu view if not already set ViewGroup menuViewWrapper = (ViewGroup) view.findViewById(R.id.header_cfg_spinner); MenuCallback newMcb = new MenuCallback(context, profileId, groupName, domain, publishedEnabled); MenuBuilder menuBuilder; if (menuViewWrapper.getTag() == null) { final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); ActionMenuPresenter mActionMenuPresenter = new ActionMenuPresenter(mContext); mActionMenuPresenter.setReserveOverflow(true); menuBuilder = new MenuBuilder(context); menuBuilder.setCallback(newMcb); MenuInflater inflater = new MenuInflater(context); inflater.inflate(R.menu.fav_menu, menuBuilder); menuBuilder.addMenuPresenter(mActionMenuPresenter); ActionMenuView menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(menuViewWrapper); UtilityWrapper.getInstance().setBackgroundDrawable(menuView, null); menuViewWrapper.addView(menuView, layoutParams); menuViewWrapper.setTag(menuBuilder); } else { menuBuilder = (MenuBuilder) menuViewWrapper.getTag(); menuBuilder.setCallback(newMcb); } menuBuilder.findItem(R.id.share_presence).setTitle( publishedEnabled ? R.string.deactivate_presence_sharing : R.string.activate_presence_sharing); menuBuilder.findItem(R.id.set_sip_data).setVisible(!TextUtils.isEmpty(groupName)); } else if (type == ContactsWrapper.TYPE_CONTACT) { ContactInfo ci = ContactsWrapper.getInstance().getContactInfo(context, cursor); ci.userData = cursor.getPosition(); // Get views TextView tv = (TextView) view.findViewById(R.id.contact_name); QuickContactBadge badge = (QuickContactBadge) view.findViewById(R.id.quick_contact_photo); TextView statusText = (TextView) view.findViewById(R.id.status_text); ImageView statusImage = (ImageView) view.findViewById(R.id.status_icon); // Bind if (ci.contactId != null) { tv.setText(ci.displayName); badge.assignContactUri(ci.callerInfo.contactContentUri); ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(context, badge.getImageView(), ci.callerInfo, R.drawable.ic_contact_picture_holo_light); statusText.setVisibility(ci.hasPresence ? View.VISIBLE : View.GONE); statusText.setText(ci.status); statusImage.setVisibility(ci.hasPresence ? View.VISIBLE : View.GONE); statusImage.setImageResource(ContactsWrapper.getInstance().getPresenceIconResourceId(ci.presence)); } View v; v = view.findViewById(R.id.contact_view); v.setTag(ci); v.setOnClickListener(mPrimaryActionListener); v = view.findViewById(R.id.secondary_action_icon); v.setTag(ci); v.setOnClickListener(mSecondaryActionListener); } else if (type == ContactsWrapper.TYPE_CONFIGURE) { // We only bind if it's the correct type View v = view.findViewById(R.id.configure_view); v.setOnClickListener(this); ConfigureObj cfg = new ConfigureObj(); cfg.profileId = cv.getAsLong(BaseColumns._ID); v.setTag(cfg); } }
From source file:com.chen.mail.providers.Attachment.java
/** * Create an attachment from a {@link ContentValues} object. * The keys should be {@link UIProvider.AttachmentColumns}. *//*www . j a v a 2 s . com*/ public Attachment(ContentValues values) { name = values.getAsString(UIProvider.AttachmentColumns.NAME); size = values.getAsInteger(UIProvider.AttachmentColumns.SIZE); uri = parseOptionalUri(values.getAsString(UIProvider.AttachmentColumns.URI)); contentType = values.getAsString(UIProvider.AttachmentColumns.CONTENT_TYPE); state = values.getAsInteger(UIProvider.AttachmentColumns.STATE); destination = values.getAsInteger(UIProvider.AttachmentColumns.DESTINATION); downloadedSize = values.getAsInteger(UIProvider.AttachmentColumns.DOWNLOADED_SIZE); contentUri = parseOptionalUri(values.getAsString(UIProvider.AttachmentColumns.CONTENT_URI)); thumbnailUri = parseOptionalUri(values.getAsString(UIProvider.AttachmentColumns.THUMBNAIL_URI)); previewIntentUri = parseOptionalUri(values.getAsString(UIProvider.AttachmentColumns.PREVIEW_INTENT_URI)); providerData = values.getAsString(UIProvider.AttachmentColumns.PROVIDER_DATA); supportsDownloadAgain = values.getAsBoolean(UIProvider.AttachmentColumns.SUPPORTS_DOWNLOAD_AGAIN); type = values.getAsInteger(UIProvider.AttachmentColumns.TYPE); flags = values.getAsInteger(UIProvider.AttachmentColumns.FLAGS); }
From source file:com.android.mail.providers.Attachment.java
/** * Create an attachment from a {@link ContentValues} object. * The keys should be {@link AttachmentColumns}. *///w ww.j a va2 s . c o m public Attachment(ContentValues values) { name = values.getAsString(AttachmentColumns.NAME); size = values.getAsInteger(AttachmentColumns.SIZE); uri = parseOptionalUri(values.getAsString(AttachmentColumns.URI)); contentType = values.getAsString(AttachmentColumns.CONTENT_TYPE); state = values.getAsInteger(AttachmentColumns.STATE); destination = values.getAsInteger(AttachmentColumns.DESTINATION); downloadedSize = values.getAsInteger(AttachmentColumns.DOWNLOADED_SIZE); contentUri = parseOptionalUri(values.getAsString(AttachmentColumns.CONTENT_URI)); thumbnailUri = parseOptionalUri(values.getAsString(AttachmentColumns.THUMBNAIL_URI)); previewIntentUri = parseOptionalUri(values.getAsString(AttachmentColumns.PREVIEW_INTENT_URI)); providerData = values.getAsString(AttachmentColumns.PROVIDER_DATA); supportsDownloadAgain = values.getAsBoolean(AttachmentColumns.SUPPORTS_DOWNLOAD_AGAIN); type = values.getAsInteger(AttachmentColumns.TYPE); flags = values.getAsInteger(AttachmentColumns.FLAGS); partId = values.getAsString(AttachmentColumns.CONTENT_ID); }
From source file:com.roamprocess1.roaming4world.ui.favorites.FavAdapter.java
@Override public void bindView(View view, final Context context, Cursor cursor) { ContentValues cv = new ContentValues(); DatabaseUtils.cursorRowToContentValues(cursor, cv); int type = ContactsWrapper.TYPE_CONTACT; if (cv.containsKey(ContactsWrapper.FIELD_TYPE)) { type = cv.getAsInteger(ContactsWrapper.FIELD_TYPE); }// ww w .j a v a 2 s . co m showViewForType(view, type); if (type == ContactsWrapper.TYPE_GROUP) { // Get views TextView tv = (TextView) view.findViewById(R.id.header_text); ImageView icon = (ImageView) view.findViewById(R.id.header_icon); // PresenceStatusSpinner presSpinner = (PresenceStatusSpinner) view.findViewById(R.id.header_presence_spinner); // Get datas SipProfile acc = new SipProfile(cursor); final Long profileId = cv.getAsLong(BaseColumns._ID); final String groupName = acc.android_group; final String displayName = acc.display_name; final String wizard = acc.wizard; final boolean publishedEnabled = (acc.publish_enabled == 1); final String domain = acc.getDefaultDomain(); // Bind datas to view //tv.setText(displayName); //Commented by Esstel Softwares tv.setText("Starred Android Contacts"); icon.setImageResource(WizardUtils.getWizardIconRes(wizard)); // presSpinner.setProfileId(profileId); // Extra menu view if not already set ViewGroup menuViewWrapper = (ViewGroup) view.findViewById(R.id.header_cfg_spinner); MenuCallback newMcb = new MenuCallback(context, profileId, groupName, domain, publishedEnabled); MenuBuilder menuBuilder; if (menuViewWrapper.getTag() == null) { final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); ActionMenuPresenter mActionMenuPresenter = new ActionMenuPresenter(mContext); mActionMenuPresenter.setReserveOverflow(true); menuBuilder = new MenuBuilder(context); menuBuilder.setCallback(newMcb); MenuInflater inflater = new MenuInflater(context); inflater.inflate(R.menu.fav_menu_new, menuBuilder); menuBuilder.addMenuPresenter(mActionMenuPresenter); ActionMenuView menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(menuViewWrapper); UtilityWrapper.getInstance().setBackgroundDrawable(menuView, null); menuViewWrapper.addView(menuView, layoutParams); menuViewWrapper.setTag(menuBuilder); } else { menuBuilder = (MenuBuilder) menuViewWrapper.getTag(); menuBuilder.setCallback(newMcb); } // menuBuilder.findItem(R.id.share_presence).setTitle(publishedEnabled ? R.string.deactivate_presence_sharing : R.string.activate_presence_sharing); // menuBuilder.findItem(R.id.set_sip_data).setVisible(!TextUtils.isEmpty(groupName)); } else if (type == ContactsWrapper.TYPE_CONTACT) { ContactInfo ci = ContactsWrapper.getInstance().getContactInfo(context, cursor); ci.userData = cursor.getPosition(); // Get views TextView tv = (TextView) view.findViewById(R.id.contact_name); QuickContactBadge badge = (QuickContactBadge) view.findViewById(R.id.quick_contact_photo); TextView statusText = (TextView) view.findViewById(R.id.status_text); ImageView statusImage = (ImageView) view.findViewById(R.id.status_icon); // Bind if (ci.contactId != null) { tv.setText(ci.displayName); badge.assignContactUri(ci.callerInfo.contactContentUri); ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(context, badge.getImageView(), ci.callerInfo, R.drawable.ic_contact_picture_holo_dark); statusText.setVisibility(ci.hasPresence ? View.VISIBLE : View.GONE); statusText.setText(ci.status); statusImage.setVisibility(ci.hasPresence ? View.VISIBLE : View.GONE); statusImage.setImageResource(ContactsWrapper.getInstance().getPresenceIconResourceId(ci.presence)); } View v; v = view.findViewById(R.id.contact_view); v.setTag(ci); v.setOnClickListener(mPrimaryActionListener); v = view.findViewById(R.id.secondary_action_icon); v.setTag(ci); v.setOnClickListener(mSecondaryActionListener); } else if (type == ContactsWrapper.TYPE_CONFIGURE) { // We only bind if it's the correct type // View v = view.findViewById(R.id.configure_view); //v.setOnClickListener(this); //ConfigureObj cfg = new ConfigureObj(); // cfg.profileId = cv.getAsLong(BaseColumns._ID); // v.setTag(cfg); } }
From source file:at.bitfire.davdroid.resource.LocalCalendar.java
void populateReminder(Event event, ContentValues row) { VAlarm alarm = new VAlarm(new Dur(0, 0, -row.getAsInteger(Reminders.MINUTES), 0)); PropertyList props = alarm.getProperties(); props.add(Action.DISPLAY);//from ww w . jav a 2 s . c o m props.add(new Description(event.summary)); event.getAlarms().add(alarm); }
From source file:com.granita.icloudcalsync.resource.LocalCalendar.java
void populateReminder(Event event, ContentValues row) throws RemoteException { VAlarm alarm = new VAlarm(new Dur(0, 0, -row.getAsInteger(Reminders.MINUTES), 0)); PropertyList props = alarm.getProperties(); props.add(Action.DISPLAY);//from ww w . jav a 2 s. com props.add(new Description(event.getSummary())); event.getAlarms().add(alarm); }
From source file:com.money.manager.ex.reports.CategoriesReportFragment.java
private CategorySub getCategoryFromSelectedItem(ListView l, int position) { // Reading item from the list view, not adapter! Object item = l.getItemAtPosition(position); if (item == null) return null; Cursor cursor = (Cursor) item; ContentValues values = new ContentValues(); DatabaseUtils.cursorIntToContentValues(cursor, ViewMobileData.CATEGID, values); DatabaseUtils.cursorStringToContentValues(cursor, ViewMobileData.Category, values); DatabaseUtils.cursorIntToContentValues(cursor, ViewMobileData.SubcategID, values); DatabaseUtils.cursorStringToContentValues(cursor, ViewMobileData.Subcategory, values); CategorySub result = new CategorySub(); result.categId = values.getAsInteger(ViewMobileData.CATEGID); result.categName = values.getAsString(ViewMobileData.Category); result.subCategId = values.getAsInteger(ViewMobileData.SubcategID); result.subCategName = values.getAsString(ViewMobileData.Subcategory); return result; }