Example usage for android.net Uri buildUpon

List of usage examples for android.net Uri buildUpon

Introduction

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

Prototype

public abstract Builder buildUpon();

Source Link

Document

Constructs a new builder, copying the attributes from this Uri.

Usage

From source file:com.dmplayer.childfragment.ChildFragmentArtists.java

private Cursor getArtistCursor(AsyncQueryHandler async, String filter) {

    String[] cols = new String[] { MediaStore.Audio.Artists._ID, MediaStore.Audio.Artists.ARTIST,
            MediaStore.Audio.Artists.NUMBER_OF_ALBUMS, MediaStore.Audio.Artists.NUMBER_OF_TRACKS };

    Uri uri = MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI;
    if (!TextUtils.isEmpty(filter)) {
        uri = uri.buildUpon().appendQueryParameter("filter", Uri.encode(filter)).build();
    }// www  . java  2s .  c om

    Cursor ret = null;
    if (async != null) {
        async.startQuery(0, null, uri, cols, null, null, MediaStore.Audio.Artists.ARTIST_KEY);
    } else {
        ret = DMPlayerUtility.query(getActivity(), uri, cols, null, null, MediaStore.Audio.Artists.ARTIST_KEY);
    }
    return ret;
}

From source file:co.codecrunch.musicplayerlite.childfragment.ChildFragmentArtists.java

private Cursor getArtistCursor(AsyncQueryHandler async, String filter) {

    String[] cols = new String[] { MediaStore.Audio.Artists._ID, MediaStore.Audio.Artists.ARTIST,
            MediaStore.Audio.Artists.NUMBER_OF_ALBUMS, MediaStore.Audio.Artists.NUMBER_OF_TRACKS };

    Uri uri = MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI;
    if (!TextUtils.isEmpty(filter)) {
        uri = uri.buildUpon().appendQueryParameter("filter", Uri.encode(filter)).build();
    }//from  w  w  w . ja v  a  2  s  .com

    Cursor ret = null;
    if (async != null) {
        async.startQuery(0, null, uri, cols, null, null, MediaStore.Audio.Artists.ARTIST_KEY);
    } else {
        ret = MusicPlayerUtility.query(getActivity(), uri, cols, null, null,
                MediaStore.Audio.Artists.ARTIST_KEY);
    }
    return ret;
}

From source file:org.sufficientlysecure.keychain.remote.ui.dialog.RemoteSelectAuthenticationKeyActivity.java

private void onKeySelected(long masterKeyId) {
    Intent callingIntent = getIntent();//ww w  . ja  v  a 2  s.  co m
    Intent originalIntent = callingIntent.getParcelableExtra(RemoteSecurityTokenOperationActivity.EXTRA_DATA);

    Uri appUri = callingIntent.getData();

    Uri allowedKeysUri = appUri.buildUpon().appendPath(KeychainContract.PATH_ALLOWED_KEYS).build();

    ApiDataAccessObject apiDao = new ApiDataAccessObject(getBaseContext());
    apiDao.addAllowedKeyIdForApp(allowedKeysUri, masterKeyId);

    originalIntent.putExtra(SshAuthenticationApi.EXTRA_KEY_ID, String.valueOf(masterKeyId));

    setResult(RESULT_OK, originalIntent);
    finish();
}

From source file:in.risysnetworks.shplayer.fragments.childfragment.ChildFragmentArtists.java

private Cursor getArtistCursor(AsyncQueryHandler async, String filter) {

    String[] cols = new String[] { MediaStore.Audio.Artists._ID, MediaStore.Audio.Artists.ARTIST,
            MediaStore.Audio.Artists.NUMBER_OF_ALBUMS, MediaStore.Audio.Artists.NUMBER_OF_TRACKS };

    Uri uri = MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI;
    if (!TextUtils.isEmpty(filter)) {
        uri = uri.buildUpon().appendQueryParameter("filter", Uri.encode(filter)).build();
    }/*from  www.ja v a  2  s  .co m*/

    Cursor ret = null;
    if (async != null) {
        async.startQuery(0, null, uri, cols, null, null, MediaStore.Audio.Artists.ARTIST_KEY);
    } else {
        ret = SHPlayerUtility.query(getActivity(), uri, cols, null, null, MediaStore.Audio.Artists.ARTIST_KEY);
    }
    return ret;
}

From source file:in.risysnetworks.shplayer.fragments.childfragment.ChildFragmentAlbum.java

private Cursor getAlbumCursor(AsyncQueryHandler async, String filter) {
    String[] cols = new String[] { MediaStore.Audio.Albums._ID, MediaStore.Audio.Albums.ARTIST,
            MediaStore.Audio.Albums.ALBUM, MediaStore.Audio.Albums.ALBUM_ART };

    Cursor ret = null;/*w  ww  .j a v a  2  s .  c  o  m*/
    Uri uri = MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI;
    if (!TextUtils.isEmpty(filter)) {
        uri = uri.buildUpon().appendQueryParameter("filter", Uri.encode(filter)).build();
    }
    if (async != null) {

        System.out.println(" async != null ");

        async.startQuery(0, null, uri, cols, null, null, MediaStore.Audio.Albums.DEFAULT_SORT_ORDER);
    } else {

        System.out.println(" async == null ");

        ret = SHPlayerUtility.query(getActivity(), uri, cols, null, null,
                MediaStore.Audio.Albums.DEFAULT_SORT_ORDER);
    }
    return ret;
}

