Expand Minimize Picture-in-picture Power Device Status Voice Recognition Skip Back Skip Forward Minus Plus Play Search
Internet Explorer alert
This browser is not recommended for use with smartdevicelink.com, and may not function properly. Upgrade to a different browser to guarantee support of all features.
close alert
To Top Created with Sketch. To Top
To Bottom Created with Sketch. To Bottom
JavaSE Documentation
SoftButtonObject

Class SoftButtonObject

Hierarchy

java.lang.Object

Package
com.smartdevicelink.managers.screen
All Implemented Interfaces
java.lang.Cloneable

Overview

SoftButtonObject
SoftButtonObject defines a button that can have multiple SoftButtonState values.
The states of SoftButtonObject allow the developer to not have to manage multiple SoftButtons that have very similar functionality.
For example, a repeat button in a music app can be thought of as one SoftButtonObject with three typical states: repeat off, repeat 1, and repeat on.

Constructors

SoftButtonObject( String name, java.util.List<com.smartdevicelink.managers.screen.SoftButtonState> states, String initialStateName, SoftButtonObject.OnEventListener onEventListener )

Create a new instance of the SoftButtonObject with multiple states

public SoftButtonObject(String name,java.util.List<com.smartdevicelink.managers.screen.SoftButtonState> states,String initialStateName,SoftButtonObject.OnEventListener onEventListener)

Constructor Parameters

name
a String value represents name of the object
states
a list of SoftButtonState represents the SoftButtonState values for the object. states should be unique for every SoftButtonObject. A SoftButtonState instance cannot be reused for multiple SoftButtonObjects.
initialStateName
a String value represents the name for the initial state
onEventListener
a listener that has a callback that will be triggered when a button event happens Note: the initialStateName should match exactly the name of one of the states for the object. Otherwise an exception will be thrown.

SoftButtonObject( String name, SoftButtonState state, SoftButtonObject.OnEventListener onEventListener )

Create a new instance of the SoftButtonObject with one state

public SoftButtonObject(String name,SoftButtonState state,SoftButtonObject.OnEventListener onEventListener)

Constructor Parameters

name
a String value represents name of the object
state
a SoftButtonState represents state for the object
onEventListener
a listener that has a callback that will be triggered when a button event happens

SoftButtonObject( String name, String text, SdlArtwork artwork, SoftButtonObject.OnEventListener onEventListener )

Create a new instance of the SoftButtonObject with one state

public SoftButtonObject(String name,String text,SdlArtwork artwork,SoftButtonObject.OnEventListener onEventListener)

Constructor Parameters

name
a String value represents name of the object
text
artwork
a SdlArtwork to be displayed on the button
onEventListener
a listener that has a callback that will be triggered when a button event happens

Methods

transitionToStateByName( String newStateName )

Transition the SoftButtonObject to a specific state

public boolean transitionToStateByName(String newStateName)

Method Parameters

newStateName
a String value represents the name fo the state that we want to transition the SoftButtonObject to

transitionToNextState()

Transition the SoftButtonObject to the next state

public void transitionToNextState()

getCurrentState()

Get the current state for the SoftButtonObject

public com.smartdevicelink.managers.screen.SoftButtonState getCurrentState()

getCurrentStateSoftButton()

Get the SoftButton object for the current state

public com.smartdevicelink.proxy.rpc.SoftButton getCurrentStateSoftButton()

setUpdateListener( SoftButtonObject.UpdateListener updateListener )

Set the SoftButtonManager's update listener

protected void setUpdateListener(SoftButtonObject.UpdateListener updateListener)

Method Parameters

updateListener
the SoftButtonManager.UpdateListener object

getName()

Get the name of the SoftButtonObject

public java.lang.String getName()

setName( String name )

Set the name of the SoftButtonObject

public void setName(String name)

Method Parameters

name
a String that represents the name of the SoftButtonObject

getStates()

Get the SoftButtonState list

public java.util.List getStates()

setStates( java.util.List<com.smartdevicelink.managers.screen.SoftButtonState> states )

Set the SoftButtonState list

public void setStates(java.util.List<com.smartdevicelink.managers.screen.SoftButtonState> states)

Method Parameters

states
a list of the object's soft button states. states should be unique for every SoftButtonObject. A SoftButtonState instance cannot be reused for multiple SoftButtonObjects.

getCurrentStateName()

Get the name of the current state

public java.lang.String getCurrentStateName()

setCurrentStateName( String currentStateName )

Set the name of the current state

public void setCurrentStateName(String currentStateName)

Method Parameters

currentStateName
a String that represents the name of the current state

getButtonId()

Get the id of the SoftButtonObject

public int getButtonId()

setButtonId( int buttonId )

Deprecated
DO NOT USE! let the managers assign ID's. In next major version change this will be restricted to the library Sets the id of the SoftButtonObject
Note: If the developer did not set buttonId, the manager will automatically assign an id before the SoftButtons are sent to the head unit. Please note that the manager may reuse ids from previous batch of SoftButtons that were already sent to the head unit

public void setButtonId(int buttonId)

Method Parameters

buttonId
an int value that represents the id of the SoftButtonObject

getOnEventListener()

Get the event listener for the SoftButtonObject

public com.smartdevicelink.managers.screen.SoftButtonObject.OnEventListener getOnEventListener()

setOnEventListener( SoftButtonObject.OnEventListener onEventListener )

Set the event listener for the SoftButtonObject

public void setOnEventListener(SoftButtonObject.OnEventListener onEventListener)

Method Parameters

onEventListener
a listener that has a callback that will be triggered when a button event happens

hashCode()

Used to compile hashcode for SoftButtonsObjects for use to compare in equals method

public int hashCode()

equals( Object o )

Uses our custom hashCode for SoftButtonObject objects

public boolean equals(Object o)

Method Parameters

o
- The object to compare

clone()

Creates a deep copy of the object

public com.smartdevicelink.managers.screen.SoftButtonObject clone()

Inherited Methods

From Class Methods
java.lang.Object getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize
View on GitHub.com
Previous Section Next Section