DurationSpan
public
final
class
DurationSpan
extends CarSpan
A span that replaces the text it is attached to with a localized duration string.
For example, the following code creates a string that shows the duration as the first text in
the string before the interpunct:
String interpunct = "\\u00b7";
SpannableString string = new SpannableString(" " + interpunct + " Point-of-Interest 1");
string.setSpan(DurationSpan.create(300), 0, 1, SPAN_INCLUSIVE_INCLUSIVE);
The span flags (e.g. SPAN_EXCLUSIVE_EXCLUSIVE) will be ignored.
This span will be ignored if it overlaps with any span that replaces text, such as another
DistanceSpan
, DurationSpan
, or CarIconSpan
. However, it is possible to *
apply styling to the text, such as changing colors:
String interpunct = "\\u00b7";
SpannableString string = new SpannableString(" " + interpunct + " Point-of-Interest 1");
string.setSpan(DurationSpan.create(300), 0, 1, SPAN_INCLUSIVE_INCLUSIVE);
string.setSpan(ForegroundCarColorSpan.create(CarColor.BLUE), 0, 1, SPAN_EXCLUSIVE_EXCLUSIVE);
Summary
Inherited methods |
|
|
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
|
Public methods
create
public static DurationSpan create (Duration duration)
Creates a DurationSpan
with the given duration.
Parameters |
duration |
Duration |
create
public static DurationSpan create (long durationSeconds)
Creates a DurationSpan
with the given duration.
Parameters |
durationSeconds |
long |
equals
public boolean equals (Object other)
getDurationSeconds
public long getDurationSeconds ()
Returns the time duration associated with this span, in seconds.
hashCode
public int hashCode ()
toString
public String toString ()