Android Open Source - wonderpush-android-sdk Wonder Push Request Params Decorator






From Project

Back to project page wonderpush-android-sdk.

License

The source code is released under:

Apache License

If you think the Android project wonderpush-android-sdk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.wonderpush.sdk;
/*from   www  .j  ava  2  s  . c  o m*/
import android.location.Location;

/**
 * A static helper class that will add parameters to a {@link WonderPush.RequestParams} object depending on the resource
 * path and user configuration of the {@link WonderPush} object.
 */
class WonderPushRequestParamsDecorator {

    protected static void decorate(String resource, WonderPush.RequestParams params) {
        // Always add lang
        addParameterIfAbsent(params, "lang", WonderPush.getLang());

        // Always add location
        addParameterIfAbsent(params, "location", WonderPush.getLocation());

        // Always add the sdk version
        addParameterIfAbsent(params, "sdkVersion", WonderPush.SDK_VERSION);

        // Add the SID for web resources
        if (resource.startsWith("/web"))
            params.put("sid", WonderPushConfiguration.getSID());
    }

    private static void addParameterIfAbsent(WonderPush.RequestParams params, String paramName, String paramValue) {
        if (null == params || null == paramName || null == paramValue)
            return;

        if (params.has(paramName))
            return;

        params.put(paramName, paramValue);
    }

    private static void addParameterIfAbsent(WonderPush.RequestParams params, String paramName, Location paramValue) {
        if (null == paramValue)
            return;

        addParameterIfAbsent(params, paramName, "" + paramValue.getLatitude() + "," + paramValue.getLongitude());
    }

}




Java Source Code List

com.wonderpush.sdk.QueryStringParser.java
com.wonderpush.sdk.WonderPushBroadcastReceiver.java
com.wonderpush.sdk.WonderPushCompatibilityHelper.java
com.wonderpush.sdk.WonderPushConfiguration.java
com.wonderpush.sdk.WonderPushDialogBuilder.java
com.wonderpush.sdk.WonderPushGcmClient.java
com.wonderpush.sdk.WonderPushInitializer.java
com.wonderpush.sdk.WonderPushJobQueue.java
com.wonderpush.sdk.WonderPushOnUpgradeReceiver.java
com.wonderpush.sdk.WonderPushRequestParamsDecorator.java
com.wonderpush.sdk.WonderPushRequestVault.java
com.wonderpush.sdk.WonderPushRestClient.java
com.wonderpush.sdk.WonderPushService.java
com.wonderpush.sdk.WonderPushUriHelper.java
com.wonderpush.sdk.WonderPushView.java
com.wonderpush.sdk.WonderPush.java
com.wonderpush.sdk.package-info.java