Class AutoScroller
AutoScroller is a utility class to send a large known block of predefined text to the glasses to be smoothly scrolled. This is similar to what seen on a teleprompter or in movie credits.
This class does not implement any interfaces to the glasses. This is a convenience class to track state and perform SDK calls to implement a specific behavior. All the functionality provided by this class could be developed using only the public SDK.
This is uses TextToImageSlicer utility class to create the content that is sent to the glasses.
If the content is not known up front, or subject to change, this is the utility class will not work. Use LiveText instead.
- Since:
- 1.4.0
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Interface class to receive a notification when the AutoScroller worker thread completes. -
Constructor Summary
ConstructorDescriptionAutoScroller
(UltraliteSDK ultraliteSdk, String textContents, int lineHeight, int startingLineIndex, int numberOfLines, int lineWidth, android.text.TextPaint textPaint) Creates an instance of the AutoScroller.AutoScroller
(UltraliteSDK ultraliteSdk, String textContents, int lineHeight, int numberOfLines, int lineWidth, android.text.TextPaint textPaint) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionboolean
isPaused()
Determine if the scrolling is paused.void
pause()
Call this afterstart()
to temporarily pause the scroll.void
resume()
Call this afterpause()
to resumevoid
Add a callback to know when the full contents have been scrolled off the screenvoid
setDuration
(int durationMs) Set the duration of each line.void
start()
Start showing the text.void
Stops sending the text and clears the display.
-
Constructor Details
-
AutoScroller
public AutoScroller(UltraliteSDK ultraliteSdk, String textContents, int lineHeight, int numberOfLines, int lineWidth, android.text.TextPaint textPaint) Deprecated.Beginning in 1.7.0 useAutoScroller(UltraliteSDK, String, int, int, int, int, TextPaint)
for the version that specifies startingLineIndex.Creates an instance of the AutoScroller.- Parameters:
ultraliteSdk
- The instance of your UltraliteSDK.textContents
- The pre-defined text to scroll across the glasses.lineHeight
- The number of glasses pixels each line of text will utilize. This must be large enough to fit a single line of text at the requested font size, plus any inter-line padding that is desired. Range: [30-120] pixels. This divides the screen into between 4 and 16 lines of text.numberOfLines
- The number of lines that will be visible. Note: showing fewer lines will scroll more smoothly. Range: [ 1 - (480/lineHeight) ].lineWidth
- The width of the text on the screen. Range: [30-640].textPaint
- Specifies all attributes related to text drawing. Send null to use the default TextPaint.- Since:
- 1.4.0
-
AutoScroller
public AutoScroller(UltraliteSDK ultraliteSdk, String textContents, int lineHeight, int startingLineIndex, int numberOfLines, int lineWidth, android.text.TextPaint textPaint) Creates an instance of the AutoScroller.- Parameters:
ultraliteSdk
- The instance of your UltraliteSDK.textContents
- The pre-defined text to scroll across the glasses.lineHeight
- The number of glasses pixels each line of text will utilize. This must be large enough to fit a single line of text at the requested font size, plus any inter-line padding that is desired. Range: [30-120] pixels. This divides the screen into between 4 and 16 lines of text. Recommended starting value: 48.startingLineIndex
- The text row index to which to start text. Zero starts text at the lowest possible starting point. Range: [ 0 - ((480/lineHeight)-1)]. Recommended starting value: 0.numberOfLines
- The number of lines that will be visible. Note: showing fewer lines will scroll more smoothly. Range: [ 1 - ((480/lineHeight)-startingLineIndex) ]. Recommended starting value: 5.lineWidth
- The width of the text on the screen. Range: [30-640]. Recommended starting value: 640.textPaint
- Specifies all attributes related to text drawing. Send null to use the default TextPaint.- Since:
- 1.7.0
-
-
Method Details
-
setDuration
public void setDuration(int durationMs) Set the duration of each line. This controls the speed of the scroll. This may be called before start() or while the text is scrolling.- Parameters:
durationMs
- Number of milliseconds each lines is shown. Default=3000.- Since:
- 1.4.0
-
setCallback
Add a callback to know when the full contents have been scrolled off the screen- Parameters:
client
- callback method to invoke upon completion- Since:
- 1.4.0
-
start
Start showing the text. This creates a worker thread. Be sure to call
stopAndClear()
or wait for theAutoScroller.AutoScrollEnded
callback after this is called to prevent data collisions.The caller must requestControl() and setLayout(Layout.SCROLL,...) prior to calling this.
- Throws:
IllegalStateException
- If we do not have control or are not in the scroll layout.- Since:
- 1.4.0
- See Also:
-
pause
Call this afterstart()
to temporarily pause the scroll.- Throws:
IllegalStateException
- If we do not have control- Since:
- 1.4.0
- See Also:
-
resume
Call this afterpause()
to resume- Throws:
IllegalStateException
- If we do not have control- Since:
- 1.4.0
- See Also:
-
isPaused
public boolean isPaused()Determine if the scrolling is paused.- Returns:
- True if paused. False if scrolling, or not yet started.
- Since:
- 1.4.0
-
stopAndClear
public void stopAndClear()Stops sending the text and clears the display. Does not release control or set the Layout. It is safe to call this after losing control, but not required.- Since:
- 1.4.0
-
AutoScroller(UltraliteSDK, String, int, int, int, int, TextPaint)
for the version that specifies startingLineIndex.