Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4a772fc4 authored by Fan Zhang's avatar Fan Zhang Committed by Android (Google) Code Review
Browse files

Merge "Refactor the nativePtr validation code to a method."

parents dfa4c24a 9fe7cdf3
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -232,9 +232,7 @@ public class MeasuredText {
         * @throws IllegalStateException if this Builder is reused.
         */
        public MeasuredText build() {
            if (mNativePtr == 0) {
                throw new IllegalStateException("Builder can not be reused.");
            }
            ensureNativePtrNoReuse();
            try {
                long ptr = nBuildMeasuredText(mNativePtr, mText, mComputeHyphenation,
                        mComputeLayout);
@@ -247,6 +245,18 @@ public class MeasuredText {
            }
        }

        /**
         * Ensures {@link #mNativePtr} is not reused.
         *
         * <p/> This is a method by itself to help increase testability - eg. Robolectric might want
         * to override the validation behavior in test environment.
         */
        private void ensureNativePtrNoReuse() {
            if (mNativePtr == 0) {
                throw new IllegalStateException("Builder can not be reused.");
            }
        }

        private static native /* Non Zero */ long nInitBuilder();

        /**