Example usage for android.net Uri withAppendedPath

List of usage examples for android.net Uri withAppendedPath

Introduction

In this page you can find the example usage for android.net Uri withAppendedPath.

Prototype

public static Uri withAppendedPath(Uri baseUri, String pathSegment) 

Source Link

Document

Creates a new Uri by appending an already-encoded path segment to a base Uri.

Usage

From source file:org.droid2droid.ui.contacts.AbstractSMSFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    Uri baseUri;/* w w  w . j  a  va  2s . co m*/
    if (mCurFilter != null) {
        baseUri = Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI, Uri.encode(mCurFilter));
    } else {
        baseUri = Contacts.CONTENT_URI;
    }
    // Now create and return a CursorLoader that will take care of
    // creating a Cursor for the data being displayed.
    String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND (" + Contacts.HAS_PHONE_NUMBER + "=1) AND ("
            + Contacts.DISPLAY_NAME + " != '' ))";
    if (D)
        Log.d(TAG_SMS, PREFIX_LOG + "baseURI=" + baseUri);
    if (D)
        Log.d(TAG_SMS, PREFIX_LOG + "select=" + select);
    return new CursorLoader(getActivity(), baseUri, CONTACTS_PROJECTION, select, null,
            Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC");
}

From source file:com.bydavy.card.receipts.fragments.ReceiptFragment.java

@Override
public void onCheckedChanged(CompoundButton buttonView, final boolean isChecked) {
    final long receiptId = getReceiptId();
    // TODO execute it outside the UIThread ?! On GNexus takes 5-15ms.
    // A simple Thread is a bad implementation, a thread with a queue that
    // execute sequentially tasks is a better implementation
    final ContentValues values = new ContentValues();
    values.put(Receipts.COLUMN_NAME_VERIFIED, isChecked);
    final Uri uri = Uri.withAppendedPath(Receipts.CONTENT_URI, String.valueOf(receiptId));
    final int rows = getActivity().getContentResolver().update(uri, values, null, null);
    if (rows != 1) {
        LogHelper.e(ErrorID.CONTENT_PROVIDER, "Impossible to update receipt " + receiptId, null);
    }/*w w  w  .j  a  v  a  2 s  .  c  om*/
}

From source file:com.navjagpal.fileshare.WebServer.java

private void sendFileContent(DefaultHttpServerConnection serverConnection, RequestLine requestLine)
        throws IOException, HttpException {
    HttpResponse response = new BasicHttpResponse(new HttpVersion(1, 1), 200, "OK");
    String fileId = getFileId(requestLine.getUri());
    addFileEntity(Uri.withAppendedPath(FileSharingProvider.Files.CONTENT_URI, fileId), response);
    serverConnection.sendResponseHeader(response);
    serverConnection.sendResponseEntity(response);
}

From source file:com.shafiq.myfeedle.core.MyfeedleNotifications.java

@Override
protected void onListItemClick(ListView list, final View view, int position, final long id) {
    super.onListItemClick(list, view, position, id);
    // load MyfeedleComments.java, the notification will be clear there
    startActivityForResult(/*w ww .j av a2s  . c o  m*/
            Myfeedle.getPackageIntent(this, MyfeedleComments.class)
                    .setData(Uri.withAppendedPath(Notifications.getContentUri(this), Long.toString(id))),
            RESULT_REFRESH);
}

From source file:edu.nd.darts.cimon.database.CimonDatabaseAdapter.java

/**
 * Delete metrics from Metrics table matching a specified group.
 * /*from  w  w w. java 2  s.  co  m*/
 * @param group    id of metric group to remove
 * @return    number of rows deleted
 * 
 * @see MetricsTable
 */
public synchronized int deleteMetrics(int group) {
    if (DebugLog.DEBUG)
        Log.d(TAG, "CimonDatabaseAdapter.deleteMetrics - delete from Metrics table: group-" + group);
    int rowsdeleted = database.delete(MetricsTable.TABLE_METRICS, MetricsTable.COLUMN_INFO_ID + " = " + group,
            null);
    Uri uri = Uri.withAppendedPath(CimonContentProvider.GRP_METRICS_URI, String.valueOf(group));
    context.getContentResolver().notifyChange(uri, null);
    return rowsdeleted;
}

From source file:inc.bait.jubilee.ui.fragments.ContactsListFragment.java

private Bitmap loadContactPhotoThumbnail(String photoData, int imageSize) {
    if (!isAdded() || getActivity() == null) {
        return null;
    }//from  ww w  .  j  ava  2 s .c  o m
    AssetFileDescriptor afd = null;
    try {
        Uri thumbUri;
        if (ApiHelper.hasHoneycomb()) {
            thumbUri = Uri.parse(photoData);
        } else {
            final Uri contactUri = Uri.withAppendedPath(Contacts.CONTENT_URI, photoData);
            thumbUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY);
        }
        afd = getActivity().getContentResolver().openAssetFileDescriptor(thumbUri, "r");
        FileDescriptor fileDescriptor = afd.getFileDescriptor();

        if (fileDescriptor != null) {
            return ImgLoader.decodeSampledBitmapFromDescriptor(fileDescriptor, imageSize, imageSize);
        }
    } catch (FileNotFoundException e) {
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "Contact photo thumbnail not found for contact " + photoData + ": " + e.toString());
        }
    } finally {
        if (afd != null) {
            try {
                afd.close();
            } catch (IOException e) {
            }
        }
    }
    return null;
}