From source file:com.xorcode.andtweet.net.ConnectionOAuth.java

/**
 * Universal method for several Timelines...
 * //from w w  w. j a  v a  2 s . co m
 * @param url URL predefined for this timeline
 * @param sinceId
 * @param maxId
 * @param limit
 * @param page
 * @return
 * @throws ConnectionException
 */
private JSONArray getTimeline(String url, long sinceId, long maxId, int limit, int page)
        throws ConnectionException {
    setSinceId(sinceId);
    setLimit(limit);

    boolean ok = false;
    JSONArray jArr = null;
    try {
        Uri sUri = Uri.parse(url);
        Uri.Builder builder = sUri.buildUpon();
        if (getSinceId() != 0) {
            builder.appendQueryParameter("since_id", String.valueOf(getSinceId()));
        } else if (maxId != 0) { // these are mutually exclusive
            builder.appendQueryParameter("max_id", String.valueOf(maxId));
        }
        if (getLimit() != 0) {
            builder.appendQueryParameter("count", String.valueOf(getLimit()));
        }
        if (page != 0) {
            builder.appendQueryParameter("page", String.valueOf(page));
        }
        HttpGet get = new HttpGet(builder.build().toString());
        mConsumer.sign(get);
        String response = mClient.execute(get, new BasicResponseHandler());
        jArr = new JSONArray(response);
        ok = (jArr != null);
    } catch (NullPointerException e) {
        // It looks like a bug in the library, but we have to catch it 
        Log.e(TAG, "NullPointerException was caught, URL='" + url + "'");
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
        throw new ConnectionException(e.getLocalizedMessage());
    }
    if (MyLog.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "getTimeline '" + url + "' " + (ok ? "OK, " + jArr.length() + " statuses" : "FAILED"));
    }
    return jArr;
}

From source file:org.awesomeapp.messenger.ui.GalleryListFragment.java

private void setupRecyclerView(RecyclerView recyclerView) {
    recyclerView.setLayoutManager(new LinearLayoutManager(recyclerView.getContext()));

    Uri baseUri = Imps.Messages.CONTENT_URI;

    if (mByContactId != -1)
        baseUri = Imps.Messages.getContentUriByThreadId(mByContactId);

    Uri.Builder builder = baseUri.buildUpon();
    mUri = builder.build();//from  ww w  .j ava2s .c  o m

    mLoaderManager = getLoaderManager();
    mLoaderCallbacks = new MyLoaderCallbacks();
    mLoaderManager.initLoader(mLoaderId, null, mLoaderCallbacks);

    Cursor cursor = null;
    mAdapter = new MessageListRecyclerViewAdapter(getActivity(), cursor);

    if (mAdapter.getItemCount() == 0) {
        mRecView.setVisibility(View.GONE);

        if (mByContactId == -1) {
            mEmptyView.setVisibility(View.VISIBLE);
            mEmptyViewImage.setVisibility(View.VISIBLE);
        } else {
            mEmptyView.setVisibility(View.GONE);
            mEmptyViewImage.setVisibility(View.GONE);
        }

    } else {
        mRecView.setVisibility(View.VISIBLE);
        mEmptyView.setVisibility(View.GONE);
        mEmptyViewImage.setVisibility(View.GONE);

    }

}

From source file:at.bitfire.davdroid.resource.LocalCollection.java

/** Appends account type, name and CALLER_IS_SYNCADAPTER to an Uri. */
protected Uri syncAdapterURI(Uri baseURI) {
    return baseURI.buildUpon().appendQueryParameter(entryColumnAccountType(), account.type)
            .appendQueryParameter(entryColumnAccountName(), account.name)
            .appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true").build();
}

From source file:org.mobisocial.corral.ContentCorral.java

private static Uri getAbsoluteUri(Uri baseUri, String parentFile, String src) {
    if (src.startsWith("/")) {
        return baseUri.buildUpon().path(src).build();
    }/*from w w w .jav  a 2s  . co m*/

    Uri.Builder builder = baseUri.buildUpon();
    String[] parentPath = parentFile.split("/");
    for (int i = 0; i < parentPath.length - 1; i++) {
        builder.appendPath(parentPath[i]);
    }

    String[] srcParts = src.split("/");
    for (String part : srcParts) {
        builder.appendPath(part);
    }
    return builder.build();
}

From source file:at.bitfire.davdroid.resource.LocalTaskList.java

@Override
protected Uri syncAdapterURI(Uri baseURI) {
    return baseURI.buildUpon().appendQueryParameter(entryColumnAccountType(), account.type)
            .appendQueryParameter(entryColumnAccountName(), account.name)
            .appendQueryParameter(TaskContract.CALLER_IS_SYNCADAPTER, "true").build();
}