List of usage examples for android.content ContentUris parseId
public static long parseId(Uri contentUri)
From source file:org.dmfs.webcal.fragments.CalendarItemFragment.java
@Override public Loader<Cursor> onCreateLoader(int loaderId, Bundle params) { Activity activity = getActivity();/*from www .j a va2 s .com*/ switch (loaderId) { case LOADER_CALENDAR_ITEM: return new CursorLoader(activity, mContentUri, PROJECTION, null, null, null); case LOADER_SUBSCRIBED_CALENDAR: return new CursorLoader(activity, SubscribedCalendars.getContentUri(activity), null, SubscribedCalendars.ITEM_ID + "=" + ContentUris.parseId(mContentUri), null, null); case LOADER_PREVIEW: // show the loader indicator delayed mHandler.postDelayed(mProgressIndicator, PROGRESS_INDICATOR_DELAY); if (mCalendarUrl != null) { return new CursorLoader(getActivity(), WebCalReaderContract.Events.getEventsUri(getActivity(), mCalendarUrl, 60 * 1000), null, null, null, null); } else { return null; } case LOADER_SUBSCRIPTION: return new CursorLoader(activity, PaymentStatus.getContentUri(activity), null, null, null, null); default: return null; } }
From source file:edu.cens.loci.ui.VisitDetailActivity.java
protected void onActivityResult(int requestCode, int resultCode, Intent data) { MyLog.d(LociConfig.D.UI.DEBUG, TAG,//from www . j av a 2 s. c o m "onActivityResult:" + String.format(" requestCode=%d resultCode=%d ", requestCode, resultCode)); if (data != null) MyLog.d(LociConfig.D.UI.DEBUG, TAG, "onActivityResult:" + data.toString()); switch (requestCode) { case SUBACTIVITY_ADD_PLACE: if (resultCode == RESULT_OK) { // created or add to existing place successfully. update visits' placeid. final long placeId = ContentUris.parseId(data.getData()); final long visitId = ContentUris.parseId(getIntent().getData()); MyLog.d(LociConfig.D.UI.DEBUG, TAG, "[Update] placeId=" + placeId + ", visitId=" + visitId); mDbUtils.updateVisitPlaceId(visitId, placeId); } break; case SUBACTIVITY_CHANGE_PLACE: if (resultCode == RESULT_OK) { // created or add to existing place successfully. update visits' placeid //MyLog.d(LociConfig.D.UI.DEBUG, TAG, "[VisitDetail] data:" + data.getData().toString()); final long placeId = ContentUris.parseId(data.getData()); final long visitId = ContentUris.parseId(getIntent().getData()); MyLog.d(LociConfig.D.UI.DEBUG, TAG, "[Update] placeId=" + placeId + ", visitId=" + visitId); mDbUtils.updateVisitPlaceId(visitId, placeId); } } }
From source file:at.bitfire.ical4android.AndroidEvent.java
public Uri update(Event event) throws CalendarStorageException { this.event = event; BatchOperation batch = new BatchOperation(calendar.provider); delete(batch);//w w w . j a v a 2s . c o m final int idxEvent = batch.nextBackrefIdx(); add(batch); batch.commit(); Uri uri = batch.getResult(idxEvent).uri; id = ContentUris.parseId(uri); return uri; }
From source file:com.silentcircle.contacts.group.GroupEditorFragment.java
public void load(String action, Uri groupUri, Bundle intentExtras) { mAction = action;//from w w w .j a v a 2 s . c o m mGroupUri = groupUri; mGroupId = (groupUri != null) ? ContentUris.parseId(mGroupUri) : 0; mIntentExtras = intentExtras; }
From source file:org.ohmage.activity.test.ResponseHistoryTest.java
public void testClickBalloon() { solo.clickOnText("MAP"); // click on the right arrow solo.clickOnText(">", 4); solo.clickOnText("urn:mock:campaign"); solo.assertCurrentActivity("Expected response info activity", ResponseInfoActivity.class); assertEquals(1, ContentUris.parseId(solo.getCurrentActivity().getIntent().getData())); solo.goBack();/*from w ww .j a v a 2 s.c om*/ }
From source file:org.gege.caldavsyncadapter.caldav.entities.DavCalendar.java
/** * removes the tag of all android events * @return/* w w w . ja v a 2 s. co m*/ * @see AndroidEvent#cInternalTag * @see SyncAdapter#synchroniseEvents(CaldavFacade, Account, ContentProviderClient, Uri, DavCalendar, SyncStats) * @throws RemoteException */ public int untagAndroidEvents() throws RemoteException { ContentValues values = new ContentValues(); values.put(Event.INTERNALTAG, 0); String mSelectionClause = "(" + Event.INTERNALTAG + " = ?) AND (" + Events.CALENDAR_ID + " = ?)"; String[] mSelectionArgs = { "1", Long.toString(ContentUris.parseId(this.getAndroidCalendarUri())) }; int RowCount = this.mProvider.update( asSyncAdapter(Events.CONTENT_URI, this.mAccount.name, this.mAccount.type), values, mSelectionClause, mSelectionArgs); //Log.d(TAG, "Rows reseted: " + RowCount.toString()); return RowCount; }
From source file:org.kontalk.data.Contact.java
private static byte[] loadAvatarData(Context context, Uri contactUri) { byte[] data = null; InputStream avatarDataStream; try {//from w ww .ja va 2 s.c om avatarDataStream = Contacts.openContactPhotoInputStream(context.getContentResolver(), contactUri); } catch (Exception e) { // fallback to old behaviour try { long cid = ContentUris.parseId(contactUri); Uri uri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, cid); avatarDataStream = Contacts.openContactPhotoInputStream(context.getContentResolver(), uri); } catch (Exception ignored) { // no way of getting avatar, sorry return null; } } if (avatarDataStream != null) { try { data = new byte[avatarDataStream.available()]; avatarDataStream.read(data, 0, data.length); } catch (IOException e) { Log.e(TAG, "cannot retrieve contact avatar", e); } finally { try { avatarDataStream.close(); } catch (IOException ignored) { } } } return data; }
From source file:org.gege.caldavsyncadapter.caldav.entities.DavCalendar.java
/** * Events not being tagged are for deletion * @return/*from ww w.j a v a 2s .c o m*/ * @see AndroidEvent#cInternalTag * @see SyncAdapter#synchroniseEvents(CaldavFacade, Account, ContentProviderClient, Uri, DavCalendar, SyncStats) * @throws RemoteException */ public int deleteUntaggedEvents() throws RemoteException { String mSelectionClause = "(" + Event.INTERNALTAG + "<> ?) AND (" + Events.CALENDAR_ID + " = ?)"; String[] mSelectionArgs = { "1", Long.toString(ContentUris.parseId(this.getAndroidCalendarUri())) }; int CountDeleted = this.mProvider.delete( asSyncAdapter(Events.CONTENT_URI, this.mAccount.name, this.mAccount.type), mSelectionClause, mSelectionArgs); //Log.d(TAG, "Rows deleted: " + CountDeleted.toString()); return CountDeleted; }
From source file:com.upenn.chriswang1990.sunshine.sync.SunshineSyncAdapter.java
/** * Helper method to handle insertion of a new location in the weather database. * * @param locationSetting The location string used to request updates from the server. * @param cityName A human-readable city name, e.g "Mountain View" * @param lat the latitude of the city * @param lon the longitude of the city * @param timezoneID timezone info of the city * @return the row ID of the added location. */// w w w . ja va 2 s .c o m long addLocation(String locationSetting, String cityName, double lat, double lon, String timezoneID) { // Students: First, check if the location with this city name exists in the db // If it exists, return the current ID // Otherwise, insert it using the content resolver and the base URI long locationId; Cursor locationCursor = getContext().getContentResolver().query(WeatherContract.LocationEntry.CONTENT_URI, new String[] { WeatherContract.LocationEntry._ID }, WeatherContract.LocationEntry.COLUMN_LOCATION_SETTING + " = ?", new String[] { locationSetting }, null); if (locationCursor != null && locationCursor.moveToFirst()) { int locationIdIndex = locationCursor.getColumnIndex(WeatherContract.LocationEntry._ID); locationId = locationCursor.getLong(locationIdIndex); locationCursor.close(); } else { ContentValues locationValues = new ContentValues(); locationValues.put(WeatherContract.LocationEntry.COLUMN_LOCATION_SETTING, locationSetting); locationValues.put(WeatherContract.LocationEntry.COLUMN_CITY_NAME, cityName); locationValues.put(WeatherContract.LocationEntry.COLUMN_COORD_LAT, lat); locationValues.put(WeatherContract.LocationEntry.COLUMN_COORD_LONG, lon); locationValues.put(WeatherContract.LocationEntry.COLUMN_TIMEZONE_ID, timezoneID); Uri locationUri = getContext().getContentResolver().insert(WeatherContract.LocationEntry.CONTENT_URI, locationValues); locationId = ContentUris.parseId(locationUri); } return locationId; }
From source file:com.android.tv.ui.TunableTvView.java
/** * Plays a recording./*from www . ja v a 2s .co m*/ */ public boolean playRecording(Uri recordingUri, OnTuneListener listener) { if (!mStarted) { throw new IllegalStateException("TvView isn't started"); } if (!CommonFeatures.DVR.isEnabled(getContext()) || !BuildCompat.isAtLeastN()) { return false; } if (DEBUG) Log.d(TAG, "playRecording " + recordingUri); long recordingId = ContentUris.parseId(recordingUri); mRecordedProgram = mDvrDataManager.getRecordedProgram(recordingId); if (mRecordedProgram == null) { Log.w(TAG, "No recorded program (Uri=" + recordingUri + ")"); return false; } String inputId = mRecordedProgram.getInputId(); TvInputInfo inputInfo = mInputManagerHelper.getTvInputInfo(inputId); if (inputInfo == null) { return false; } mOnTuneListener = listener; // mCurrentChannel can be null. mCurrentChannel = mChannelDataManager.getChannel(mRecordedProgram.getChannelId()); // For recording playback, input event should not be sent. mCanReceiveInputEvent = false; boolean needSurfaceSizeUpdate = false; if (!inputInfo.equals(mInputInfo)) { mInputInfo = inputInfo; if (DEBUG) { Log.d(TAG, "Input \'" + mInputInfo.getId() + "\' can receive input event: " + mCanReceiveInputEvent); } needSurfaceSizeUpdate = true; } mChannelViewTimer.start(); mVideoWidth = 0; mVideoHeight = 0; mVideoFormat = StreamInfo.VIDEO_DEFINITION_LEVEL_UNKNOWN; mVideoFrameRate = 0f; mVideoDisplayAspectRatio = 0f; mAudioChannelCount = StreamInfo.AUDIO_CHANNEL_COUNT_UNKNOWN; mHasClosedCaption = false; mTvView.setCallback(mCallback); mTimeShiftCurrentPositionMs = INVALID_TIME; mTvView.setTimeShiftPositionCallback(null); setTimeShiftAvailable(false); mTvView.timeShiftPlay(inputId, recordingUri); if (needSurfaceSizeUpdate && mFixedSurfaceWidth > 0 && mFixedSurfaceHeight > 0) { // When the input is changed, TvView recreates its SurfaceView internally. // So we need to call SurfaceHolder.setFixedSize for the new SurfaceView. getSurfaceView().getHolder().setFixedSize(mFixedSurfaceWidth, mFixedSurfaceHeight); } hideScreenByVideoAvailability(TvInputManager.VIDEO_UNAVAILABLE_REASON_TUNING); unblockScreenByContentRating(); if (mParentControlEnabled) { mBlockScreenForTuneView.setVisibility(View.VISIBLE); } if (mOnTuneListener != null) { mOnTuneListener.onStreamInfoChanged(this); } return true; }