Java Code Examples for android.net.Uri.Builder#toString()

The following examples show how to use android.net.Uri.Builder#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AdminClient.java    From StreamHub-Android-SDK with MIT License 6 votes vote down vote up
/**
 * Generates an auth endpoint with the specified parameters.
 *
 * @param userToken    The lftoken representing a user.
 * @param collectionId The Id of the collection to auth against.
 * @param articleId    The Id of the collection's article.
 * @param siteId       The Id of the article's site.
 * @return The auth endpoint with the specified parameters.
 * @throws UnsupportedEncodingException
 * @throws MalformedURLException
 */
public static String generateAuthEndpoint(String userToken,
                                          String collectionId,
                                          String articleId,
                                          String siteId) throws UnsupportedEncodingException {
    Builder uriBuilder = new Uri.Builder()
            .scheme(LivefyreConfig.scheme)
            .authority(LivefyreConfig.adminDomain + "." + LivefyreConfig.getConfiguredNetworkID())
            .appendPath("api")
            .appendPath("v3.0")
            .appendPath("auth")
            .appendPath("");

    if (collectionId != null) {
        uriBuilder.appendQueryParameter("collectionId", collectionId)
                .appendQueryParameter("lftoken", userToken);
    } else {
        final String article64 = Helpers.generateBase64String(articleId);
        uriBuilder.appendQueryParameter("siteId", siteId)
                .appendQueryParameter("articleId", article64)
                .appendQueryParameter("lftoken", userToken);
    }
    Log.d("Admin URL", "" + uriBuilder.toString());
    return uriBuilder.toString();
}
 
Example 2
Source File: BootstrapClient.java    From StreamHub-Android-SDK with MIT License 5 votes vote down vote up
/**
 * Generates a general bootstrap endpoint with the specified parameters.
 *
 * @param siteId    The Id of the article's site.
 * @param articleId The Id of the collection's article.
 * @param opts      Optional parameters to pass in. Currently takes in pageNumber param for Bootstrap page number.
 * @return The init endpoint with the specified parameters.
 * @throws UnsupportedEncodingException
 * @throws MalformedURLException
 */
public static String generateBootstrapEndpoint(String siteId,String articleId,Map<String, Object>... opts)throws UnsupportedEncodingException {
    // Casting
    final String article64 = Helpers.generateBase64String(articleId);

    // Build the URL
    Builder uriBuilder = new Uri.Builder()
            .scheme(LivefyreConfig.scheme)
            .authority(LivefyreConfig.bootstrapDomain + "." + LivefyreConfig.getConfiguredNetworkID())
            .appendPath("bs3")
            .appendPath("v3.1")
            .appendPath(LivefyreConfig.getConfiguredNetworkID())
            .appendPath(siteId)
            .appendPath(article64);

    if (opts.length <= 0) {
        uriBuilder.appendPath("init");
    } else {
        if (opts[0].get("pageNumber") instanceof Integer) {
            String page = opts[0].get("pageNumber").toString() + ".json";
            uriBuilder.appendPath(page);
        } else {
            throw new IllegalArgumentException("Bootstrap page number must be an Integer");
        }
    }

    return uriBuilder.toString();
}
 
Example 3
Source File: StreamClient.java    From StreamHub-Android-SDK with MIT License 5 votes vote down vote up
public static String generateStreamUrl(String collectionId, String eventId) throws MalformedURLException {
    final Builder uriBuilder = new Uri.Builder()
            .scheme(LivefyreConfig.scheme)
            .authority(
                    LivefyreConfig.streamDomain + "."
                            + LivefyreConfig.getConfiguredNetworkID())
            .appendPath("v3.1").appendPath("collection")
            .appendPath(collectionId).appendPath("").appendPath(eventId);

    return uriBuilder.toString();
}
 
Example 4
Source File: WriteClient.java    From StreamHub-Android-SDK with MIT License 5 votes vote down vote up
/**
 * @param collectionId The Id of the collection.
 * @param userToken    The token of the logged in user.
 * @param endpoint
 * @return
 * @throws MalformedURLException
 */
public static String generateWriteURL(
        String collectionId, String userToken, String endpoint)
        throws MalformedURLException {
    final Builder uriBuilder = new Uri.Builder().scheme(LivefyreConfig.scheme)
            .authority(LivefyreConfig.quillDomain + "." + LivefyreConfig.getConfiguredNetworkID())
            .appendPath("api").appendPath("v3.0").appendPath("collection")
            .appendPath(collectionId).appendPath("post");
    if (LFSConstants.LFSPostTypeReview == endpoint)
        uriBuilder.appendPath(endpoint).appendPath("");
    else
        uriBuilder.appendPath("");
    Log.d("Write URL", "" + uriBuilder.toString());
    return uriBuilder.toString();
}
 
Example 5
Source File: WriteClient.java    From StreamHub-Android-SDK with MIT License 5 votes vote down vote up
/**
 * @param collectionId The Id of the collection.
 * @param userToken    The token of the logged in user.
 * @param endpoint
 * @param networkID    Livefyre provided network name.
 * @return
 * @throws MalformedURLException
 */
public static String generateWriteURL(
        String collectionId, String userToken, String endpoint, String networkID)
        throws MalformedURLException {
    final Builder uriBuilder = new Uri.Builder().scheme(LivefyreConfig.scheme)
            .authority(LivefyreConfig.quillDomain + "." + networkID)
            .appendPath("api").appendPath("v3.0").appendPath("collection")
            .appendPath(collectionId).appendPath("post");
    if (LFSConstants.LFSPostTypeReview.equals(endpoint))
        uriBuilder.appendPath(endpoint).appendPath("");
    else
        uriBuilder.appendPath("");
    Log.d("Write URL", "" + uriBuilder.toString());
    return uriBuilder.toString();
}