diff options
Diffstat (limited to 'shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeMeasuredText.java')
-rw-r--r-- | shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeMeasuredText.java | 62 |
1 files changed, 25 insertions, 37 deletions
diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeMeasuredText.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeMeasuredText.java index 321db9ed8..d22cd3834 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeMeasuredText.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeMeasuredText.java @@ -18,31 +18,35 @@ import org.robolectric.versioning.AndroidVersions.U; import org.robolectric.versioning.AndroidVersions.V; /** Shadow for {@link MeasuredText} that is backed by native code */ -@Implements(value = MeasuredText.class, minSdk = Q, shadowPicker = Picker.class) +@Implements( + value = MeasuredText.class, + minSdk = Q, + shadowPicker = Picker.class, + callNativeMethodsByDefault = true) public class ShadowNativeMeasuredText { - @Implementation + @Implementation(maxSdk = U.SDK_INT) protected static float nGetWidth( /* Non Zero */ long nativePtr, @IntRange(from = 0) int start, @IntRange(from = 0) int end) { return MeasuredTextNatives.nGetWidth(nativePtr, start, end); } - @Implementation + @Implementation(maxSdk = U.SDK_INT) protected static /* Non Zero */ long nGetReleaseFunc() { DefaultNativeRuntimeLoader.injectAndLoad(); return MeasuredTextNatives.nGetReleaseFunc(); } - @Implementation + @Implementation(maxSdk = U.SDK_INT) protected static int nGetMemoryUsage(/* Non Zero */ long nativePtr) { return MeasuredTextNatives.nGetMemoryUsage(nativePtr); } - @Implementation + @Implementation(maxSdk = U.SDK_INT) protected static void nGetBounds(long nativePtr, char[] buf, int start, int end, Rect rect) { MeasuredTextNatives.nGetBounds(nativePtr, buf, start, end, rect); } - @Implementation + @Implementation(maxSdk = U.SDK_INT) protected static float nGetCharWidthAt(long nativePtr, int offset) { return MeasuredTextNatives.nGetCharWidthAt(nativePtr, offset); } @@ -51,9 +55,20 @@ public class ShadowNativeMeasuredText { @Implements( value = MeasuredText.Builder.class, minSdk = Q, - shadowPicker = ShadowNativeMeasuredTextBuilder.Picker.class) + shadowPicker = ShadowNativeMeasuredTextBuilder.Picker.class, + callNativeMethodsByDefault = true) public static class ShadowNativeMeasuredTextBuilder { - @Implementation + + /** + * The {@link MeasuredText.Builder} static initializer invokes its own native methods. This has + * to be deferred starting in Android V. + */ + @Implementation(minSdk = V.SDK_INT) + protected static void __staticInitializer__() { + // deferred + } + + @Implementation(maxSdk = U.SDK_INT) protected static /* Non Zero */ long nInitBuilder() { return MeasuredTextBuilderNatives.nInitBuilder(); } @@ -80,20 +95,7 @@ public class ShadowNativeMeasuredText { MeasuredTextBuilderNatives.nAddStyleRun(nativeBuilderPtr, paintPtr, start, end, isRtl); } - @Implementation(minSdk = V.SDK_INT) - protected static void nAddStyleRun( - /* Non Zero */ long nativeBuilderPtr, - /* Non Zero */ long paintPtr, - int lineBreakStyle, - int lineBreakWordStyle, - /* Ignored */ boolean hyphenation, - int start, - int end, - boolean isRtl) { - MeasuredTextBuilderNatives.nAddStyleRun(nativeBuilderPtr, paintPtr, start, end, isRtl); - } - - @Implementation + @Implementation(maxSdk = U.SDK_INT) protected static void nAddReplacementRun( /* Non Zero */ long nativeBuilderPtr, /* Non Zero */ long paintPtr, @@ -126,21 +128,7 @@ public class ShadowNativeMeasuredText { nativeBuilderPtr, hintMtPtr, text, computeHyphenation, computeLayout); } - @Implementation(minSdk = V.SDK_INT) - protected static long nBuildMeasuredText( - /* Non Zero */ long nativeBuilderPtr, - long hintMtPtr, - char[] text, - boolean computeHyphenation, - boolean computeLayout, - boolean computeBounds, - /** ignored */ - boolean fastHyphenationMode) { - return MeasuredTextBuilderNatives.nBuildMeasuredText( - nativeBuilderPtr, hintMtPtr, text, computeHyphenation, computeLayout); - } - - @Implementation + @Implementation(maxSdk = U.SDK_INT) protected static void nFreeBuilder(/* Non Zero */ long nativeBuilderPtr) { MeasuredTextBuilderNatives.nFreeBuilder(nativeBuilderPtr); } |