Android: Fix possible crash in TouchscreenControllerView

This commit is contained in:
Connor McLaughlin 2020-10-11 14:51:14 +10:00
parent 7775774761
commit 2ce9baa8ad
1 changed files with 4 additions and 3 deletions

View File

@ -44,9 +44,6 @@ public class TouchscreenControllerView extends FrameLayout {
LayoutInflater inflater = LayoutInflater.from(getContext());
switch (viewType)
{
case "none":
break;
case "digital":
mMainView = inflater.inflate(R.layout.layout_touchscreen_controller_digital, this, true);
break;
@ -59,11 +56,15 @@ public class TouchscreenControllerView extends FrameLayout {
mMainView = inflater.inflate(R.layout.layout_touchscreen_controller_analog_sticks, this, true);
break;
case "none":
default:
mMainView = null;
break;
}
if (mMainView == null)
return;
mMainView.setOnTouchListener((view1, event) -> {
return handleTouchEvent(event);
});