
org.robolectric.shadows.ShadowTextUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of shadows-framework Show documentation
Show all versions of shadows-framework Show documentation
An alternative Android testing framework.
The newest version!
package org.robolectric.shadows;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.TextUtils.TruncateAt;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
/** Implement {@link TextUtils#ellipsize} by truncating the text. */
@SuppressWarnings({"UnusedDeclaration"})
@Implements(TextUtils.class)
public class ShadowTextUtils {
@Implementation
protected static CharSequence ellipsize(
CharSequence text, TextPaint p, float avail, TruncateAt where) {
// This shadow follows the convention of ShadowPaint#measureText where each
// characters width is 1.0.
if (avail <= 0) {
return "";
} else if (text.length() < (int) (avail)) {
return text;
} else {
return text.subSequence(0, (int) avail);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy