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, Location location)
Add an end location to this context, this is useful for e.g.
static PlacementContext forEndLocation(String locationName, double latitude, double longitude)
String toString()
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.
PlacementContext withEndLocation(LatLngPair coordinate)
Add an end location to this context, this is useful for e.g.
PlacementContext withEndLocation(Location location)
Adds an end location to this promotion context.
PlacementContext withEndLocation(String locationName, LatLngPair coordinate)
Add an end location to this context, this is useful for e.g.
synchronized PlacementContext withStartLocation(String locationName, LatLngPair coordinate)
Creates a context with a freeform combination of location name and latitude/longitude pair as start location for a transportation pickup.
PlacementContext withStartLocation(Location location)
Adds a start location to context.
PlacementContext withStartLocation(String locationName, double latitude, double longitude)
Creates a context with a freeform combination of location name and latitude/longitude pair as start location for a transportation pickup.
PlacementContext withStartLocation(LatLngPair coordinate)
Creates a context with coordinate as start location for a transportation pickup.
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, Location location)

Add an end location to this context, this is useful for e.g. getting transportation to location, same as new PlacementContext().withEndLocation(...);.

Returns
  • the new context instance, for nested calls.

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

Returns
  • the new context instance, for nested calls.

public String toString ()

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 PlacementContext withEndLocation (LatLngPair coordinate)

Add an end location to this context, this is useful for e.g. getting transportation to location, same as new PlacementContext().withEndLocation(...);.

Parameters
coordinate LatLngPair object holding the latitude/longitude information.
Returns
  • same object, for nested calls.

public PlacementContext withEndLocation (Location location)

Adds an end location to this promotion context.

Returns
  • same object, for nested calls.

public PlacementContext withEndLocation (String locationName, LatLngPair coordinate)

Add an end location to this context, this is useful for e.g. getting transportation to location, same as new PlacementContext().withEndLocation(...);.

Parameters
coordinate LatLngPair object holding the latitude/longitude information.
Returns
  • same object, for nested calls.

public synchronized PlacementContext withStartLocation (String locationName, LatLngPair coordinate)

Creates a context with a freeform combination of location name and latitude/longitude pair as start location for a transportation pickup.

Returns
  • same object, for nested calls.

public PlacementContext withStartLocation (Location location)

Adds a start location to context.

Returns
  • same object, for nested calls.

public PlacementContext withStartLocation (String locationName, double latitude, double longitude)

Creates a context with a freeform combination of location name and latitude/longitude pair as start location for a transportation pickup.

Returns
  • same object, for nested calls.

public PlacementContext withStartLocation (LatLngPair coordinate)

Creates a context with coordinate as start location for a transportation pickup.

Returns
  • same object, for nested calls.

public void writeToParcel (Parcel dest, int flags)