public class

Preview

extends Object
implements Parcelable
java.lang.Object
   ↳ com.usebutton.sdk.models.Preview

Class Overview

The Preview class holds a short preview of an AppAction, the getText() method will represent the text while getIconUri() holds the URI for an icon for the app we're linking into. In your android.view.View.OnClickListener you can choose to invoke this preview when clicked or show your own custom UI. If you choose to render your own UI, please refer to the Custom Button UI guide for more information. Please refer to getAction(String, ButtonContext, Button.ActionListener) for a more comprehensive code example on usage of this class. Example:

     AppAction action;
     Preview preview = action.getPreview();
     android.widget.ImageButton button = (ImageButton) findViewById(R.id.activity_my_button);
     if (preview.getText() != null) {
         preview.getText().applyTo(button);
     }
     button.setBackgroundColor(preview.getBackgroundColor());
     button.setBack
     SomeImageLoader.load(preview.getIconUri(), new OnImage {
        @Override
        public void onImage(final Bitmap image) {
            button.setImageBitmap(image);
        }
     });

     b.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(final View v) {
              action.invokePreview(v.getContext());
           }
     });
 

Summary

[Expand]
Inherited Constants
From interface android.os.Parcelable
Public Methods
int getBackgroundColor()
Uri getIconUri()
Text getText()
This is the preview's text, it has a styling hint for the text's color (getColor()) and a string copy (getCopy().
boolean hasAction()
If this method returns true you should call AppAction#invokePreview(Context) even if you have your own custom UI.
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Public Methods

public int getBackgroundColor ()

Returns
  • an int representation of the suggested color for this Preview like outlined in Color.

public Uri getIconUri ()

Returns
  • Uri or null to a preview icon (usually a square app icon)

public Text getText ()

This is the preview's text, it has a styling hint for the text's color (getColor()) and a string copy (getCopy().

Returns
  • text or null if no text for this preview.

public boolean hasAction ()

If this method returns true you should call AppAction#invokePreview(Context) even if you have your own custom UI.

     AppAction action; Context context;
     if (action.getPreview().hasAction()) {
         action.invokePreview(context);
     }
     else {
         showMyCustomCard(action.getListBody());
     }
 

Returns
  • true if this Preview should be invoked.