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.openerp.support.calendar.OECalendar.java

/**
 * As sync adapter.//from   w  ww .j a  v a2  s .  com
 * 
 * @param uri
 *            : uri of the calendar
 * @param account
 *            : with OpenERP Mobile Calendar created
 * @param accountType
 *            : with OpenERP Mobile Calendar created
 * @return uri : with uri + account + accounttype
 */
private Uri asSyncAdapter(Uri uri, String account, String accountType) {
    return uri.buildUpon().appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true")
            .appendQueryParameter(Calendars.ACCOUNT_NAME, account)
            .appendQueryParameter(Calendars.ACCOUNT_TYPE, accountType).build();
}

From source file:edu.stanford.mobisocial.dungbeetle.DungBeetleContentProvider.java

private Uri uriWithId(Uri uri, long id) {
    Uri.Builder b = uri.buildUpon();
    b.appendPath(String.valueOf(id));
    return b.build();
}

From source file:com.android.contacts.common.ContactPhotoManager.java

/**
 * Adds a business contact type encoded fragment to the URL.  Used to ensure photo URLS
 * from Nearby Places can be identified as business photo URLs rather than URLs for personal
 * contact photos./*from   w ww .j  a  v  a 2 s . co m*/
 *
 * @param photoUrl The photo URL to modify.
 * @return URL with the contact type parameter added and set to TYPE_BUSINESS.
 */
public static String appendBusinessContactType(String photoUrl) {
    Uri uri = Uri.parse(photoUrl);
    Builder builder = uri.buildUpon();
    builder.encodedFragment(String.valueOf(TYPE_BUSINESS));
    return builder.build().toString();
}

From source file:org.andstatus.app.net.social.pumpio.ConnectionPumpio.java

@NonNull
private List<MbUser> getUsers(String userId, ApiRoutineEnum apiRoutine) throws ConnectionException {
    int limit = 200;
    ConnectionAndUrl conu = getConnectionAndUrl(apiRoutine, userId);
    Uri sUri = Uri.parse(conu.url);
    Uri.Builder builder = sUri.buildUpon();
    if (fixedDownloadLimitForApiRoutine(limit, apiRoutine) > 0) {
        builder.appendQueryParameter("count",
                String.valueOf(fixedDownloadLimitForApiRoutine(limit, apiRoutine)));
    }// w  w w  .j av  a2  s. co  m
    String url = builder.build().toString();
    JSONArray jArr = conu.httpConnection.getRequestAsArray(url);
    List<MbUser> users = new ArrayList<>();
    if (jArr != null) {
        for (int index = 0; index < jArr.length(); index++) {
            try {
                JSONObject jso = jArr.getJSONObject(index);
                MbUser item = userFromJson(jso);
                users.add(item);
            } catch (JSONException e) {
                throw ConnectionException.loggedJsonException(this, "Parsing list of users", e, null);
            }
        }
    }
    MyLog.d(TAG, apiRoutine + " '" + url + "' " + users.size() + " users");
    return users;
}

From source file:org.andstatus.app.net.social.pumpio.ConnectionPumpio.java

@Override
public List<MbTimelineItem> getTimeline(ApiRoutineEnum apiRoutine, TimelinePosition sinceId, int limit,
        String userId) throws ConnectionException {
    ConnectionAndUrl conu = getConnectionAndUrl(apiRoutine, userId);
    Uri sUri = Uri.parse(conu.url);
    Uri.Builder builder = sUri.buildUpon();
    if (!sinceId.isEmpty()) {
        // The "since" should point to the "Activity" on the timeline, not to the message
        // Otherwise we will always get "not found"
        builder.appendQueryParameter("since", sinceId.getPosition());
    }/*from w w w.j a  v  a2s  . c om*/
    if (fixedDownloadLimitForApiRoutine(limit, apiRoutine) > 0) {
        builder.appendQueryParameter("count",
                String.valueOf(fixedDownloadLimitForApiRoutine(limit, apiRoutine)));
    }
    String url = builder.build().toString();
    JSONArray jArr = conu.httpConnection.getRequestAsArray(url);
    List<MbTimelineItem> timeline = new ArrayList<>();
    if (jArr != null) {
        // Read the activities in chronological order
        for (int index = jArr.length() - 1; index >= 0; index--) {
            try {
                JSONObject jso = jArr.getJSONObject(index);
                MbTimelineItem item = timelineItemFromJson(jso);
                timeline.add(item);
            } catch (JSONException e) {
                throw ConnectionException.loggedJsonException(this, "Parsing timeline", e, null);
            }
        }
    }
    MyLog.d(TAG, "getTimeline '" + url + "' " + timeline.size() + " messages");
    return timeline;
}

