public class

PlacementContext

extends Object
implements Parcelable
java.lang.Object
   ↳ com.usebutton.sdk.PlacementContext

Class Overview

Convenience class on top of JSONObject. Mutable key-value pairs with promotion relevant information. See ButtonDropin for a full example of a location aware context. Context parameters provided to promotions.

Summary

[Expand]
Inherited Constants
From interface android.os.Parcelable
Public Constructors
PlacementContext()
Public Methods
int describeContents()
static PlacementContext forEndLocation(String locationName, double latitude, double longitude)
Creates a new PlacementContext object with a location, this can be used for transportation promotions to indicate the drop off location.
static PlacementContext forStartLocation(String locationName, double latitude, double longitude)
Creates a new PlacementContext object with a location, this can be used for transportation promotions to indicate the pick up location.
synchronized PlacementContext putPrivate(String name, String value)
Reserved for future proofing the SDK so new top level keys can be used by partners without SDK changes.
synchronized PlacementContext with(String name, String value)
Add a String value to the context for key name, This will be added under the vendor top-level key.
synchronized PlacementContext with(String name, JSONObject value)
Add an arbitrary org.json.JSONObject value to the context for key name.
synchronized PlacementContext withEndLocation(String name, double latitude, double longitude)
PlacementContext withEndLocation(String name, Location location)
Adds a named end location to this promotion context.
synchronized PlacementContext withEndTime(Date endTime)
PlacementContext withStartLocation(String name, Location location)
Adds a start location to context.
synchronized PlacementContext withStartLocation(String name, double latitude, double longitude)
Adds a start location to context.
synchronized PlacementContext withStartTime(Date startTime)
synchronized PlacementContext withSubjectLocation(double latitude, double longitude)
void writeToParcel(Parcel dest, int flags)
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Public Constructors

public PlacementContext ()

Public Methods

public int describeContents ()

public static PlacementContext forEndLocation (String locationName, double latitude, double longitude)

Creates a new PlacementContext object with a location, this can be used for transportation promotions to indicate the drop off location. Equivalent to new PlacementContext().withEndLocation(...);.

Parameters
locationName for example "Pizza Restaurant"
Returns
  • the new context instance, for nested calls.

public static PlacementContext forStartLocation (String locationName, double latitude, double longitude)

Creates a new PlacementContext object with a location, this can be used for transportation promotions to indicate the pick up location. Equivalent to new PlacementContext().withStartLocation(...);.

Parameters
locationName for example "Work"
Returns
  • the new context instance, for nested calls.

public synchronized PlacementContext putPrivate (String name, String value)

Reserved for future proofing the SDK so new top level keys can be used by partners without SDK changes. You are probably looking for #putVendorValue(String, Object).

Returns
  • same object, for nesting.

public synchronized PlacementContext with (String name, String value)

Add a String value to the context for key name, This will be added under the vendor top-level key. {"vendor": {:name: :value}

public synchronized PlacementContext with (String name, JSONObject value)

Add an arbitrary org.json.JSONObject value to the context for key name. This will be added under the vendor top-level key. {"vendor": {:name: :value}

public synchronized PlacementContext withEndLocation (String name, double latitude, double longitude)

public PlacementContext withEndLocation (String name, Location location)

Adds a named end location to this promotion context.

Returns
  • same object, for nested calls.

public synchronized PlacementContext withEndTime (Date endTime)

public PlacementContext withStartLocation (String name, Location location)

Adds a start location to context.

Parameters
name of start location, for example "Office"
Returns
  • same object, for nested calls.

public synchronized PlacementContext withStartLocation (String name, double latitude, double longitude)

Adds a start location to context.

Returns
  • same object, for nested calls.

public synchronized PlacementContext withStartTime (Date startTime)

public synchronized PlacementContext withSubjectLocation (double latitude, double longitude)

public void writeToParcel (Parcel dest, int flags)