centre the PreviewView between the top action icons and the bottom mode switcher view for 4:3, 3:2 (video mode - SD) and 1:1 resolutions, when not full screen
fix NullPointerException thrown in the GestureDetector listeneronFling. The reason why it happens even though we added the null checks and caught exception is this:
The GestureDetector.SimpleOnGestureListener class is in Java and the MotionEvent parameters to onFling are marked as @NonNull. When used in a Kotlin file, the compiler will add Instrisincs.checkNotNullParameter checks before our code and this is what causes the crash
To fix it, we have to create GestureDetectorListener, a Java wrapper file for the SimpleOnGestureListener class and mark the parameters as @Nullable. So now, the Kotlin compiler will not add these non-null checks.
Notes
PreviewView
between the top action icons and the bottom mode switcher view for4:3
,3:2
(video mode -SD
) and1:1
resolutions, when not full screenNullPointerException
thrown in theGestureDetector
listeneronFling
. The reason why it happens even though we added the null checks and caught exception is this:The
GestureDetector.SimpleOnGestureListener
class is in Java and theMotionEvent
parameters toonFling
are marked as@NonNull
. When used in a Kotlin file, the compiler will addInstrisincs.checkNotNullParameter
checks before our code and this is what causes the crashTo fix it, we have to create
GestureDetectorListener
, a Java wrapper file for theSimpleOnGestureListener
class and mark the parameters as@Nullable
. So now, the Kotlin compiler will not add these non-null checks.