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

Commit 61ee45f2 authored by Shamali P's avatar Shamali P
Browse files

Add a factory for PreviewPositionHelper

Enables testing as well as serves as a way to convey to clients that it
is stateful and hence a factory may need to be used to get a new object
for distinct invocations.

Bug: 399641570
Flag: EXEMPT BUGFIX
Test: N/A
Change-Id: I8411c4f8ef110128f9d59a24a5b5705bbf9abf7b
parent 901d7f99
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -208,4 +208,19 @@ public class PreviewPositionHelper {
        }
        mMatrix.postTranslate(translateX, translateY);
    }

    /**
     * A factory that returns a new instance of the {@link PreviewPositionHelper}.
     * <p>{@link PreviewPositionHelper} is a stateful helper, and hence when using it in distinct
     * scenarios, prefer fetching an object using this factory</p>
     * <p>Additionally, helpful for injecting mocks in tests</p>
     */
    public static class PreviewPositionHelperFactory {
        /**
         * Returns a new {@link PreviewPositionHelper} for use in a distinct scenario.
         */
        public PreviewPositionHelper create() {
            return new PreviewPositionHelper();
        }
    }
}