From source file:it.sineo.android.tileMapEditor.HomeActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == C.REQ_CODE_NEW_MAP) {
        if (resultCode == RESULT_OK && data != null) {
            String mapJSON = data.getStringExtra(C.EXTRA_MAP_JSON);
            TileMap map = new TileMap(mapJSON);

            ContentValues values = new ContentValues();
            values.put(TileMap.Columns.KEY_NAME, map.name);
            values.put(TileMap.Columns.KEY_JSON_DATA, mapJSON);
            values.put(TileMap.Columns.KEY_THUMB, data.getByteArrayExtra(C.EXTRA_MAP_THUMB));
            getContentResolver().insert(C.CONTENT_URI, values);
        }/*from   w  w w .java2  s .  co m*/
        Log.d(TAG, "received code " + resultCode + " w/ data: " + data);
    } else if (requestCode == C.REQ_CODE_EDIT_MAP) {
        if (resultCode == RESULT_OK && data != null) {
            String mapJSON = data.getStringExtra(C.EXTRA_MAP_JSON);
            long id = data.getLongExtra(C.EXTRA_MAP_ID, -1);
            TileMap map = new TileMap(mapJSON);
            ContentValues values = new ContentValues();
            values.put(TileMap.Columns.KEY_NAME, map.name);
            values.put(TileMap.Columns.KEY_JSON_DATA, mapJSON);
            values.put(TileMap.Columns.KEY_THUMB, data.getByteArrayExtra(C.EXTRA_MAP_THUMB));
            Uri mapUri = Uri.withAppendedPath(C.CONTENT_URI, Long.toString(id));
            getContentResolver().update(mapUri, values, null, null);
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.google.android.apps.paco.NotificationCreator.java

private Notification createNotification(Context context, Experiment experiment,
        NotificationHolder notificationHolder, String message) {
    int icon = R.drawable.paco32;

    String tickerText = context.getString(R.string.time_for_notification_title) + experiment.getTitle();
    if (notificationHolder.isCustomNotification()) {
        tickerText = message;/*ww  w  .j  a  va  2s. c o m*/
    }

    //Notification notification = new Notification(icon, tickerText, notificationHolder.getAlarmTime());

    Intent surveyIntent = new Intent(context, ExperimentExecutor.class);
    surveyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    Uri uri = Uri.withAppendedPath(ExperimentColumns.JOINED_EXPERIMENTS_CONTENT_URI,
            experiment.getId().toString());
    surveyIntent.setData(uri);
    surveyIntent.putExtra(Experiment.SCHEDULED_TIME, notificationHolder.getAlarmTime());
    surveyIntent.putExtra(NOTIFICATION_ID, notificationHolder.getId().longValue());

    PendingIntent notificationIntent = PendingIntent.getActivity(context, 1, surveyIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    // new wearable compatible way to do it
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context).setSmallIcon(icon)
            .setContentTitle(experiment.getTitle()).setTicker(tickerText).setContentText(message)
            .setWhen(notificationHolder.getAlarmTime()).setContentIntent(notificationIntent)
            .setAutoCancel(true);

    int defaults = Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS;
    String ringtoneUri = new UserPreferences(context).getRingtone();
    if (ringtoneUri != null) {
        notificationBuilder.setSound(Uri.parse(ringtoneUri));
    } else {
        defaults |= Notification.DEFAULT_SOUND;
        //    notification.sound = Uri.parse(android.os.Environment.getExternalStorageDirectory().getAbsolutePath()
        //                                   + "/Android/data/" + context.getPackageName() + "/" +
        //                                   "deepbark_trial.mp3");
    }
    notificationBuilder.setDefaults(defaults);

    //end wearable

    return notificationBuilder.build();
}

From source file:com.ultramegasoft.flavordex2.fragment.ViewInfoFragment.java

@SuppressWarnings("ConstantConditions")
@NonNull/*  w  w  w  . j a  va 2  s .c o m*/
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    final Context context = getContext();
    if (context == null) {
        return null;
    }

    Uri uri = ContentUris.withAppendedId(Tables.Entries.CONTENT_ID_URI_BASE, mEntryId);
    switch (id) {
    case LOADER_MAIN:
        return new CursorLoader(context, uri, null, null, null, null);
    case LOADER_EXTRAS:
        uri = Uri.withAppendedPath(uri, "extras");
        return new CursorLoader(context, uri, null, null, null, Tables.EntriesExtras.EXTRA + " ASC");
    }

    return null;
}

From source file:nl.sogeti.android.gpstracker.viewer.LoggerMap.java

@Override
protected void onResume() {
    super.onResume();
    mLoggerServiceManager.startup(this, mServiceConnected);

    mSharedPreferences.registerOnSharedPreferenceChangeListener(mSharedPreferenceChangeListener);
    mUnits.setUnitsChangeListener(mUnitsChangeListener);
    updateTitleBar();//  w  w  w .  jav  a 2  s  .c om
    updateBlankingBehavior();
    restoreMap();

    if (mTrackId >= 0) {
        ContentResolver resolver = this.getContentResolver();
        Uri trackUri = Uri.withAppendedPath(Tracks.CONTENT_URI, mTrackId + "/segments");
        Uri lastSegmentUri = Uri.withAppendedPath(Tracks.CONTENT_URI,
                mTrackId + "/segments/" + mLastSegment + "/waypoints");
        Uri mediaUri = ContentUris.withAppendedId(Media.CONTENT_URI, mTrackId);

        resolver.unregisterContentObserver(this.mTrackSegmentsObserver);
        resolver.unregisterContentObserver(this.mSegmentWaypointsObserver);
        resolver.unregisterContentObserver(this.mTrackMediasObserver);
        resolver.registerContentObserver(trackUri, false, this.mTrackSegmentsObserver);
        resolver.registerContentObserver(lastSegmentUri, true, this.mSegmentWaypointsObserver);
        resolver.registerContentObserver(mediaUri, true, this.mTrackMediasObserver);
    }
    updateDataOverlays();

    updateSpeedColoring();
    updateSpeedDisplayVisibility();
    updateAltitudeDisplayVisibility();
    updateDistanceDisplayVisibility();
    updateCompassDisplayVisibility();
    updateLocationDisplayVisibility();

}