public class

ButtonDropin

extends FrameLayout
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ com.usebutton.sdk.ButtonDropin

Class Overview

This is the only UI class that you will have to drop into your layout XML to display a Button. It's important that you set a button ID in your layout XML, like show below. You find or create your button ID in the dashboard See Button for full instructions on how to initialize the SDK.

 <com.usebutton.sdk.ButtonDropin
           xmlns:button="http://schemas.android.com/apk/res-auto"
           android:layout_width="match_parent"
           android:layout_height="60dp"
           android:layout_margin="10dp"
           button:buttonId="your-button-id"
           button:textColor="@color/white"
           button:textSize="18dp"
       />
 
You will have to prepare the button with some context, e.g. the location information for a start or end location as shown in this example of an onCreate(Bundle)
    // Get the Button View
    final ButtonDropin buttonDropin = (ButtonDropin) findViewById(R.id.main_dropin);

   // Create a PlacementContext for the location you want a ride to.
   final PlacementContext context = PlacementContext.forEndLocation("Button HQ", 40.732561,-73.988068);
   final Location bestLocation = new LocationProvider(this).getBestLocation();
   if (bestLocation != null) {
      context.withStartLocation(new LatLngPair(bestLocation));
   }
   // Just to make sure we work on emulator etc, we'll use another place in NYC
   // comment out to use your current location from above
   context.withStartLocation(new LatLngPair(40.732561, -73.988068));

   // Prepare the Button for display with our context
   buttonDropin.prepareForDisplayWithContext(context); // OR:
   buttonDropin.prepareForDisplayWithContext(context, new ButtonDropin.Listener() {
      @Override
      public void onPrepared(final boolean willDisplay) {
          // Toggle visibility of UI items here if necessary
      }
   });
 

Summary

Nested Classes
interface ButtonDropin.Listener  
[Expand]
Inherited Constants
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
ButtonDropin(Context context)
ButtonDropin(Context context, AttributeSet attrs)
ButtonDropin(Context context, AttributeSet attrs, int defStyleAttr)
ButtonDropin(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
Public Methods
observable()
void prepareForDisplayWithContext(PlacementContext context, ButtonDropin.Listener listener)
This is where you prepare this ButtonDropin with a context so we can serve a highly customized button, depending on your use case.
void prepareForDisplayWithContext(PlacementContext context)
void refresh()
void setListener(ButtonDropin.Listener listener)
Set a permanent listener to observe changes in visibility for this promotion.
Protected Methods
void onAttachedToWindow()
void onDetachedFromWindow()
void onDraw(Canvas canvas)
[Expand]
Inherited Methods
From class android.widget.FrameLayout
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.ViewManager
From interface android.view.ViewParent
From interface android.view.accessibility.AccessibilityEventSource

Public Constructors

public ButtonDropin (Context context)

public ButtonDropin (Context context, AttributeSet attrs)

public ButtonDropin (Context context, AttributeSet attrs, int defStyleAttr)

public ButtonDropin (Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Public Methods

public observable ()

public void prepareForDisplayWithContext (PlacementContext context, ButtonDropin.Listener listener)

This is where you prepare this ButtonDropin with a context so we can serve a highly customized button, depending on your use case. See setListener(Listener) on how to set a permanent listener for this dropin instance

Parameters
context the context used to customize your button, e.g. location information, see ButtonDropin
listener one time callback for this call,

public void prepareForDisplayWithContext (PlacementContext context)

public void refresh ()

public void setListener (ButtonDropin.Listener listener)

Set a permanent listener to observe changes in visibility for this promotion. Can be used to e.g. enable/disable other UI elements. Set to null to unregister

Parameters
listener will be called whenever a promotion change happens.

Protected Methods

protected void onAttachedToWindow ()

protected void onDetachedFromWindow ()

protected void onDraw (Canvas canvas)