From source file:com.mobicage.rogerthat.plugins.friends.RecommendServiceActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.recommend_service);

    mViewFlipper = (ViewFlipper) findViewById(R.id.view_flipper);

    if (!AppConstants.FRIENDS_ENABLED) {
        LinearLayout rtf = (LinearLayout) findViewById(R.id.recommend_to_friends);
        mViewFlipper.removeView(rtf);/*from w w w.  j  a  va2s.  co  m*/

        RelativeLayout rl = (RelativeLayout) findViewById(R.id.rogerthat_layout);
        rl.setVisibility(View.GONE);

        View ci = findViewById(R.id.contacts_indicator);
        ci.setVisibility(View.VISIBLE);
    }

    if (AppConstants.FACEBOOK_APP_ID == null) {
        LinearLayout rof = (LinearLayout) findViewById(R.id.recommend_on_fb);
        mViewFlipper.removeView(rof);

        RelativeLayout fl = (RelativeLayout) findViewById(R.id.facebook_layout);
        fl.setVisibility(View.GONE);
    }

    Swiper leftSwiper = new Swiper() {
        @Override
        public Intent onSwipe() {
            int i = mViewFlipper.getDisplayedChild() + 1;
            if (i < mViewFlipper.getChildCount()) {
                displayTab(i);
            }
            return null;
        }
    };
    Swiper rightSwiper = new Swiper() {
        @Override
        public Intent onSwipe() {
            int i = mViewFlipper.getDisplayedChild();
            if (i > 0) {
                displayTab(i - 1);
            }
            return null;
        }
    };
    mGestureScanner = new GestureDetector(new Slider(this, this, leftSwiper, rightSwiper));

    Intent intent = getIntent();
    mServiceEmail = intent.getStringExtra(SERVICE_EMAIL);
    mShareDescription = intent.getStringExtra(SHARE_DESCRIPTION);
    mShareCaption = intent.getStringExtra(SHARE_CAPTION);

    Uri shareLinkUrl = Uri.parse(intent.getStringExtra(SHARE_LINK_URL));
    Builder b = shareLinkUrl.buildUpon();
    b.appendQueryParameter("from", "phone");
    b.appendQueryParameter("target", "fbwall");
    b.build();
    mShareLinkUrl = b.toString();

    mShareImageUrl = intent.getStringExtra(SHARE_IMAGE_URL);

    mUiHelper = new UiLifecycleHelper(this, null);
    mUiHelper.onCreate(savedInstanceState);
}

From source file:com.android.emailcommon.provider.EmailContent.java

static public Uri uriWithLimit(Uri uri, int limit) {
    return uri.buildUpon().appendQueryParameter(EmailContent.PARAMETER_LIMIT, Integer.toString(limit)).build();
}

From source file:com.android.music.AlbumBrowserFragment.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;/*from ww  w . j a v a  2s  .  c o m*/
    if (mArtistId != null) {
        Uri uri = MediaStore.Audio.Artists.Albums.getContentUri("external", Long.valueOf(mArtistId));
        if (!TextUtils.isEmpty(filter)) {
            uri = uri.buildUpon().appendQueryParameter("filter", Uri.encode(filter)).build();
        }
        if (async != null) {
            async.startQuery(0, null, uri, cols, null, null, MediaStore.Audio.Albums.DEFAULT_SORT_ORDER);
        } else {
            ret = MusicUtils.query(getActivity(), uri, cols, null, null,
                    MediaStore.Audio.Albums.DEFAULT_SORT_ORDER);
        }
    } else {
        Uri uri = MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI;
        if (!TextUtils.isEmpty(filter)) {
            uri = uri.buildUpon().appendQueryParameter("filter", Uri.encode(filter)).build();
        }
        if (async != null) {
            async.startQuery(0, null, uri, cols, null, null, MediaStore.Audio.Albums.DEFAULT_SORT_ORDER);
        } else {
            ret = MusicUtils.query(getActivity(), uri, cols, null, null,
                    MediaStore.Audio.Albums.DEFAULT_SORT_ORDER);
        }
    }
    return ret;
}

From source file:com.android.music.ArtistAlbumBrowserFragment.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();
    }/* ww  w  . jav  a 2  s  .c  om*/

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

From source file:com.brandroidtools.filemanager.activities.PickerActivity.java

private Uri getResultUriForFileFromIntent(File src, Intent intent) {
    Uri result = Uri.fromFile(src);

    if (Intent.ACTION_PICK.equals(intent.getAction()) && intent.getData() != null) {
        String scheme = intent.getData().getScheme();
        if (scheme != null) {
            result = result.buildUpon().scheme(scheme).build();
        }//  w  w  w .j  a va2 s  . co  m
    }

    return result;
}