I have opened the constructor and setContainer function to simplify implementation of custom views. Since the container property is a lateinit var, a readable error is already thrown when the engine would use the container:
kotlin.UninitializedPropertyAccessException: lateinit property container has not been initialized
at com.otaliastudios.zoom.ZoomEngine.access$getContainer$p(ZoomEngine.kt:35)
In addition I have added a check in addListener because without calling addListener you don't need an engine.
The following exception is thrown, if setContainer is not called and addListener is used:
Caused by: java.lang.IllegalStateException: container is not initialized.
at com.otaliastudios.zoom.ZoomEngine.addListener(ZoomEngine.kt:357)
If setContainer is called twice, an error like the following is thrown:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.otaliastudios.zoom.demo/com.otaliastudios.zoom.demo.MainActivity}: android.view.InflateException: Binary XML file line #26 in com.otaliastudios.zoom.demo:layout/activity_main: Binary XML file line #26 in com.otaliastudios.zoom.demo:layout/activity_main: Error inflating class com.otaliastudios.zoom.ZoomImageView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)
...
Caused by: java.lang.IllegalStateException: container already set
at com.otaliastudios.zoom.ZoomEngine.setContainer(ZoomEngine.kt:541)
at com.otaliastudios.zoom.ZoomImageView.<init>(ZoomImageView.kt:61)
Solution
I have opened the constructor and setContainer function to simplify implementation of custom views. Since the container property is a lateinit var, a readable error is already thrown when the engine would use the container:
In addition I have added a check in
addListener
because without callingaddListener
you don't need an engine. The following exception is thrown, ifsetContainer
is not called andaddListener
is used:If setContainer is called twice, an error like the following is thrown: